-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (100 loc) · 3.97 KB
/
e2e-android.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
# 🔗 Links:
# Source file: https://github.com/obytes/react-native-template-obytes/blob/master/.github/workflows/e2e-android.yml
# End-to-end testing: https://starter.obytes.com/testing/end-to-end-testing/
# ✍️ Description:
# This workflow is used to run end-to-end tests on Android using Maestro.
# As a first step, it will generate a test APK using the Gradle build and then upload it as an artifact.
# A new job will be started to run the tests using the test APK generated in the previous job.
# To test the app, we set up an Android emulator using the `reactivecircus/android-emulator-runner` action. This runner requires macOS as the operating system for the runner.
# This workflow will be triggered on pull requests (PRs) with the label "android-test-github" or can be manually triggered from the Actions tab.
#
# 🚨 GITHUB SECRETS REQUIRED: None
name: E2E Tests Android (Maestro + Github Action)
on:
workflow_dispatch:
pull_request:
branches: [main, master]
jobs:
generate-test-apk:
if: github.event_name != 'pull_request' || ( github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'android-test-github'))
name: Generate Test APK (Gradle)
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout project repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📦 Setup Node + PNPM + install deps
uses: ./.github/actions/setup-node-pnpm-install
- name: 📦 Set Up JDK + Generate Test APK
uses: ./.github/actions/setup-jdk-generate-apk
with:
APP_ENV: staging
- name: Upload Test APK
uses: actions/upload-artifact@v3
with:
name: test-apk
path: ./android/app/build/outputs/apk/release/app-release.apk
test-android:
name: Run Android E2E Tests (Maestro + Github Action)
needs: generate-test-apk
runs-on: macOS-latest
steps:
- name: 📦 Checkout project repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📦 Install Maestro
run: npm run install-maestro ## We use npm because we don't need to install deps again
- name: Download Test APK
uses: actions/download-artifact@v3
with:
name: test-apk
path: ${{ github.workspace }}
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-cache
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
cores: 2
ram-size: 4096M
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."
- name: Run tests with Maestro
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
cores: 2
ram-size: 4096M
profile: Nexus 6
script: |
adb install "${{ github.workspace }}/app-release.apk"
$HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.obytes.staging --format junit
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-test-logs
path: ~/.maestro/tests/**/*
- name: Store tests result
uses: actions/upload-artifact@v3
with:
name: e2e_android_report
path: |
report.xml