Skip to content

Commit d312070

Browse files
committed
Use a template for Apple test spec
1 parent 0a12e33 commit d312070

File tree

3 files changed

+57
-77
lines changed

3 files changed

+57
-77
lines changed

.github/workflows/apple-perf.yml

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ on:
2525
description: The list of configs used the benchmark
2626
required: false
2727
type: string
28-
test_spec:
29-
description: The test spec to drive the test on AWS devices
30-
required: false
31-
type: string
3228
workflow_call:
3329
inputs:
3430
models:
@@ -50,10 +46,6 @@ on:
5046
description: The list of configs used the benchmark
5147
required: false
5248
type: string
53-
test_spec:
54-
description: The test spec to drive the test on AWS devices
55-
required: false
56-
type: string
5749

5850
concurrency:
5951
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
@@ -114,6 +106,41 @@ jobs:
114106
echo "devices=$(echo "$MAPPED_ARNS_JSON" | jq -c .)" >> $GITHUB_OUTPUT
115107
echo "delegates=$(echo $DELEGATES | jq -Rc 'split(",")')" >> $GITHUB_OUTPUT
116108
109+
prepare-test-specs:
110+
runs-on: linux.2xlarge
111+
needs: set-parameters
112+
strategy:
113+
matrix:
114+
model: ${{ fromJson(needs.set-parameters.outputs.models) }}
115+
delegate: ${{ fromJson(needs.set-parameters.outputs.delegates) }}
116+
fail-fast: false
117+
steps:
118+
- uses: actions/checkout@v3
119+
120+
- name: Prepare the spec
121+
shell: bash
122+
working-directory: extension/benchmark/apple/Benchmark
123+
run: |
124+
set -eux
125+
# The model will be exported in the next step to this S3 path
126+
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/model.zip"
127+
# We could write a script to properly use jinja here, but there is only one variable,
128+
# so let's just sed it
129+
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' default-ios-device-farm-appium-test-spec.yml.j2
130+
cp default-ios-device-farm-appium-test-spec.yml.j2 default-ios-device-farm-appium-test-spec.yml
131+
# Just print the test spec for debugging
132+
cat default-ios-device-farm-appium-test-spec.yml
133+
134+
- name: Upload the spec
135+
uses: seemethere/upload-artifact-s3@v5
136+
with:
137+
s3-bucket: gha-artifacts
138+
s3-prefix: |
139+
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}
140+
retention-days: 1
141+
if-no-files-found: error
142+
path: extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
143+
117144
export-models:
118145
name: export-models
119146
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -173,10 +200,19 @@ jobs:
173200
DELEGATE_CONFIG="mps"
174201
fi
175202
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
176-
bash .ci/scripts/test_llama.sh "${{ matrix.model }}" "${BUILD_MODE}" "${DTYPE}" "${DELEGATE_CONFIG}" "${ARTIFACTS_DIR_NAME}"
203+
bash .ci/scripts/test_llama.sh \
204+
-model "${{ matrix.model }}" \
205+
-build_tool "${BUILD_MODE}" \
206+
-dtype "${DTYPE}" \
207+
-mode "${DELEGATE_CONFIG}" \
208+
-upload "${ARTIFACTS_DIR_NAME}"
177209
else
178210
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
179-
bash .ci/scripts/test_model.sh "${{ matrix.model }}" "${BUILD_MODE}" "${{ matrix.delegate }}" "${ARTIFACTS_DIR_NAME}"
211+
bash .ci/scripts/test_model.sh \
212+
"${{ matrix.model }}" \
213+
"${BUILD_MODE}" \
214+
"${{ matrix.delegate }}" \
215+
"${ARTIFACTS_DIR_NAME}"
180216
fi
181217
echo "::endgroup::"
182218
@@ -282,6 +318,7 @@ jobs:
282318
if: always()
283319
needs:
284320
- set-parameters
321+
- prepare-test-specs
285322
- upload-benchmark-app
286323
- export-models
287324
permissions:
@@ -307,8 +344,7 @@ jobs:
307344
# Uploaded to S3 from the previous job
308345
ios-ipa-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/Benchmark.ipa
309346
ios-xctestrun-zip: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/Benchmark.xctestrun.zip
310-
test-spec: ${{ inputs.test_spec || 'https://ossci-ios.s3.amazonaws.com/executorch/default-ios-device-farm-appium-test-spec.yml' }}
311-
extra-data: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/model.zip
347+
test-spec: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/default-ios-device-farm-appium-test-spec.yml
312348

