-
Notifications
You must be signed in to change notification settings - Fork 46
199 lines (172 loc) · 5.84 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
# 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: 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: 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: [ 29 ]
target: [ 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: 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
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@v6
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: 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
uses: wzieba/Firebase-Distribution-Github-Action@v1.7.0
id: uploadArtifact
with:
appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: ooniDevFull/debug/app-ooni-dev-full-debug.apk
- name: Write Summary
run: |
echo "View this release in the Firebase console: ${{ steps.uploadArtifact.outputs.FIREBASE_CONSOLE_URI }}" >> $GITHUB_STEP_SUMMARY