-
Notifications
You must be signed in to change notification settings - Fork 9
317 lines (301 loc) · 10.9 KB
/
integration-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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
on:
release:
types: [created]
push:
branches: [ master ]
pull_request_target:
branches: [ master ]
env:
python2_bundle_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/sample_env_python2_wh.zip
python3_bundle_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/sample_env_python3.zip
test_spec_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/test_spec.yaml
test_app_url: https://github.com/aardsoft/aws-devicefarm-sample-data/releases/download/0.3/fi.aardsoft.devicefarmsample-debug.apk
name: Perform basic testing against a devicefarm
jobs:
package:
name: Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Run package
run: npm run package
- name: Validate there are no uncommitted changes
run: |
changedFiles=$(git --no-pager diff -w)
if [ "$changedFiles" ]; then
git --no-pager diff -w
exit 1
fi
shell: bash
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: pull-request
needs:
- package
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install additional packages
run: |
if [ `id -u` -eq 0 ]; then
apt-get update
apt-get install -y zip unzip
else
sudo apt-get update
sudo apt-get install -y zip unzip
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Get project
uses: ./get-project
id: get-project
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
- name: List device pools
uses: ./list-device-pools
id: list-device-pools
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
- name: Get device pool details
uses: ./get-device-pool
id: get-device-pool
with:
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
- name: List uploads
uses: ./list-uploads
id: list-uploads
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
# this fails with too many artifacts due to missing cleanup handlers. Only
# nice to have anyway, so ignore errors.
- name: Print uploads
continue-on-error: true
uses: ./pretty-print
with:
input: ${{ steps.list-uploads.outputs.data }}
- name: Create upload
uses: ./create-upload
id: create-upload-1
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
name: test-via-action.yaml
type: APPIUM_PYTHON_TEST_SPEC
- name: Get upload details
uses: ./get-upload
id: get-upload
with:
resource_arn: ${{ steps.create-upload-1.outputs.arn }}
- name: Create upload 2
uses: ./create-upload
id: create-upload-2
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
name: test-via-action.yaml
type: APPIUM_PYTHON_TEST_SPEC
- name: Delete previously created upload
uses: ./delete-upload
with:
resource_arn: ${{ steps.create-upload-1.outputs.arn }}
- name: Delete previously created upload
uses: ./delete-upload
with:
resource_arn: ${{ steps.create-upload-2.outputs.arn }}
- name: Upload remote test specification
uses: ./upload-file
id: test-spec
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
file: ${{ env.test_spec_url }}
remote_src: true
type: APPIUM_PYTHON_TEST_SPEC
- name: Upload remote test bundle
uses: ./upload-file
id: test-bundle
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
file: ${{ env.python3_bundle_url }}
remote_src: true
type: APPIUM_PYTHON_TEST_PACKAGE
- name: Upload remote app
uses: ./upload-file
id: test-app
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
file: ${{ env.test_app_url }}
remote_src: true
type: ANDROID_APP
- name: Create incomplete upload
uses: ./create-upload
id: incomplete-upload
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
name: incomplete-app.apk
type: ANDROID_APP
# TODO: this should fail - check if we can abort if it passes
- name: Schedule test run with incomplete data
uses: ./test-application
continue-on-error: true
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_arn: ${{ steps.incomplete-upload.outputs.arn }}
test_type: APPIUM_PYTHON
test_package_file: ${{ env.python3_bundle_url }}
test_package_type: APPIUM_PYTHON_TEST_PACKAGE
test_spec_file: ${{ env.test_spec_url }}
test_spec_type: APPIUM_PYTHON_TEST_SPEC
remote_src: true
# this also is expected to fail due to AWS still defaulting to python2.7,
# while the test package requires python3
- name: Schedule test run without custom test spec
uses: ./test-application
continue-on-error: true
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_arn: ${{ steps.test-app.outputs.arn }}
test_type: APPIUM_PYTHON
test_package_file: ${{ env.python3_bundle_url }}
test_package_type: APPIUM_PYTHON_TEST_PACKAGE
remote_src: true
# this requires a bundle with wheelhouse. It fails without getting real
# appium tests.
- name: Schedule python2 test run without custom test spec
continue-on-error: true
uses: ./test-application
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_arn: ${{ steps.test-app.outputs.arn }}
test_type: APPIUM_PYTHON
test_package_file: ${{ env.python_2_bundle_url }}
test_package_type: APPIUM_PYTHON_TEST_PACKAGE
remote_src: true
# this should fail due to the short timeout
- name: Schedule test run for previous uploads, short timeout
uses: ./test-application
continue-on-error: true
id: schedule-run-timeout
with:
name: run_with_uploaded_files_and_timeout
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_arn: ${{ steps.test-app.outputs.arn }}
test_type: APPIUM_PYTHON
test_package_arn: ${{ steps.test-bundle.outputs.arn }}
test_spec_arn: ${{ steps.test-spec.outputs.arn }}
timeout: 30
- name: Schedule test run with inline test spec
uses: ./test-application
with:
name: inline-spec
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_arn: ${{ steps.test-app.outputs.arn }}
test_type: APPIUM_PYTHON
test_package_file: ${{ env.python3_bundle_url }}
test_package_type: APPIUM_PYTHON_TEST_PACKAGE
test_spec_file: inline_test_spec.yaml
test_spec_type: APPIUM_PYTHON_TEST_SPEC
test_spec: |
version: 0.1
phases:
install:
commands:
- export PYTHON_VERSION=3
pre_test:
commands:
- adb -s $DEVICEFARM_DEVICE_UDID shell pm grant fi.aardsoft.devicefarmsample android.permission.READ_EXTERNAL_STORAGE
- adb -s $DEVICEFARM_DEVICE_UDID shell pm grant fi.aardsoft.devicefarmsample android.permission.WRITE_EXTERNAL_STORAGE
test:
commands:
- adb -s $DEVICEFARM_DEVICE_UDID shell am instrument -w -r -e foo bar -e bar baz fi.aardsoft.devicefarmsample
post_test:
commands:
- adb -s $DEVICEFARM_DEVICE_UDID pull /storage/emulated/0/Android/data/fi.aardsoft.devicefarmsample/files/output.txt
- mv output.txt $DEVICEFARM_LOG_DIR/test-output.txt
artifacts:
- $DEVICEFARM_LOG_DIR
remote_src: false
- name: Schedule test run via API (non-blocking)
uses: ./schedule-run
with:
name: schedule_run
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_arn: ${{ steps.test-app.outputs.arn }}
test_type: APPIUM_PYTHON
test_package_arn: ${{ steps.test-bundle.outputs.arn }}
test_spec_arn: ${{ steps.test-spec.outputs.arn }}
- name: Schedule test run for previous uploads
uses: ./test-application
id: schedule-run
with:
name: run_with_uploaded_files
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_arn: ${{ steps.test-app.outputs.arn }}
test_type: APPIUM_PYTHON
test_package_arn: ${{ steps.test-bundle.outputs.arn }}
test_spec_arn: ${{ steps.test-spec.outputs.arn }}
- name: List runs
uses: ./list-runs
with:
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
- name: Get run details
uses: ./get-run
with:
run_arn: ${{ steps.schedule-run.outputs.arn }}
- name: List file artifacts for run
uses: ./list-artifacts
with:
resource_arn: ${{ steps.schedule-run.outputs.arn }}
type: FILE
- name: Download artifacts for run
uses: ./download-artifacts
with:
run_arn: ${{ steps.schedule-run.outputs.arn }}
file_artifacts: |
Test spec file.yml
Invalid Artifact Logging Warning.txt
Customer Artifacts.zip
- name: Print and clean downloaded artifacts
run: |
cat 'Test spec file.yml'
unzip -l 'Customer Artifacts.zip'
rm -f 'Test spec file.yml' 'Customer Artifacts.zip'
- name: Schedule test run with uploads
uses: ./test-application
with:
name: run_with_uploads
project_arn: ${{ secrets.AWS_PROJECT_ARN }}
device_pool_arn: ${{ secrets.AWS_DEVICE_POOL_ARN }}
app_file: ${{ env.test_app_url }}
app_type: ANDROID_APP
test_type: APPIUM_PYTHON
test_package_file: ${{ env.python3_bundle_url }}
test_package_type: APPIUM_PYTHON_TEST_PACKAGE
test_spec_file: ${{ env.test_spec_url }}
test_spec_type: APPIUM_PYTHON_TEST_SPEC
remote_src: true
file_artifacts: |
Test spec file.yml
Invalid Artifact Logging Warning.txt
Customer Artifacts.zip
- name: Print and clean downloaded artifacts
run: |
cat 'Test spec file.yml'
unzip -l 'Customer Artifacts.zip'
rm -f 'Test spec file.yml' 'Customer Artifacts.zip'