-
Notifications
You must be signed in to change notification settings - Fork 47
238 lines (205 loc) · 7.33 KB
/
validate.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
# This workflow is triggered on push events to the repository
# It runs the following jobs:
# - build: Ensure the code builds
# - unit-test: Run unit tests
# - instrumented-test: Run instrumented tests
# - assemble-archive: Archive APKs
# - distribute: Upload artifact to Firebase App Distribution
name: Validate
on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 2 * * */2"
jobs:
build:
name: Ensure the code builds
runs-on: ubuntu-latest
strategy:
matrix:
version:
- "OoniStableFullRelease"
- "OoniStableFdroidRelease"
- "DwStableFullRelease"
- "DwStableFdroidRelease"
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v4
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Build `StableFullRelease` and `StableFdroidRelease` variants
run: ./gradlew build${{ matrix.version }} && ./gradlew clean
unit-test:
name: Run unit tests
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v4
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Run unit tests
run: ./gradlew testOoniStableFullRelease
- name: Uploads test reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-report
path: app/build/test-results/testOoniStableFullReleaseUnitTest
instrumented-test:
name: Run instrumented tests
runs-on: ubuntu-latest
needs: [ build ]
strategy:
matrix:
api-level: [25, 29] # Bug in API 21-24
target: [default, google_apis]
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v4
- 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
- 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-${{ matrix.api-level }}-${{ matrix.target }}
- 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: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
profile: Nexus 6
ram-size: 4096M
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."
- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
profile: Nexus 6
ram-size: 4096M
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew connectedOoniStableFullDebugAndroidTest
- name: uploads test reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: emulator-test-reports
path: app/build/reports/androidTests/connected/debug/flavors/ooniStableFull/
assemble-archive:
name: Archive APKs
runs-on: ubuntu-latest
strategy:
matrix:
version:
- "OoniStableFullDebug"
- "OoniStableFdroidDebug"
- "OoniDevFullDebug"
- "OoniDevFullDebugAndroidTest"
- "DwStableFullDebug"
- "DwStableFdroidDebug"
- "DwDevFullDebug"
needs: [ build ]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Get issue number
uses: actions/github-script@v7
id: get_issue_number
with:
script: |
if (context.issue.number) {
// Return issue number if present
return context.issue.number;
} else {
// Otherwise return issue number from commit
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0].number;
}
result-encoding: string
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Assemble APKs
if: success() && steps.get_issue_number.outputs.result
run: ./gradlew assemble${{ matrix.version }}
env:
PR_NUMBER: ${{ steps.get_issue_number.outputs.result }}
- name: uploads dev apk
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.version }}Apk
path: |
app/build/outputs/apk/ooniStableFull/debug/app-ooni-stable-full-debug.apk
app/build/outputs/apk/ooniStableFdroid/debug/app-ooni-stable-fdroid-debug.apk
app/build/outputs/apk/ooniDevFull/debug/app-ooni-dev-full-debug.apk
app/build/outputs/apk/androidTest/ooniDevFull/debug/app-ooni-dev-full-debug-androidTest.apk
app/build/outputs/apk/dwStableFull/debug/app-dw-stable-full-debug.apk
app/build/outputs/apk/dwStableFdroid/debug/app-dw-stable-fdroid-debug.apk
app/build/outputs/apk/dwDevFull/debug/app-dw-dev-full-debug.apk
distribute:
name: Upload artifact to Firebase App Distribution
runs-on: ubuntu-latest
needs: [ assemble-archive ]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Download app APK
uses: actions/download-artifact@v4
with:
name: OoniDevFullDebugApk
- name: Upload artifact to Firebase App Distribution
id: uploadArtifact
env:
INPUT_APPID: ${{secrets.FIREBASE_APP_ID}}
INPUT_SERVICECREDENTIALSFILECONTENT: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
GOOGLE_APPLICATION_CREDENTIALS: service_credentials_content.json
INPUT_GROUPS: testers
INPUT_FILE: ooniDevFull/debug/app-ooni-dev-full-debug.apk
run: |
cat <<< "${INPUT_SERVICECREDENTIALSFILECONTENT}" > service_credentials_content.json
sudo npm install -g firebase-tools
firebase appdistribution:distribute "$INPUT_FILE" --app "$INPUT_APPID" --groups "$INPUT_GROUPS" --testers "$INPUT_TESTERS" --release-notes "$(git log -1 --pretty=short)"