-
-
Notifications
You must be signed in to change notification settings - Fork 314
190 lines (172 loc) · 8.42 KB
/
android-device-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: android-device-test
on:
workflow_run:
workflows: [android-ci]
types:
- completed
permissions:
id-token: write # needed for AWS
jobs:
android-device-test:
strategy:
fail-fast: false
matrix:
test: [
{
artifactName: android-render-tests-opengl,
testFile: RenderTests-opengl.apk,
appFile: RenderTestsApp-opengl.apk,
name: "Android Render Tests (OpenGL)",
# Google Pixel 7 Pro
devicePool: "arn:aws:devicefarm:us-west-2:373521797162:devicepool:20687d72-0e46-403e-8f03-0941850665bc/9692fe7f-86a9-4ecc-908f-175600968564"
},
{
artifactName: android-render-tests-vulkan,
testFile: RenderTests-vulkan.apk,
appFile: RenderTestsApp-vulkan.apk,
name: "Android Render Tests (Vulkan)",
# Google Pixel 7 Pro
devicePool: "arn:aws:devicefarm:us-west-2:373521797162:devicepool:20687d72-0e46-403e-8f03-0941850665bc/9692fe7f-86a9-4ecc-908f-175600968564",
# android-render-test.yml
# see https://github.com/maplibre/ci-runners/tree/main/aws-device-farm/custom-test-envs
testSpecArn: "arn:aws:devicefarm:us-west-2:373521797162:upload:20687d72-0e46-403e-8f03-0941850665bc/c1fc7d3e-dfe3-4a31-9ee0-7b0f71b08872"
},
{
artifactName: benchmarkAPKs,
testFile: "MapLibreAndroidTestApp-drawable-release-androidTest.apk",
appFile: "MapLibreAndroidTestApp-drawable-release.apk",
name: "Android Benchmark",
testFilter: "org.maplibre.android.benchmark.Benchmark",
# Google Pixel 7 Pro
# query with `aws list-device-pools --arn <project_arn>`
devicePool: "arn:aws:devicefarm:us-west-2:373521797162:devicepool:20687d72-0e46-403e-8f03-0941850665bc/9692fe7f-86a9-4ecc-908f-175600968564",
# benchmark-android.yaml
# see https://github.com/maplibre/ci-runners/tree/main/aws-device-farm/custom-test-envs
testSpecArn: "arn:aws:devicefarm:us-west-2:373521797162:upload:20687d72-0e46-403e-8f03-0941850665bc/14862afb-cf88-44aa-9f1e-5131cbb22f01"
},
{
artifactName: android-ui-test,
testFile: InstrumentationTests.apk,
appFile: InstrumentationTestApp.apk,
name: "Android Instrumentation Tests",
# Google Pixel 7 Pro
devicePool: "arn:aws:devicefarm:us-west-2:373521797162:devicepool:20687d72-0e46-403e-8f03-0941850665bc/9692fe7f-86a9-4ecc-908f-175600968564",
testSpecArn: "arn:aws:devicefarm:us-west-2:373521797162:upload:20687d72-0e46-403e-8f03-0941850665bc/09e0738e-c91e-4c5f-81e6-06a06cc340d8"
},
{
artifactName: android-cpp-tests,
testFile: app-release-androidTest.apk,
appFile: app-debug.apk,
name: "Android C++ Unit Tests",
# Google Pixel 7 Pro
devicePool: "arn:aws:devicefarm:us-west-2:373521797162:devicepool:20687d72-0e46-403e-8f03-0941850665bc/9692fe7f-86a9-4ecc-908f-175600968564"
}
]
runs-on: ubuntu-latest
if: github.repository_owner == 'maplibre' && github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v4
- id: parent_workflow
run: |
conclusion=$(curl ${{ github.event.workflow_run.jobs_url }} | jq -r '.jobs[] | select(.name == "android-build").conclusion')
was_skipped=$([[ "$conclusion" = "skipped" || "$conclusion" = "cancelled" ]] && echo "true" || echo "false")
echo "was_skipped=$was_skipped" >> "$GITHUB_OUTPUT"
# get comment from PR
- uses: ./.github/actions/get-pr-number
id: get-pr-number
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
revoke: false # revoking will fail for long running workflows, because the token will already have expired
app_id: ${{ secrets.MAPLIBRE_NATIVE_BOT_APP_ID }}
private_key: ${{ secrets.MAPLIBRE_NATIVE_BOT_PRIVATE_KEY }}
- name: Check if comment on PR contains '!benchmark android'
if: matrix.test.name == 'Android Benchmark' && steps.get-pr-number.outputs.pr-number
uses: peter-evans/find-comment@v3
id: benchmark_comment
with:
issue-number: ${{ steps.get-pr-number.outputs.pr-number }}
body-regex: '^!benchmark.*android.*$'
- name: Should we run this device test?
# always run when something was merged into main
# run benchmark when comment with '!benchmark android' exists in PR
if: |
steps.parent_workflow.outputs.was_skipped == 'false' &&
((github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.event == 'push') ||
matrix.test.name == 'Android Benchmark' && steps.benchmark_comment.outputs.comment-id ||
matrix.test.name != 'Android Benchmark')
run:
echo "run_device_test=true" >> "$GITHUB_ENV"
- uses: LouisBrunner/[email protected]
id: create_check
with:
token: ${{ steps.generate_token.outputs.token }}
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
status: queued
name: ${{ matrix.test.name }}
sha: ${{ github.event.workflow_run.head_sha }}
- uses: ./.github/actions/download-workflow-run-artifact
if: env.run_device_test == 'true'
with:
artifact-name: ${{ matrix.test.artifactName }}
expect-files: "${{ matrix.test.testFile }}, ${{ matrix.test.appFile }}"
- name: Configure AWS Credentials
if: env.run_device_test == 'true'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.run_id }}
- name: Upload external data
if: env.run_device_test == 'true'
run: |
export RESULTS_API=${{ secrets.MLN_RESULTS_API }}
export AWS_DEVICE_FARM_PROJECT_ARN=${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}
upload_arn="$(.github/workflows/android-device-test/upload-external-data.sh)"
echo external_data_arn="$upload_arn" >> "$GITHUB_ENV"
- uses: ./.github/actions/aws-device-farm-run
id: aws_device_farm_run
if: env.run_device_test == 'true'
with:
name: ${{ matrix.test.name }}
appType: ANDROID_APP
appFile: ${{ matrix.test.appFile }}
testFile: ${{ matrix.test.testFile }}
testPackageType: INSTRUMENTATION_TEST_PACKAGE
testType: INSTRUMENTATION
testFilter: ${{ matrix.test.testFilter }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_TO_ASSUME: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }}
AWS_DEVICE_FARM_PROJECT_ARN: ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}
AWS_DEVICE_FARM_DEVICE_POOL_ARN: ${{ matrix.test.devicePool }}
externalData: ${{ env.external_data_arn }}
testSpecArn: ${{ matrix.test.testSpecArn }}
- name: Store Test Artifacts
if: (matrix.test.name == 'Android Benchmark' || failure()) && env.run_device_test == 'true'
run: |
npm install
temp_dir="$(mktemp -d)"
node scripts/aws-device-farm/store-test-artifacts.mjs ${{ steps.aws_device_farm_run.outputs.runArn }} "$temp_dir"
zip -r test_artifacts.zip "$temp_dir"
- name: Upload Test Artifacts
if: (matrix.test.name == 'Android Benchmark' || failure()) && env.run_device_test == 'true'
uses: actions/upload-artifact@v4
with:
name: "Test Artifacts ${{ matrix.test.name }}"
path: test_artifacts.zip
- name: Generate another token (previous one could have expired)
if: always()
id: generate_token_2
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.MAPLIBRE_NATIVE_BOT_APP_ID }}
private_key: ${{ secrets.MAPLIBRE_NATIVE_BOT_PRIVATE_KEY }}
- uses: LouisBrunner/[email protected]
if: always()
with:
token: ${{ steps.generate_token_2.outputs.token }}
check_id: ${{ steps.create_check.outputs.check_id }}
conclusion: ${{ job.status }}
sha: ${{ github.event.workflow_run.sha }}