Skip to content

Commit cfe9f23

Browse files
committed
fix: simplify android workflow with composite action
1 parent 27d25bd commit cfe9f23

File tree

2 files changed

+101
-43
lines changed

2 files changed

+101
-43
lines changed

.github/workflows/android-regression.yml

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ jobs:
8181
runs-on: ${{ github.event.inputs.RUNNER == 'mac' && fromJSON('["self-hosted", "macOS"]') || fromJSON('["self-hosted", "linux", "X64", "qa-android"]') }}
8282
env:
8383
PLATFORM: 'android'
84-
EMULATOR_COUNT: ${{ github.event.inputs.RUNNER == 'mac' && '6' || '4' }}
84+
EMULATOR_COUNT: ${{ github.event.inputs.RUNNER == 'mac' && '6' || '4' }} # macOS runner can support 6 emulators, linux runner only 4
85+
WORKERS_1_DEVICE: ${{ github.event.inputs.RUNNER == 'mac' && '6' || '4' }} # 6 or 4 workers, 1 device each
86+
WORKERS_2_DEVICE: ${{ github.event.inputs.RUNNER == 'mac' && '3' || '2' }} # 3 or 2 workers, 2 devices each
87+
WORKERS_3_DEVICE: ${{ github.event.inputs.RUNNER == 'mac' && '2' || '1' }} # 2 or 1 worker(s), 3 devices each
8588
APK_URL: ${{ github.event.inputs.APK_URL }}
8689
BUILD_NUMBER: ${{ github.event.inputs.BUILD_NUMBER }}
8790
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -202,47 +205,42 @@ jobs:
202205
PLATFORM: ${{ env.PLATFORM }}
203206
RISK: ${{ github.event.inputs.RISK }}
204207

205-
- name: Run the 1-devices tests ​​with 4 workers
206-
continue-on-error: true
207-
id: devices-1-test-run
208-
env:
209-
PLAYWRIGHT_WORKERS_COUNT: ${{ env.EMULATOR_COUNT }} # 6 on mac, 4 on linux
210-
DEVICES_PER_TEST_COUNT: 1
211-
run: |
212-
pwd
213-
TESTING=${{ github.event.inputs.HIDE_WEBDRIVER_LOGS }} npx playwright test --grep "(?=.*@${PLATFORM})(?=.*@${DEVICES_PER_TEST_COUNT}-devices)(?=.*@${{ github.event.inputs.RISK }})" #Note: this has to be double quotes
214-
215-
- name: Upload results of this run
216-
uses: ./github/actions/upload-test-results
208+
- name: Run 1-device tests
209+
uses: ./github/actions/run-playwright-tests
217210
with:
218211
PLATFORM: ${{ env.PLATFORM }}
212+
RISK: ${{ github.event.inputs.RISK }}
213+
WORKERS_COUNT: ${{ env.WORKERS_1_DEVICE }}
214+
DEVICES_PER_TEST: '1'
215+
TEST_NAME: '1-device'
216+
GREP_INCLUDE: '@1-devices'
217+
HIDE_WEBDRIVER_LOGS: ${{ env.HIDE_WEBDRIVER_LOGS }}
219218
UPLOAD_IDENTIFIER: 'devices-1-test-run'
220219

221-
- name: Run the 2-devices tests ​​with 2 workers
222-
continue-on-error: true
223-
id: devices-2-test-run
224-
env:
225-
PLAYWRIGHT_WORKERS_COUNT: ${{ github.event.inputs.RUNNER == 'mac' && '3' || '2' }}
226-
DEVICES_PER_TEST_COUNT: 2
227-
run: |
228-
pwd
229-
_TESTING=${{ github.event.inputs.HIDE_WEBDRIVER_LOGS }} npx playwright test --grep "(?=.*@${PLATFORM})(?=.*@${DEVICES_PER_TEST_COUNT}-devices)(?=.*@${{ github.event.inputs.RISK }})" #Note: this has to be double quotes
230-
231-
- name: Upload results of this run
232-
uses: ./github/actions/upload-test-results
220+
- name: Run 2-device tests
221+
uses: ./github/actions/run-playwright-tests
233222
with:
234223
PLATFORM: ${{ env.PLATFORM }}
224+
RISK: ${{ github.event.inputs.RISK }}
225+
WORKERS_COUNT: ${{ env.WORKERS_2_DEVICE }}
226+
DEVICES_PER_TEST: '2'
227+
TEST_NAME: '2-device'
228+
GREP_INCLUDE: '@2-devices'
229+
HIDE_WEBDRIVER_LOGS: ${{ env.HIDE_WEBDRIVER_LOGS }}
235230
UPLOAD_IDENTIFIER: 'devices-2-test-run'
236231

