-
Notifications
You must be signed in to change notification settings - Fork 701
211 lines (177 loc) · 6.43 KB
/
master_dev_ci.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
name: Workflow for master/development branches
on:
pull_request:
push:
branches:
- 'development'
- 'master'
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v4
- name: Cache Gradle and build outputs
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
build
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
checks:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
check: [ build_logic, spotless, detekt ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Run ${{ matrix.check }}
id: run_check
run: |
if [ "${{ matrix.check }}" = "build_logic" ]; then
./gradlew check -p build-logic
elif [ "${{ matrix.check }}" = "spotless" ]; then
./gradlew spotlessCheck --no-configuration-cache --no-daemon
elif [ "${{ matrix.check }}" = "detekt" ]; then
./gradlew detekt
fi
- name: Upload Detekt Reports
if: ${{ matrix.check == 'detekt' && steps.run_check.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: detekt-reports
path: |
**/build/reports/detekt/detekt.md
dependency_guard:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Check Dependency Guard
id: dependencyguard_verify
continue-on-error: true
run: ./gradlew dependencyGuard
- name: Prevent updating Dependency Guard baselines if this is a fork
id: checkfork_dependencyguard
if: steps.dependencyguard_verify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Dependency Guard failed, please update baselines with: ./gradlew dependencyGuardBaseline" && exit 1
# Runs if previous job failed
- name: Generate new Dependency Guard baselines if verification failed and it's a PR
id: dependencyguard_baseline
if: steps.dependencyguard_verify.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew dependencyGuardBaseline
- name: Push new Dependency Guard baselines if available
uses: stefanzweifel/git-auto-commit-action@v5
if: steps.dependencyguard_baseline.outcome == 'success'
with:
file_pattern: '**/dependencies/*.txt'
disable_globbing: true
commit_message: "🤖 Updates baselines for Dependency Guard"
tests_and_lint:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Run tests
run: |
./gradlew testDebug :lint:test :androidApp:lintRelease :lint:lint
- name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-and-lint-reports
path: |
**/build/reports/lint-results-*.html
**/build/test-results/test*UnitTest/**.xml
# Add `createDebugUnitTestCoverageReport` if we ever add JVM tests for prod
- name: Generate coverage reports for Debug variants (only API 30)
run: ./gradlew createDebugCombinedCoverageReport
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.api-level }}
path: '**/build/reports/androidTests'
- name: Display local test coverage (only API 30)
id: jacoco
uses: madrapps/[email protected]
with:
title: Combined test coverage report
min-coverage-overall: 40
min-coverage-changed-files: 60
paths: |
${{ github.workspace }}/**/build/reports/jacoco/**/*Report.xml
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload local coverage reports (XML + HTML) (only API 30)
uses: actions/upload-artifact@v4
with:
name: coverage-reports
if-no-files-found: error
compression-level: 1
overwrite: false
path: '**/build/reports/jacoco/'
build:
needs: [ checks, dependency_guard, tests_and_lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Build APKs
run: ./gradlew :androidApp:assembleDebug
- name: Check badging
id: badging_verify
continue-on-error: true
run: ./gradlew :androidApp:checkReleaseBadging
- name: Prevent updating Dependency Guard baselines if this is a fork
id: checkfork_badging
if: steps.badging_verify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Dependency Guard failed, please update badging with: ./gradlew updateReleaseBadging" && exit 1
# Runs if previous job failed
- name: Generate new Dependency Guard baselines if verification failed and it's a PR
id: generate_badging
if: steps.checkfork_badging.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew updateReleaseBadging
- name: Push new Dependency Guard baselines if available
uses: stefanzweifel/git-auto-commit-action@v5
if: steps.generate_badging.outcome == 'success'
with:
file_pattern: 'androidApp/release-badging.txt'
disable_globbing: true
commit_message: "🤖 Updates release badging"
- name: Upload APKs
uses: actions/upload-artifact@v4
with:
name: APKs
path: '**/build/outputs/apk/**/*.apk'