-
Notifications
You must be signed in to change notification settings - Fork 16
204 lines (174 loc) · 8.5 KB
/
ci.yaml
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
name: CI
on:
pull_request:
branches: [ master ]
# Allows for running this workflow manually from the Actions tab
workflow_dispatch:
jobs:
analyze:
name: Analyze
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout the code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
java-version: '17'
distribution: 'corretto'
cache: gradle
- name: Clear gradle cache
run: |
mv ~/.gradle ~/.invalid || true
- name: Cache dependencies
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ env.CACHE_VERSION }}-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }}
- name: Check Gradle wrapper
uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5
- name: Check code style
run: ./gradlew ktlintCheck
- name: Check code quality
run: ./gradlew detekt
# TODO: Investigate why this is not working and encountering the following:
# `snyk` requires an authenticated account. Please run `snyk auth` and try again
# - name: Check dependencies with snyk
# uses: snyk/actions/gradle-jdk@dc22abdbe8ec00e2a925256fef96f319ca5510ce
# continue-on-error: true # To make sure that SARIF upload gets called
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# with:
# args: --sarif-file-output=snyk.sarif
#
# - name: Upload snyk result to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@81b419c908d540ec4c7da9bfb4b5d941fca8f624
# with:
# sarif_file: snyk.sarif
- name: Upload reports
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: analyze-reports
path: app/build/reports
if: always()
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
timeout-minutes: 10
needs: analyze
steps:
- name: Checkout the code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
java-version: '17'
distribution: 'corretto'
cache: gradle
- name: Clear gradle cache
run: |
mv ~/.gradle ~/.invalid || true
- name: Cache dependencies
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ env.CACHE_VERSION }}-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }}
- name: Check Gradle wrapper
uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5
# TODO: Add code coverage metrics
# See https://about.codecov.io/blog/code-coverage-for-android-development-using-kotlin-jacoco-github-actions-and-codecov/
- name: Run unit tests
run: ./gradlew testDebugUnitTest
- name: Upload reports
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: unit-tests-reports
path: app/build/reports
if: always()
instrumentation-tests:
name: Instrumentation tests on API ${{ matrix.api-level }}
runs-on: ubuntu-latest
timeout-minutes: 15
needs: unit-tests
strategy:
fail-fast: false
matrix:
api-level: [ 26, 27, 28, 29, 30, 31, 32, 33, 34 ]
steps:
- name: Checkout the code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
java-version: '17'
distribution: 'corretto'
cache: gradle
- name: Clear gradle cache
run: |
mv ~/.gradle ~/.invalid || true
- name: Cache dependencies
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ env.CACHE_VERSION }}-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }}
- name: Check Gradle wrapper
uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5
- 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: Create directory for AVD
run: mkdir -p ~/.android/avd
- name: Get AVD info
uses: ./.github/actions/get-avd-info
id: avd-info
with:
api-level: ${{ matrix.api-level }}
# Retrieve the cached emulator snapshot
- name: Retrieve cached emulator snapshot
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: ${{ runner.os }}-avd-${{ env.CACHE_VERSION }}-${{ steps.avd-info.outputs.arch }}-${{ steps.avd-info.outputs.target }}-${{ matrix.api-level }}
# Create a new emulator snapshot if it isn't present in the cache
- name: Create AVD snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2
with:
api-level: ${{ matrix.api-level }}
target: ${{ steps.avd-info.outputs.target }}
arch: ${{ steps.avd-info.outputs.arch }}
disable-animations: true
force-avd-creation: false
ram-size: 4096M
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot"
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d
with:
api-level: ${{ matrix.api-level }}
target: ${{ steps.avd-info.outputs.target }}
arch: ${{ steps.avd-info.outputs.arch }}
disable-animations: true
force-avd-creation: false
ram-size: 4096M
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: ./gradlew connectedCheck && killall -INT crashpad_handler || true
- name: Upload reports
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: instrumentation-tests-reports-api${{ matrix.api-level }}
path: app/build/reports
if: always()