237-
- name: Run the tests ​​other tests with 1 worker
238-
continue-on-error: true
239-
id: other-devices-test-run
240-
env:
241-
PLAYWRIGHT_WORKERS_COUNT: ${{ github.event.inputs.RUNNER == 'mac' && '2' || '1' }}
242-
DEVICES_PER_TEST_COUNT: 3
243-
run: |
244-
pwd
245-
_TESTING=${{ github.event.inputs.HIDE_WEBDRIVER_LOGS }} npx playwright test --grep "(?=.*@${PLATFORM})(?=.*@${{ github.event.inputs.RISK }})" --grep-invert "@1-devices|@2-devices" #Note: this has to be double quotes
232+
- name: Run 3-device tests
233+
uses: ./github/actions/run-playwright-tests
234+
with:
235+
PLATFORM: ${{ env.PLATFORM }}
236+
RISK: ${{ github.event.inputs.RISK }}
237+
WORKERS_COUNT: ${{ env.WORKERS_3_DEVICE }}
238+
DEVICES_PER_TEST: '3'
239+
TEST_NAME: '3-device'
240+
GREP_INCLUDE: '@3-devices'
241+
HIDE_WEBDRIVER_LOGS: ${{ env.HIDE_WEBDRIVER_LOGS }}
242+
UPLOAD_IDENTIFIER: 'devices-3-test-run'
243+
246244

247245
- name: Generate and publish test report
248246
uses: ./github/actions/generate-publish-test-report
@@ -256,21 +254,12 @@ jobs:
256254
GITHUB_RUN_NUMBER: ${{ github.run_number }}
257255
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
258256

259-
- name: Upload results of this run
260-
uses: ./github/actions/upload-test-results
261-
with:
262-
PLATFORM: ${{ env.PLATFORM }}
263-
UPLOAD_IDENTIFIER: 'devices-other-test-run'
264-
265257
- name: Upload csv of this whole run
266258
uses: ./github/actions/upload-csv-test-results
267259
if: always()
268260
with:
269261
PLATFORM: ${{ env.PLATFORM }}
270262

271-
- name: Check if any tests failed
272-
if: steps.devices-1-test-run != 'success' || steps.devices-2-test-run != 'success' || steps.other-devices-test-run.outcome != 'success'
273-
run: echo 'Some test failed, see above'; exit 1
274263

275264
- name: Stop emulators
276265
if: always()
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: 'Run Android Tests'
2+
description: 'Run Android tests with specified configuration'
3+
4+
inputs:
5+
PLATFORM:
6+
description: 'Platform to test (android/ios)'
7+
required: true
8+
RISK:
9+
description: 'Risk level to test'
10+
required: true
11+
WORKERS_COUNT:
12+
description: 'Number of Playwright workers'
13+
required: true
14+
DEVICES_PER_TEST:
15+
description: 'Number of devices per test'
16+
required: true
17+
TEST_NAME:
18+
description: 'Name for this test run (for logging)'
19+
required: true
20+
GREP_INCLUDE:
21+
description: 'Pattern to include in grep'
22+
required: false
23+
default: ''
24+
HIDE_WEBDRIVER_LOGS:
25+
description: 'Hide webdriver logs (1 to hide, 0 to show)'
26+
required: true
27+
UPLOAD_IDENTIFIER:
28+
description: 'Unique identifier for uploading results'
29+
required: true
30+
31+
runs:
32+
using: 'composite'
33+
steps:
34+
- name: Run ${{ inputs.TEST_NAME }} tests
35+
id: run-tests
36+
continue-on-error: true
37+
shell: bash
38+
env:
39+
PLAYWRIGHT_WORKERS_COUNT: ${{ inputs.WORKERS_COUNT }}
40+
DEVICES_PER_TEST_COUNT: ${{ inputs.DEVICES_PER_TEST }}
41+
run: |
42+
echo "🚀 Running ${{ inputs.TEST_NAME }} tests"
43+
echo " Workers: ${{ inputs.WORKERS_COUNT }}"
44+
echo " Devices per test: ${{ inputs.DEVICES_PER_TEST }}"
45+
echo " Total emulator usage: $((${{ inputs.WORKERS_COUNT }} * ${{ inputs.DEVICES_PER_TEST }}))"
46+
47+
# Build the base grep pattern
48+
base_pattern="(?=.*@${{ inputs.PLATFORM }})"
49+
50+
# Add risk filter if specified
51+
if [[ "${{ inputs.RISK }}" != "" ]]; then
52+
base_pattern="${base_pattern}(?=.*@${{ inputs.RISK }})"
53+
fi
54+
55+
# Add include pattern if specified
56+
if [[ "${{ inputs.GREP_INCLUDE }}" != "" ]]; then
57+
base_pattern="${base_pattern}(?=.*${{ inputs.GREP_INCLUDE }})"
58+
fi
59+
60+
# Run the tests
61+
_TESTING=${{ inputs.HIDE_WEBDRIVER_LOGS }} npx playwright test \
62+
--grep "$base_pattern"
63+
fi
64+
65+
- name: Upload ${{ inputs.TEST_NAME }} results
66+
uses: ./github/actions/upload-test-results
67+
with:
68+
PLATFORM: ${{ inputs.PLATFORM }}
69+
UPLOAD_IDENTIFIER: ${{ inputs.UPLOAD_IDENTIFIER }}

0 commit comments

Comments
 (0)