313349
upload-benchmark-results:
314350
needs:

.github/workflows/upload-apple-test-specs.yml

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
pull_request:
55
paths:
66
- .github/workflows/upload-apple-test-specs.yml
7-
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
7+
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml.j2
88
push:
99
branches:
1010
- main
1111
paths:
1212
- .github/workflows/upload-apple-test-specs.yml
13-
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
13+
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml.j2
1414

1515
concurrency:
1616
# NB: This concurency group needs to be different than the one used in apple-perf, otherwise
@@ -19,23 +19,7 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
jobs:
22-
upload-apple-test-spec-for-validation:
23-
runs-on: linux.2xlarge
24-
steps:
25-
- uses: actions/checkout@v3
26-
27-
- name: Upload the spec as a GitHub artifact for validation
28-
uses: seemethere/upload-artifact-s3@v5
29-
with:
30-
s3-bucket: gha-artifacts
31-
s3-prefix: |
32-
${{ github.repository }}/${{ github.run_id }}/artifacts
33-
retention-days: 1
34-
if-no-files-found: error
35-
path: extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
36-
3722
validate-apple-test-spec:
38-
needs: upload-apple-test-spec-for-validation
3923
uses: ./.github/workflows/apple-perf.yml
4024
secrets: inherit
4125
permissions:
@@ -46,50 +30,3 @@ jobs:
4630
models: stories110M
4731
devices: apple_iphone_15
4832
delegates: xnnpack
49-
test_spec: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/default-ios-device-farm-appium-test-spec.yml
50-
51-
upload-apple-test-spec:
52-
needs: validate-apple-test-spec
53-
runs-on: ubuntu-22.04
54-
timeout-minutes: 15
55-
permissions:
56-
id-token: write
57-
contents: read
58-
steps:
59-
- uses: actions/checkout@v3
60-
61-
- uses: actions/setup-python@v4
62-
with:
63-
python-version: '3.11'
64-
cache: pip
65-
66-
- name: configure aws credentials
67-
uses: aws-actions/[email protected]
68-
with:
69-
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-ios
70-
aws-region: us-east-1
71-
72-
- name: Only push to S3 when running the workflow manually from main branch
73-
if: ${{ github.ref == 'refs/heads/main' }}
74-
shell: bash
75-
run: |
76-
set -eux
77-
echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}"
78-
79-
- name: Upload the spec to S3 ossci-ios bucket
80-
shell: bash
81-
working-directory: extension/benchmark/apple/Benchmark/
82-
env:
83-
SPEC_FILE: default-ios-device-farm-appium-test-spec.yml
84-
run: |
85-
set -eux
86-
87-
pip install awscli==1.32.18
88-
89-
AWS_CMD="aws s3 cp --dryrun"
90-
if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then
91-
AWS_CMD="aws s3 cp"
92-
fi
93-
94-
shasum -a 256 "${SPEC_FILE}"
95-
${AWS_CMD} "${SPEC_FILE}" s3://ossci-ios/executorch/ --acl public-read

extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml renamed to extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ phases:
1010
# The pre-test phase includes commands that setup your test environment.
1111
pre_test:
1212
commands:
13+
# Download the model from S3
14+
- curl -s --fail '{{ model_path }}' -o model.zip
15+
- unzip model.zip && ls -la
16+
1317
- mkdir $DEVICEFARM_TEST_PACKAGE_PATH/Debug-iphoneos
1418
- mkdir $DEVICEFARM_TEST_PACKAGE_PATH/Release-iphoneos
1519
- unzip $DEVICEFARM_APP_PATH -d /tmp
1620
- cp -r /tmp/Payload/*.app $DEVICEFARM_TEST_PACKAGE_PATH/Debug-iphoneos/
1721
- cp -r /tmp/Payload/*.app $DEVICEFARM_TEST_PACKAGE_PATH/Release-iphoneos/
1822

23+
- ls -la $DEVICEFARM_TEST_PACKAGE_PATH/Debug-iphoneos/
24+
- ls -la $DEVICEFARM_TEST_PACKAGE_PATH/Release-iphoneos/
25+
1926
# The test phase includes commands that run your test suite execution.
2027
test:
2128
commands:

0 commit comments

Comments
 (0)