-
Notifications
You must be signed in to change notification settings - Fork 1
218 lines (183 loc) · 6.87 KB
/
run-test.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
name: Tests
on:
pull_request:
push:
branches:
- "develop"
- "main"
schedule:
# Run twice a day the sanity check, at 9:13 and 21:13.
# You ask why 13? because probably less people schedule their tasks at exactly this time, so I
# guess CI is less occupied. And 13 is a lucky number ;)
- cron: "13 9,21 * * *"
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: read
actions: read
checks: write
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Prepare Android Environment
uses: ./.github/actions/prepare-android-env
- name: Run test
run: ./gradlew test
env:
LOUDIUS_CLIENT_SECRET: ${{ secrets.LOUDIUS_CLIENT_SECRET }}
LOUDIUS_CLIENT_ID: ${{ secrets.LOUDIUS_CLIENT_ID }}
LOUDIUS_GITHUB_USER_PASSWORD: ${{ secrets.LOUDIUS_GITHUB_USER_PASSWORD }}
LOUDIUS_GITHUB_USER_NAME: ${{ secrets.LOUDIUS_GITHUB_USER_NAME }}
LOUDIUS_GITHUB_USER_OTP_SECRET: ${{ secrets.LOUDIUS_GITHUB_USER_OTP_SECRET }}
- name: Upload tests results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: |
*/build/test-results/**
*/build/paparazzi/failures/**
retention-days: 5
android-tests:
name: Run UI tests on Firebase Test Lab
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: LFS-warning - Prevent large files that are not LFS tracked
uses: ppremk/[email protected]
- name: Prepare Android Environment
uses: ./.github/actions/prepare-android-env
- name: Assemble App Debug APK and Android Instrumentation Tests
run: ./gradlew assembleDebug assembleDebugAndroidTest
env:
LOUDIUS_CLIENT_SECRET: ${{ secrets.LOUDIUS_CLIENT_SECRET }}
LOUDIUS_CLIENT_ID: ${{ secrets.LOUDIUS_CLIENT_ID }}
LOUDIUS_GITHUB_USER_PASSWORD: ${{ secrets.LOUDIUS_GITHUB_USER_PASSWORD }}
LOUDIUS_GITHUB_USER_NAME: ${{ secrets.LOUDIUS_GITHUB_USER_NAME }}
LOUDIUS_GITHUB_USER_OTP_SECRET: ${{ secrets.LOUDIUS_GITHUB_USER_OTP_SECRET }}
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
install_components: "gsutil"
- name: Generate random directory
id: generate-dir
run: |-
echo "results_dir=$(date +%F_%T)-${RANDOM}" >> "$GITHUB_OUTPUT"
echo "bucket=test-lab-07qs3ns6c51bi-iazpthysivhkq" >> "$GITHUB_OUTPUT"
- name: Run tests on Firebase Test Lab
run: |-
gcloud firebase test android run \
--app="app/build/outputs/apk/debug/app-debug.apk" \
--test="app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk" \
--device="model=Pixel2.arm,version=33,locale=en,orientation=portrait" \
--type=instrumentation \
--use-orchestrator \
--test-runner-class="com.appunite.loudius.util.InstrumentationTestRunner" \
--timeout="20m" \
--results-dir="${{ steps.generate-dir.outputs.results_dir }}" \
--results-bucket="${{ steps.generate-dir.outputs.bucket }}" \
--environment-variables "clearPackageData=true,coverage=true,coverageFilePath=/sdcard/Download/"
- name: Download test results from Firebase Test Lab
if: always()
run: |-
mkdir "app/build/test-results"
gsutil cp -r "gs://${{ steps.generate-dir.outputs.bucket }}/${{ steps.generate-dir.outputs.results_dir }}/Pixel2.arm-33-en-portrait/test_result_1.xml" "app/build/test-results/results.xml"
- name: Upload tests results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: |
*/build/test-results/**
retention-days: 5
test-license-headers:
name: Ensure license headers are added
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Ensure license headers are added
run: python "build-tools/check-license-headers.py"
verify-formatting:
name: Verify ktlint formatting
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare Android Environment
uses: ./.github/actions/prepare-android-env
- name: Run test
run: ./gradlew ktlintCheck
test-results:
name: Upload tests results
runs-on: ubuntu-20.04
if: always()
needs:
- android-tests
- unit-tests
- verify-formatting
- test-license-headers
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
build-tools/
.github/
- name: Download tests results for both jobs
uses: actions/download-artifact@v3
with:
name: test-results
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.SERVICE_ACCOUNT }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Python dependencies
uses: py-actions/py-dependency-install@v4
with:
path: "build-tools/requirements.txt"
- name: Upload to Big Query
run: |-
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
python "build-tools/upload-junit-to-cloud.py" --url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" --final --glob "*/build/test-results/**/*.xml"
else
python "build-tools/upload-junit-to-cloud.py" --url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" --glob "*/build/test-results/**/*.xml"
fi
- name: Test Report
uses: dorny/test-reporter@v1
with:
name: Tests Results
path: "*/build/test-results/**/*.xml"
reporter: java-junit
fail-on-error: "false"
- name: Include Slack Notification
if: failure() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')
uses: ./.github/actions/slack-notification
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_GIT_REF: ${{ github.ref }}
SLACK_WORKFLOW: ${{ github.workflow }}