Skip to content

Commit 0b034ed

Browse files
authored
Return the list of artifacts from mobile job (#5727)
This updates the mobile job to return the list of artifacts from AWS to the caller to use as they see fit. One of the use case is for ExecuTorch to extract the benchmark results JSON from `CUSTOMER_ARTIFACT` and `TESTSPEC_OUTPUT` (2 types of artifacts from AWS). My plan here is to: * [x] Get the list of artifacts (this PR) * [ ] On ExecuTorch side, extract the benchmark JSON from the artifacts pytorch/executorch#5808 * [ ] Create a new GitHub action on test-infra to upload the JSON (This could be done on ExecuTorch side too, but I plan to make this generic and reusable by other projects, so it must be on test-infra) Minor fixes: * Also update the console output to print out the context of `TESTSPEC_OUTPUT`, which is basically the main output from the device. * Print additional information about the job name (the device name from AWS in disguise) and app type (Android, iOS) * Some lint fix here and there.
1 parent eaaeb36 commit 0b034ed

File tree

3 files changed

+157
-42
lines changed

3 files changed

+157
-42
lines changed

.github/actions/get-workflow-job-id/action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Get workflow job id
33
description: Get the ID of the workflow job that is currently running.
44

55
inputs:
6+
working-directory:
7+
description: The working directory to use
8+
default: ''
69
github-token:
710
description: GITHUB_TOKEN
811
required: true
@@ -19,12 +22,12 @@ runs:
1922
using: composite
2023
steps:
2124
- name: Get job id and name or fail
22-
# timeout-minutes is unsupported for composite workflows, see https://github.com/actions/runner/issues/1979
23-
# timeout-minutes: 10
2425
shell: bash
2526
id: get-job-id
27+
working-directory: ${{ inputs.working-directory }}
2628
run: |
2729
set -eux
30+
2831
python3 .github/scripts/get_workflow_job_id.py "${GITHUB_RUN_ID}" "${RUNNER_NAME}"
2932
env:
3033
GITHUB_TOKEN: ${{ inputs.github-token }}

.github/workflows/mobile_job.yml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,22 @@ on:
9292
type: string
9393
default: ''
9494

95+
outputs:
96+
artifacts:
97+
description: |
98+
The list of artifacts from AWS in JSON format returned to the caller
99+
value: ${{ jobs.mobile.outputs.artifacts }}
100+
95101
jobs:
96-
job:
102+
mobile:
97103
name: ${{ inputs.job-name }} (${{ inputs.device-type }})
98104
runs-on: ${{ inputs.runner }}
99105
timeout-minutes: ${{ inputs.timeout }}
100106
permissions:
101107
id-token: write
102108
contents: read
109+
outputs:
110+
artifacts: ${{ inputs.device-type == 'ios' && steps.ios-test.outputs.artifacts || inputs.device-type == 'android' && steps.android-test.outputs.artifacts || '[]' }}
103111
steps:
104112
- name: Clean workspace
105113
run: |
@@ -112,7 +120,7 @@ jobs:
112120
uses: aws-actions/configure-aws-credentials@v3
113121
with:
114122
role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_mobile_job
115-
# This could go up to 18000, the max duration enforced by the server side
123+
# The max duration enforced by the server side
116124
role-duration-seconds: 18000
117125
aws-region: us-east-1
118126

@@ -254,7 +262,16 @@ jobs:
254262
255263
echo "extra-data-output=${EXTRA_DATA_OUTPUT}" >> "${GITHUB_OUTPUT}"
256264
265+
- name: Get workflow job id
266+
id: get-job-id
267+
uses: ./test-infra/.github/actions/get-workflow-job-id
268+
if: always()
269+
with:
270+
working-directory: test-infra
271+
github-token: ${{ secrets.GITHUB_TOKEN }}
272+
257273
- name: Run iOS tests on devices
274+
id: ios-test
258275
if: ${{ inputs.device-type == 'ios' }}
259276
shell: bash
260277
working-directory: test-infra/tools/device-farm-runner
@@ -270,6 +287,7 @@ jobs:
270287
DEVICE_TYPE: ${{ inputs.device-type }}
271288
RUN_ID: ${{ github.run_id }}
272289
RUN_ATTEMPT: ${{ github.run_attempt }}
290+
JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
273291
run: |
274292
set -ex
275293
@@ -282,9 +300,22 @@ jobs:
282300
--test-spec "${TEST_SPEC}" \
283301
--name-prefix "${JOB_NAME}-${DEVICE_TYPE}" \
284302
--workflow-id "${RUN_ID}" \
285-
--workflow-attempt "${RUN_ATTEMPT}"
303+
--workflow-attempt "${RUN_ATTEMPT}" \
304+
--output "ios-artifacts-${JOB_ID}.json"
305+
306+
- name: Upload iOS artifacts to S3
307+
uses: seemethere/upload-artifact-s3@v5
308+
if: ${{ inputs.device-type == 'ios' }}
309+
with:
310+
retention-days: 14
311+
s3-bucket: gha-artifacts
312+
s3-prefix: |
313+
device_farm/${{ github.run_id }}/${{ github.run_attempt }}/artifacts
314+
path: |
315+
test-infra/tools/device-farm-runner/ios-artifacts-${{ steps.get-job-id.outputs.job-id }}.json
286316
287317
- name: Run Android tests on devices
318+
id: android-test
288319
if: ${{ inputs.device-type == 'android' }}
289320
shell: bash
290321
working-directory: test-infra/tools/device-farm-runner
@@ -300,6 +331,7 @@ jobs:
300331
DEVICE_TYPE: ${{ inputs.device-type }}
301332
RUN_ID: ${{ github.run_id }}
302333
RUN_ATTEMPT: ${{ github.run_attempt }}
334+
JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
303335
run: |
304336
set -ex
305337
@@ -312,4 +344,16 @@ jobs:
312344
--test-spec "${TEST_SPEC}" \
313345
--name-prefix "${JOB_NAME}-${DEVICE_TYPE}" \
314346
--workflow-id "${RUN_ID}" \
315-
--workflow-attempt "${RUN_ATTEMPT}"
347+
--workflow-attempt "${RUN_ATTEMPT}" \
348+
--output "android-artifacts-${JOB_ID}.json"
349+
350+
- name: Upload Android artifacts to S3
351+
uses: seemethere/upload-artifact-s3@v5
352+
if: ${{ inputs.device-type == 'android' }}
353+
with:
354+
retention-days: 14
355+
s3-bucket: gha-artifacts
356+
s3-prefix: |
357+
device_farm/${{ github.run_id }}/${{ github.run_attempt }}/artifacts
358+
path: |
359+
test-infra/tools/device-farm-runner/android-artifacts-${{ steps.get-job-id.outputs.job-id }}.json

0 commit comments

Comments
 (0)