-
Notifications
You must be signed in to change notification settings - Fork 83
298 lines (249 loc) · 9.42 KB
/
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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
name : CI
on :
push :
branches :
- main
tags-ignore :
- '**'
pull_request :
jobs :
test-ubuntu :
runs-on : ubuntu-latest
timeout-minutes : 25
strategy :
fail-fast : false
matrix :
kotlin-version : [ 1.8.22, 1.9.10 ]
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : Test on Ubuntu
run : ./gradlew assemble test --no-build-cache --no-daemon --stacktrace -Doverride_kotlin=${{ matrix.kotlin-version }}
- name : Upload Test Results
uses : actions/upload-artifact@v3
if : ${{ failure() }}
with :
name : test-results-${{ matrix.kotlin-version }}
path : ./**/build/reports/tests/
test-windows :
runs-on : windows-latest
timeout-minutes : 25
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
# On Windows the command looks a little bit different. Notice that we use the .bat file and
# quotes for the Kotlin version, because dots "." in the Kotlin version and parameter name
# cause issues.
#
# Expressions in Github actions are limited. If there would be an if expression, then we
# wouldn't need to duplicate the next step and depending on the OS enable / disable them.
- name : Test on Windows
run : ./gradlew.bat assemble test --no-build-cache --no-daemon --stacktrace -Doverride_config-fullTestRun=false
- name : Upload Test Results
uses : actions/upload-artifact@v3
if : ${{ failure() }}
with :
name : test-results-windows
path : ./**/build/reports/tests/
ktlint :
runs-on : ubuntu-latest
timeout-minutes : 15
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : KtLint
run : ./gradlew ktlintCheck --no-build-cache --no-daemon --stacktrace && ./gradlew -p buildSrc ktlintCheck --no-build-cache --no-daemon --stacktrace
lint :
runs-on : ubuntu-latest
timeout-minutes : 15
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : Android Lint
run : ./gradlew lint --no-build-cache --no-daemon --stacktrace
- name : Upload Lint Results
uses : actions/upload-artifact@v3
if : ${{ failure() }}
with :
name : lint-results
path : ./**/build/reports/lint-results.html
publish-maven-local :
runs-on : ubuntu-latest
timeout-minutes : 15
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : Publish to Maven Local
run : ./gradlew clean publishToMavenLocal --no-build-cache --no-daemon --stacktrace --no-parallel && cd gradle-plugin && ./gradlew clean publishToMavenLocal --no-build-cache --no-daemon --stacktrace && cd ..
publish-snapshot :
runs-on : ubuntu-latest
if : github.repository == 'square/anvil' && github.ref == 'refs/heads/main'
timeout-minutes : 25
needs :
- test-ubuntu
- build-gradle-plugin
- gradle-wrapper-validation
- publish-maven-local
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : Publish Snapshots 1.9
run : ./gradlew clean publish --no-build-cache --no-daemon --stacktrace --no-parallel && cd gradle-plugin && ./gradlew clean publish --no-build-cache --no-daemon --stacktrace && cd ..
env :
ORG_GRADLE_PROJECT_mavenCentralUsername : ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
# TODO: Remove when we drop Kotlin 1.8 support
- name : Publish Snapshots 1.8
run : ./gradlew clean publish --no-build-cache --no-daemon --stacktrace --no-parallel -Doverride_kotlin=1.8.22 -PVERSION_NAME=2.4.9-1-8-SNAPSHOT && cd gradle-plugin && ./gradlew clean publish --no-build-cache --no-daemon --stacktrace -Doverride_kotlin=1.8.22 -PVERSION_NAME=2.4.9-1-8-SNAPSHOT && cd ..
env :
ORG_GRADLE_PROJECT_mavenCentralUsername : ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
build-gradle-plugin :
runs-on : ubuntu-latest
defaults :
run :
working-directory : gradle-plugin
timeout-minutes : 15
strategy :
# Run all tasks, even if some fail. Note that they don't share an output, some tasks overlap
# which is expected. If they need to share their outputs, then we need a proper caching
# solution.
fail-fast : false
matrix :
kotlin-version : [ 1.8.22, 1.9.10 ]
agp-version : [ 7.1.1, 7.2.0, 7.3.1 ]
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : Test Gradle Plugin
run : ./gradlew assemble test --no-build-cache --no-daemon --stacktrace -Doverride_kotlin=${{ matrix.kotlin-version }} -Doverride_agp=${{ matrix.agp-version }}
- name : Upload Test Results
uses : actions/upload-artifact@v3
if : ${{ failure() }}
with :
# Use the Kotlin version to prevent overrides.
name : test-results-gradle-plugin-${{ matrix.kotlin-version }}-${{ matrix.agp-version }}
path : ./**/build/reports/tests/
ktlint-gradle-plugin :
runs-on : ubuntu-latest
defaults :
run :
working-directory : gradle-plugin
timeout-minutes : 15
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : KtLint Gradle Plugin
run : ./gradlew ktlintCheck --no-build-cache --no-daemon --stacktrace
kapt-for-dagger-factories :
runs-on : ubuntu-latest
timeout-minutes : 25
strategy :
# Run all tasks, even if some fail. Note that they don't share an output, some tasks overlap
# which is expected. If they need to share their outputs, then we need a proper caching
# solution.
fail-fast : false
matrix :
kotlin-version : [ 1.8.22, 1.9.10 ]
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : Run integration tests
run : ./gradlew -p integration-tests test --no-build-cache --no-daemon --stacktrace -Doverride_kotlin=${{ matrix.kotlin-version }} -Doverride_config-generateDaggerFactoriesWithAnvil=false
- name : Build the sample
run : ./gradlew :sample:app:assembleDebug --no-build-cache --no-daemon --stacktrace -Doverride_kotlin=${{ matrix.kotlin-version }} -Doverride_config-generateDaggerFactoriesWithAnvil=false
- name : Upload Test Results
uses : actions/upload-artifact@v3
if : ${{ failure() }}
with :
# Use the Kotlin version to prevent overrides.
name : test-results-kapt-${{ matrix.kotlin-version }}
path : ./**/build/reports/tests/
instrumentation-tests :
name : Instrumentation tests
runs-on : macos-latest
timeout-minutes : 20
strategy :
# Allow tests to continue on other devices if they fail on one device.
fail-fast : false
matrix :
api-level :
# Consider other devices in case it's needed.
#- 24
- 29
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : Instrumentation Tests
uses : reactivecircus/android-emulator-runner@v2
with :
api-level : ${{ matrix.api-level }}
target : default
arch : x86_64
script : ./gradlew connectedCheck --no-build-cache --no-daemon --stacktrace
- name : Upload results
uses : actions/upload-artifact@v3
with :
name : insrumentation-test-results
path : ./**/build/reports/androidTests/connected/**
gradle-wrapper-validation :
name : "Validate the Gradle Wrapper"
runs-on : ubuntu-latest
timeout-minutes : 15
steps :
- uses : actions/checkout@v3
- uses : gradle/wrapper-validation-action@v1
build-benchmark-project :
runs-on : ubuntu-latest
timeout-minutes : 25
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v3
with :
distribution : 'temurin'
java-version : '11'
check-latest : true
- name : "Generate Project"
run : ./gradlew :createBenchmarkProject
- name : "Build Benchmark Project"
run : ./gradlew :benchmark:app:assemble