Skip to content

Commit dae3c6b

Browse files
authored
ci: consolidate upload test report into a reusable action (#1273)
Signed-off-by: Justin Alvarez <alvajus@amazon.com>
1 parent 5c52f7d commit dae3c6b

File tree

4 files changed

+157
-213
lines changed

4 files changed

+157
-213
lines changed

.github/workflows/e2e-linux.yaml

Lines changed: 13 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -135,94 +135,23 @@ jobs:
135135
if: ${{ steps.vars.outputs.has_creds == 'true' && (!(startsWith(inputs.os, 'amazon') && inputs.version == '2' ))}}
136136
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
137137
with:
138-
name: linux-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
138+
name: linux-${{ inputs.version }}-test-e2e-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
139139
path: ${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-*.json
140140
- name: Clean up repo AL2
141141
if: ${{ (startsWith(inputs.os, 'amazon') && inputs.version == '2' && always() ) }}
142142
run: |
143143
rm -rf "${GITHUB_WORKSPACE}"
144-
upload-linux-e2e-test-report:
144+
upload-e2e-test-reports:
145145
needs: test
146146
if: always()
147-
runs-on:
148-
[
149-
"self-hosted",
150-
"linux",
151-
"${{ inputs.arch }}",
152-
"${{ inputs.version }}",
153-
"${{ inputs.runner-type }}",
154-
]
155-
timeout-minutes: 5
156-
steps:
157-
- name: Set output variables to check AL2
158-
id: linux2
159-
run: |
160-
is_al2=${{ (startsWith(inputs.os, 'amazon') && inputs.version == '2' ) }}
161-
echo "is_al2=$is_al2" >> $GITHUB_OUTPUT
162-
- name: configure aws credentials
163-
uses: aws-actions/configure-aws-credentials@4fc4975a852c8cd99761e2de1f4ba73402e44dd9 # v4.0.3
164-
if: |
165-
steps.linux2.outputs.is_al2 == 'false'
166-
&& needs.test.outputs.has_creds == 'true'
167-
&& github.event_name == 'pull_request'
168-
&& github.event.action == 'closed'
169-
&& github.event.pull_request.merged == true
170-
with:
171-
role-to-assume: ${{ secrets.ROLE }}
172-
role-session-name: credhelper-test
173-
aws-region: ${{ secrets.REGION }}
174-
- name: download artifacts
175-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.08
176-
if: |
177-
steps.linux2.outputs.is_al2 == 'false'
178-
&& needs.test.outputs.has_creds == 'true'
179-
&& github.event_name == 'pull_request'
180-
&& github.event.action == 'closed'
181-
&& github.event.pull_request.merged == true
182-
with:
183-
name: linux-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
184-
path: linux-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
185-
- name: Display structure of downloaded files
186-
if: |
187-
steps.linux2.outputs.is_al2 == 'false'
188-
&& needs.test.outputs.has_creds == 'true'
189-
&& github.event_name == 'pull_request'
190-
&& github.event.action == 'closed'
191-
&& github.event.pull_request.merged == true
192-
run: ls -R linux-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
193-
- name: Check and upload e2e tests reports to s3 bucket
194-
if: |
195-
steps.linux2.outputs.is_al2 == 'false'
196-
&& needs.test.outputs.has_creds == 'true'
197-
&& github.event_name == 'pull_request'
198-
&& github.event.action == 'closed'
199-
&& github.event.pull_request.merged == true
200-
201-
run: |
202-
VM_REPORT="${{ github.workspace }}/linux-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json"
203-
CONTAINER_REPORT="${{ github.workspace }}/linux-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json"
204-
VM_SERIAL_REPORT="${{ github.workspace }}/linux-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json"
205-
206-
if [ -f "$VM_REPORT" ]; then
207-
echo "VM report file exists. Uploading to S3..."
208-
aws s3 cp "$VM_REPORT" "s3://finch-e2e-test-log-reports/linux-${{ inputs.arch }}/${{ needs.test.outputs.vm_report }}"
209-
echo "VM report uploaded successfully."
210-
else
211-
echo "VM report file does not exist. Skipping upload."
212-
fi
213-
214-
if [ -f "$CONTAINER_REPORT" ]; then
215-
echo "Container report file exists. Uploading to S3..."
216-
aws s3 cp "$CONTAINER_REPORT" "s3://finch-e2e-test-log-reports/linux-${{ inputs.arch }}/${{ needs.test.outputs.container_report }}"
217-
echo "Container report uploaded successfully."
218-
else
219-
echo "Container report file does not exist. Skipping upload."
220-
fi
221-
222-
if [ -f "$VM_SERIAL_REPORT" ]; then
223-
echo "VM serial report file exists. Uploading to S3..."
224-
aws s3 cp "$VM_SERIAL_REPORT" "s3://finch-e2e-test-log-reports/linux-${{ inputs.arch }}/${{ needs.test.outputs.vm_serial_report }}"
225-
echo "VM serial report uploaded successfully."
226-
else
227-
echo "VM serial report file does not exist. Skipping upload."
228-
fi
147+
uses: ./.github/workflows/upload-test-report.yaml
148+
secrets: inherit
149+
with:
150+
os: ${{ inputs.os }}
151+
arch: ${{ inputs.arch }}
152+
version: ${{ inputs.version }}
153+
test-command: "test-e2e"
154+
has-creds: ${{ needs.test.outputs.has_creds }}
155+
vm_report: ${{ needs.test.outputs.vm_report }}
156+
container_report: ${{ needs.test.outputs.container_report }}
157+
vm_serial_report: ${{ needs.test.outputs.vm_serial_report }}

.github/workflows/e2e-macos.yaml

Lines changed: 12 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -103,74 +103,17 @@ jobs:
103103
with:
104104
name: macos-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
105105
path: ${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-*.json
106-
upload-macos-e2e-test-report:
106+
upload-e2e-test-reports:
107107
needs: test
108108
if: always()
109-
runs-on:
110-
[
111-
"self-hosted",
112-
"macos",
113-
"${{ inputs.arch }}",
114-
"${{ inputs.version }}",
115-
"${{ inputs.runner-type }}",
116-
]
117-
timeout-minutes: 5
118-
steps:
119-
- name: configure aws credentials
120-
uses: aws-actions/configure-aws-credentials@4fc4975a852c8cd99761e2de1f4ba73402e44dd9 # v4.0.3
121-
if: |
122-
needs.test.outputs.has_creds == 'true'
123-
&& github.event_name == 'pull_request'
124-
&& github.event.action == 'closed'
125-
&& github.event.pull_request.merged == true
126-
with:
127-
role-to-assume: ${{ secrets.ROLE }}
128-
role-session-name: credhelper-test
129-
aws-region: ${{ secrets.REGION }}
130-
- name: download artifacts
131-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.08
132-
if: |
133-
needs.test.outputs.has_creds == 'true'
134-
&& github.event_name == 'pull_request'
135-
&& github.event.action == 'closed'
136-
&& github.event.pull_request.merged == true
137-
with:
138-
name: macos-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
139-
path: macos-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
140-
- name: Display structure of downloaded files
141-
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
142-
run: ls -R macos-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
143-
- name: Check and upload e2e tests reports to s3 bucket
144-
if: |
145-
needs.test.outputs.has_creds == 'true'
146-
&& github.event_name == 'pull_request'
147-
&& github.event.action == 'closed'
148-
&& github.event.pull_request.merged == true
149-
run: |
150-
VM_REPORT="${{ github.workspace }}/macos-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json"
151-
CONTAINER_REPORT="${{ github.workspace }}/macos-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json"
152-
VM_SERIAL_REPORT="${{ github.workspace }}/macos-${{ inputs.version }}-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json"
153-
154-
if [ -f "$VM_REPORT" ]; then
155-
echo "VM report file exists. Uploading to S3..."
156-
aws s3 cp "$VM_REPORT" "s3://finch-e2e-test-log-reports/macos-${{ inputs.arch }}/${{ needs.test.outputs.vm_report }}"
157-
echo "VM report uploaded successfully."
158-
else
159-
echo "VM report file does not exist. Skipping upload."
160-
fi
161-
162-
if [ -f "$CONTAINER_REPORT" ]; then
163-
echo "Container report file exists. Uploading to S3..."
164-
aws s3 cp "$CONTAINER_REPORT" "s3://finch-e2e-test-log-reports/macos-${{ inputs.arch }}/${{ needs.test.outputs.container_report }}"
165-
echo "Container report uploaded successfully."
166-
else
167-
echo "Container report file does not exist. Skipping upload."
168-
fi
169-
170-
if [ -f "$VM_SERIAL_REPORT" ]; then
171-
echo "VM serial report file exists. Uploading to S3..."
172-
aws s3 cp "$VM_SERIAL_REPORT" "s3://finch-e2e-test-log-reports/macos-${{ inputs.arch }}/${{ needs.test.outputs.vm_serial_report }}"
173-
echo "VM serial report uploaded successfully."
174-
else
175-
echo "VM serial report file does not exist. Skipping upload."
176-
fi
109+
uses: ./.github/workflows/upload-test-report.yaml
110+
secrets: inherit
111+
with:
112+
os: "mac"
113+
arch: ${{ inputs.arch }}
114+
version: ${{ inputs.version }}
115+
test-command: ${{ inputs.test-command }}
116+
has-creds: ${{ needs.test.outputs.has_creds }}
117+
vm_report: ${{ needs.test.outputs.vm_report }}
118+
container_report: ${{ needs.test.outputs.container_report }}
119+
vm_serial_report: ${{ needs.test.outputs.vm_serial_report }}

.github/workflows/e2e-windows.yaml

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ jobs:
3232
"${{ inputs.arch }}",
3333
"${{ inputs.runner-type }}",
3434
]
35+
outputs:
36+
has_creds: ${{ steps.vars.outputs.has_creds}}
37+
vm_report: ${{ steps.set-multiple-vars.outputs.VM_REPORT }}
38+
container_report: ${{ steps.set-multiple-vars.outputs.CONTAINER_REPORT }}
39+
vm_serial_report: ${{ steps.set-multiple-vars.outputs.VM_SERIAL_REPORT }}
3540
steps:
3641
- name: Configure git CRLF settings
3742
run: |
@@ -101,7 +106,7 @@ jobs:
101106
if: always()
102107
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
103108
with:
104-
name: windows-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
109+
name: windows-${{ inputs.test-command }}-2022-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
105110
path: ${{ github.workspace }}/reports/${{ github.run_id }}-${{ github.run_attempt }}-*.json
106111
- name: Remove Finch VM and Clean Up Previous Environment
107112
if: ${{ always() }}
@@ -111,64 +116,17 @@ jobs:
111116
make clean
112117
cd deps/finch-core && make clean
113118
exit 0 # Cleanup may set the exit code e.g. if a file doesn't exist; just ignore
114-
upload-windows-e2e-test-report:
119+
upload-e2e-test-reports:
115120
needs: test
116121
if: always()
117-
timeout-minutes: 5
118-
runs-on:
119-
[
120-
"self-hosted",
121-
"windows",
122-
"${{ inputs.arch }}",
123-
"${{ inputs.runner-type }}",
124-
]
125-
steps:
126-
- name: Set output variables
127-
id: vars
128-
run: |
129-
$has_creds="${{ github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true }}"
130-
echo "has_creds=$has_creds" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
131-
exit 0 # if $has_creds is false, powershell will exit with code 1 and this step will fail
132-
- name: configure aws credentials
133-
uses: aws-actions/configure-aws-credentials@4fc4975a852c8cd99761e2de1f4ba73402e44dd9 # v4.0.3
134-
if: env.has_creds == 'true'
135-
with:
136-
role-to-assume: ${{ secrets.ROLE }}
137-
role-session-name: credhelper-test
138-
aws-region: ${{ secrets.REGION }}
139-
- name: download artifacts
140-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.08
141-
if: env.has_creds == 'true'
142-
with:
143-
name: windows-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
144-
path: windows-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports
145-
- name: Check and upload e2e tests reports to s3 bucket
146-
if: env.has_creds == 'true'
147-
run: |
148-
$env:VM_REPORT = "${{ github.workspace }}\windows-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports\${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json"
149-
$env:CONTAINER_REPORT = "${{ github.workspace }}\windows-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports\${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json"
150-
$env:VM_SERIAL_REPORT = "${{ github.workspace }}\windows-${{ inputs.test-command }}-${{ inputs.arch }}-${{ github.run_id }}-${{ github.run_attempt }}-e2e-reports\${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json"
151-
152-
if (Test-Path $env:VM_REPORT) {
153-
Write-Host "VM report file exists. Uploading to S3..."
154-
aws s3 cp $env:VM_REPORT "s3://finch-e2e-test-log-reports/windows-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-report.json"
155-
Write-Host "VM report uploaded successfully."
156-
} else {
157-
Write-Host "VM report file does not exist. Skipping upload."
158-
}
159-
160-
if (Test-Path $env:CONTAINER_REPORT) {
161-
Write-Host "Container report file exists. Uploading to S3..."
162-
aws s3 cp $env:CONTAINER_REPORT "s3://finch-e2e-test-log-reports/windows-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-container-report.json"
163-
Write-Host "Container report uploaded successfully."
164-
} else {
165-
Write-Host "Container report file does not exist. Skipping upload."
166-
}
167-
168-
if (Test-Path $env:VM_SERIAL_REPORT) {
169-
Write-Host "VM serial report file exists. Uploading to S3..."
170-
aws s3 cp $env:VM_SERIAL_REPORT "s3://finch-e2e-test-log-reports/windows-${{ inputs.arch }}/${{ github.run_id }}-${{ github.run_attempt }}-e2e-vm-serial-report.json"
171-
Write-Host "VM serial report uploaded successfully."
172-
} else {
173-
Write-Host "VM serial report file does not exist. Skipping upload."
174-
}
122+
uses: ./.github/workflows/upload-test-report.yaml
123+
secrets: inherit
124+
with:
125+
os: "windows"
126+
arch: ${{ inputs.arch }}
127+
version: "2022"
128+
test-command: ${{ inputs.test-command }}
129+
has-creds: ${{ needs.test.outputs.has_creds }}
130+
vm_report: ${{ needs.test.outputs.vm_report }}
131+
container_report: ${{ needs.test.outputs.container_report }}
132+
vm_serial_report: ${{ needs.test.outputs.vm_serial_report }}

0 commit comments

Comments
 (0)