-
Notifications
You must be signed in to change notification settings - Fork 25
196 lines (175 loc) · 7.78 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
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
name: e2e-Android
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
testingbuild:
runs-on: ubuntu-latest
# Kill the task if not finished after 60 minutes
timeout-minutes: 90
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Dependencies
run: npm install
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Build for Detox
run: npm run e2e:build:android
checksecret:
name: check for oauth client
runs-on: ubuntu-latest
outputs:
is_SECRETS_PRESENT_set: ${{ steps.checksecret_job.outputs.is_SECRETS_PRESENT_set }}
steps:
- name: Check whether unity activation requests should be done
id: checksecret_job
env:
SECRETS_PRESENT: ${{ secrets.OAUTH_CLIENT_SECRET }}
run: |
echo "is_SECRETS_PRESENT_set: ${{ env.SECRETS_PRESENT != '' }}"
echo "::set-output name=is_SECRETS_PRESENT_set::${{ env.SECRETS_PRESENT != '' }}"
test:
needs: checksecret
if: needs.checksecret.outputs.is_SECRETS_PRESENT_set == 'true'
runs-on: ubuntu-latest
# Kill the task if not finished after 60 minutes
timeout-minutes: 90
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version: 18
# https://github.com/ReactiveCircus/android-emulator-runner?tab=readme-ov-file#running-hardware-accelerated-emulators-on-linux-runners
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# Setup Java 17 (required by >RN0.73) for the build step
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Cache node modules
uses: actions/cache@v4
id: cache
with:
path: node_modules
key: node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Rebuild detox from cache
if: steps.cache.outputs.cache-hit == 'true'
# Currently, (Detox 20) those two commands are macOS only
run: npx detox clean-framework-cache && npx detox build-framework-cache
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd
- 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: 34
target: aosp_atd
arch: x86_64
profile: Nexus 5X
avd-name: Pixel_5_API_34_AOSP
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
# Generate the secret files needed for a release build
- name: Create .env file
env:
OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
E2E_TEST_USERNAME: ${{ secrets.E2E_TEST_USERNAME }}
E2E_TEST_PASSWORD: ${{ secrets.E2E_TEST_PASSWORD }}
JWT_ANONYMOUS_API_SECRET: ${{ secrets.JWT_ANONYMOUS_API_SECRET }}
GMAPS_API_KEY: ${{ secrets.GMAPS_API_KEY }}
run: printf 'API_URL=https://stagingapi.inaturalist.org/v2\nOAUTH_API_URL=https://staging.inaturalist.org\nJWT_ANONYMOUS_API_SECRET=%s\nOAUTH_CLIENT_ID=%s\nOAUTH_CLIENT_SECRET=%s\nE2E_TEST_USERNAME=%s\nE2E_TEST_PASSWORD=%s\nGMAPS_API_KEY=%s\nANDROID_MODEL_FILE_NAME=small_inception_tf1.tflite\nANDROID_TAXONOMY_FILE_NAME=small_export_tax.csv\nIOS_MODEL_FILE_NAME=small_inception_tf1.mlmodel\nIOS_TAXONOMY_FILE_NAME=small_export_tax.json\n' "$JWT_ANONYMOUS_API_SECRET" "$OAUTH_CLIENT_ID" "$OAUTH_CLIENT_SECRET" "$E2E_TEST_USERNAME" "$E2E_TEST_PASSWORD" "$GMAPS_API_KEY" > .env
- name: Create keystore.properties file
env:
ANDROID_KEY_STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
ANDROID_ALIAS: ${{ secrets.ANDROID_ALIAS }}
run: printf 'storePassword=%s\nkeyPassword=%s\nkeyAlias=%s\nstoreFile=release.keystore' "$ANDROID_KEY_STORE_PASSWORD" "$ANDROID_KEY_PASSWORD" "$ANDROID_ALIAS" > android/keystore.properties
- name: Generate release keystore
env:
ANDROID_ALIAS: ${{ secrets.ANDROID_ALIAS }}
ANDROID_KEY_STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
run: |
keytool -genkeypair -v -noprompt -storetype PKCS12 -keystore release.keystore -alias "$ANDROID_ALIAS" -keyalg RSA -keysize 2048 -validity 10000 -storepass "$ANDROID_KEY_STORE_PASSWORD" -keypass "$ANDROID_KEY_PASSWORD" -dname "CN=mqttserver.ibm.com, OU=ID, O=IBM, L=Hursley, S=Hants, C=GB"
- name: Move keystore
run: mv release.keystore android/app/release.keystore
# Download the example model otherwise an error alert will be shown on app start, requires .env
- name: Download a fake cv model and taxonomy file into the assets folder
run: npm run add-github-actions-test-model
- name: Ensure servers are running
run: |
# is rails running?
curl -I --fail "https://staging.inaturalist.org/ping"
# is node running & is ES working?
curl -I --fail "https://stagingapi.inaturalist.org/v2/taxa"
# This is by far the longest step in this job, currently we are building the apk everytime, maybe there should be a more specific trigger for the entire job
- name: Build for Detox
run: npm run e2e:build:android
- name: Start Android Emulator and run Detox tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: aosp_atd
arch: x86_64
profile: Nexus 5X
avd-name: Pixel_5_API_34_AOSP
emulator-options: -no-window -no-snapshot-save -noaudio -no-boot-anim -no-audio -timezone America/Los_Angeles
# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot-save -noaudio -no-boot-anim -no-audio -timezone America/Los_Angeles
script: |
$ANDROID_HOME/emulator/emulator -list-avds
$ANDROID_HOME/platform-tools/adb devices
$ANDROID_HOME/platform-tools/adb emu geo fix -121.45356 46.51119 4392 12
npm run e2e:test:android -- --take-screenshots failing --record-videos failing -l debug
# The artifacts for the failing tests are available for download on github.com on the page of the individual actions run
- name: Store Detox artifacts on test failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: detox-artifacts
path: artifacts
notify:
name: Notify Slack
needs: test
if: ${{ success() || failure() }}
runs-on: ubuntu-latest
steps:
- uses: iRoachie/slack-github-actions@v2.3.0
if: env.SLACK_WEBHOOK_URL != null
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BUILDS_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}