mirrored from https://gitlab.com/fdroid/fdroidclient
-
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
342 lines (321 loc) · 11.8 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
342 lines (321 loc) · 11.8 KB
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
image: registry.gitlab.com/fdroid/fdroidserver:buildserver-trixie
stages:
- lint
- test
- deploy
# only create a pipeline if it is a merge request, not for plain
# branches, unless that branch is master.
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "webide"'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
.base:
tags:
- saas-linux-medium-amd64
variables:
JAVA_HOME: /usr/lib/jvm/java-21-openjdk-amd64
GIT_LFS_SKIP_SMUDGE: "1"
GIT_SUBMODULE_STRATEGY: none
before_script:
- test -e /etc/apt/sources.list.d/trixie-backports.list
|| echo "deb http://deb.debian.org/debian trixie-backports main" >> /etc/apt/sources.list
- apt update
- apt-get -qy install -t trixie-backports --no-install-recommends git sdkmanager openjdk-21-jdk-headless
- test -n "$ANDROID_HOME" || source /etc/profile.d/bsenv.sh
- export GRADLE_USER_HOME=$PWD/.gradle
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdk = "\([0-9][0-9]*\)".*,\1,p' gradle/libs.versions.toml`
- sdkmanager --install
"build-tools;${ANDROID_COMPILE_SDK}.0.0"
"platform-tools"
"platforms;android-${ANDROID_COMPILE_SDK}.0"
# index-v1.jar tests need SHA1 support still, TODO use apksig to validate JAR sigs
- sed -i 's,SHA1 denyAfter 20[0-9][0-9],SHA1 denyAfter 2027,'
/usr/lib/jvm/java-21-openjdk-amd64/conf/security/java.security
after_script:
# this file changes every time but should not be cached
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
- rm -fr $GRADLE_USER_HOME/caches/*/plugin-resolution/
cache:
# Use branch-scoped keys so caches are shared across commits on the same branch
key: "${CI_PROJECT_PATH}-${CI_COMMIT_REF_SLUG}"
paths:
- .gradle/wrapper
- .gradle/caches
.test-template: &test-template
extends: .base
stage: test
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
- kernel.log
- logcat.txt
- app/core*
- app/*.log
- app/build/reports
- app/build/outputs/*ml
- app/build/outputs/apk
- libs/*/build/reports
- build/reports
reports:
junit:
- app/build/**/TEST-*.xml
- libs/*/build/**/TEST-*.xml
expire_in: 1 week
when: on_failure
after_script:
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
# this file changes every time but should not be cached
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
- rm -fr $GRADLE_USER_HOME/caches/*/plugin-resolution/
.always-on-these-changes: &always-on-these-changes
changes:
- .gitlab-ci.yml
- build.gradle
- settings.gradle
- gradle/libs.versions.toml
app assembleRelease test:
<<: *test-template
rules:
- <<: *always-on-these-changes
- changes:
- app/**/*
- libs/**/*
script:
- ./gradlew :app:assembleDefault :app:testFullDebugUnitTest
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
- app/build/reports
- app/build/outputs/apk
- app/build/outputs/mapping
- libs/*/build/reports
reports:
junit:
- app/build/test-results/*/TEST-*.xml
expire_in: 1 week
when: always
libs db test:
<<: *test-template
rules:
- <<: *always-on-these-changes
- changes:
- libs/database/**/*
script:
- ./gradlew :libs:database:testDebugUnitTest
libs download test:
<<: *test-template
rules:
- <<: *always-on-these-changes
- changes:
- libs/download/**/*
script:
- ./gradlew :libs:download:testAndroidHostTest
libs index test:
<<: *test-template
rules:
- <<: *always-on-these-changes
- changes:
- libs/index/**/*
script:
- ./gradlew :libs:index:testAndroidHostTest
app lint:
<<: *test-template
stage: lint
rules:
- <<: *always-on-these-changes
- changes:
- app/**/*
script:
# the tasks "lint", "test", etc don't always include everything
- ./gradlew :app:lint :app:ktfmtCheck
libs lint:
<<: *test-template
stage: lint
rules:
- <<: *always-on-these-changes
- changes:
- libs/**/*
script:
- ./gradlew :libs:core:lint :libs:database:lint :libs:download:lint :libs:index:lint
- ./gradlew :libs:core:ktfmtCheck :libs:database:ktfmtCheck :libs:download:ktfmtCheck :libs:index:ktfmtCheck :libs:sharedTest:ktfmtCheck
- ./gradlew checkLegacyAbi
app screenshots:
<<: *test-template
stage: lint
rules:
- <<: *always-on-these-changes
- changes:
- app/**/*
before_script:
- apt update
- apt-get -qy install --no-install-recommends git-lfs
- test -n "$ANDROID_HOME" || source /etc/profile.d/bsenv.sh
- export GRADLE_USER_HOME=$PWD/.gradle
- git lfs install
- git lfs fetch https://gitlab.com/fdroid/fdroidclient.git --all
- git lfs fetch origin --all || true # may fail if fork has LFS disabled
- git lfs checkout
script:
- ./gradlew :app:validateBasicDefaultDebugScreenshotTest
after_script:
- |
if [ "$CI_JOB_STATUS" == "failed" ]; then
url="https://${CI_PROJECT_NAMESPACE}.${CI_PAGES_DOMAIN}/-/${CI_PROJECT_NAME}/-/jobs/${CI_JOB_ID}/artifacts/app/build/reports/screenshotTest/preview/debug/basicDefault/index.html"
echo "Report at ${url}"
echo '[{"location":{"path":".","lines":{"begin":1}},"description":"Screenshot test report needs copy and paste: '"${url}"'","check_name":"screenshot_test_report","fingerprint":"screenshot_test_report","severity":"blocker"}]' > codequality-warnings.json
fi
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
when: always
paths:
- app/build/reports/screenshotTest
- codequality-warnings.json
reports:
codequality: codequality-warnings.json
expire_in: 1 week
app tools scripts:
stage: lint
image: debian:trixie-slim
variables:
GIT_LFS_SKIP_SMUDGE: "1"
rules:
- <<: *always-on-these-changes
- changes:
- app/**/*
script:
- apt-get update
- apt-get -qy install --no-install-recommends python3
- ./tools/check-format-strings.py
- ./tools/check-fastlane-whitespace.py
app weblate merge conflict:
stage: lint
image: debian:trixie-slim
rules:
- changes:
- .gitlab-ci.yml
- app/src/*/res/values*/strings.xml
- metadata/*
variables:
GIT_LFS_SKIP_SMUDGE: "1"
script:
- apt-get update
- apt-get -qy install --no-install-recommends ca-certificates git git-lfs
- git config user.name "$CI_PIPELINE_ID/$CI_JOB_ID"
- git config user.email $CI_PROJECT_PATH@f-droid.org
- git fetch https://hosted.weblate.org/git/f-droid/f-droid
- git checkout -B weblate FETCH_HEAD
- export EXITVALUE=0
- if ! git rebase $CI_COMMIT_SHA; then
export EXITVALUE=1;
set -x;
while git rebase --skip; do echo; done;
set +x;
fi
- git diff --exit-code
- exit $EXITVALUE
libs database schema:
<<: *test-template
stage: lint
rules:
- <<: *always-on-these-changes
- changes:
- libs/database/**/*
script:
- ./gradlew :libs:database:kspDebugKotlin
- git status
- git --no-pager diff --exit-code
cache: []
# Run the tests in the emulator. Each step is broken out to run on
# its own since the CI runner can have limited RAM, and the emulator
# can take a while to start.
#
# once these prove stable, the task should be switched to
# connectedCheck to test all the build flavors
.kvm-connected-template: &kvm-connected-template
extends: .base
image: briar/ci-image-android-emulator:trixie # TODO change to latest once available
tags:
- kvm
rules:
- if: '$RUN_KVM_JOBS == "1"'
# Cache hits the storage limits in kvm runners quickly
cache: []
script:
- export AVD_SDK=`echo $CI_JOB_NAME | awk '{print $2}'`
- export AVD_TAG=`echo $CI_JOB_NAME | awk '{print $3}'`
- export AVD_ARCH=`echo $CI_JOB_NAME | awk '{print $4}'`
- export AVD_PACKAGE="system-images;android-${AVD_SDK};${AVD_TAG};${AVD_ARCH}"
- echo $AVD_PACKAGE
- $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager --verbose delete avd --name "$NAME_AVD"
- export AVD="$AVD_PACKAGE"
- $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "$AVD"
- echo no | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager --verbose create avd --name "$NAME_AVD" --package "$AVD" --device "pixel"
- df -h
- start-emulator.sh
- export FLAG="-Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.LargeTest,androidx.test.filters.FlakyTest"
- ./gradlew $FLAG :app:connectedAndroidTest :libs:database:connectedCheck :libs:download:connectedAndroidTest :libs:index:connectedAndroidTest
- export FLAG="-Pandroid.testInstrumentationRunnerArguments.annotation=androidx.test.filters.FlakyTest"
- for i in {1..5}; do echo "$i" && ./gradlew $FLAG :app:connectedAndroidTest :libs:database:connectedCheck :libs:download:connectedAndroidTest :libs:index:connectedAndroidTest && break; done || exit 137
allow_failure:
exit_codes: 137
kvm 24 default x86:
<<: [ *test-template, *kvm-connected-template ]
no kvm warning:
image: debian:trixie-slim
rules:
- if: '$RUN_KVM_JOBS != "1"'
cache: []
script:
- |
echo "WARNING: RUN_KVM_JOBS environment variable is not set."
echo "This job requires a special KVM runner. Skipping with warning."
echo '[{"location":{"path":".gitlab-ci.yml","lines":{"begin":237}},"description":"KVM job was skipped: RUN_KVM_JOBS env variable is not set. Set it to 1 to enable this job.","check_name":"skipped_kvm_job","fingerprint":"skipped_kvm_job","severity":"major"}]' > codequality-warnings.json
exit 42
artifacts:
reports:
codequality: codequality-warnings.json
allow_failure:
exit_codes: 42
pages:
extends: .base
stage: deploy
only:
- master
script:
- ./gradlew :libs:core:dokkaGenerateHtml :libs:download:dokkaGenerateHtml :libs:index:dokkaGenerateHtml :libs:database:dokkaGenerateHtml
- mkdir -p public/libs
- touch public/index.html public/libs/index.html
- cp -r libs/core/build/dokka/html public/libs/core
- cp -r libs/download/build/dokka/html public/libs/download
- cp -r libs/index/build/dokka/html public/libs/index
- cp -r libs/database/build/dokka/html public/libs/database
artifacts:
paths:
- public
deploy_nightly:
extends: .base
stage: deploy
only:
- master
variables:
JAVA_HOME: /usr/lib/jvm/java-21-openjdk-amd64
script:
- test -z "$DEBUG_KEYSTORE" && exit 0
- apt-get install -t trixie-backports androguard fdroidserver jq moreutils python3-progress
- sed -i
's,<string name="app_name_basic">.*</string>,<string name="app_name_basic">F-Nightly Basic</string>,'
app/src/main/res/values*/strings.xml
- sed -i
's,<string name="app_name_full">.*</string>,<string name="app_name_full">F-Nightly</string>,'
app/src/main/res/values*/strings.xml
# add this nightly repo as a enabled repo
- jq --slurpfile new_dict config/nightly-repo/repo.json "[(\$new_dict[0] | .address = \"${CI_PROJECT_URL}-nightly/-/raw/master/fdroid/repo\")] + ." app/src/main/assets/default_repos.json | sponge app/src/main/assets/default_repos.json
# build the APKs!
- rm -rf app/build/outputs/apk legacy/build/outputs/apk
- ./gradlew :app:assembleBasicNightly :app:assembleFullNightly
- mv app/build/outputs/apk/basicNightly/release/app-basic-nightly-release-unsigned.apk app/build/outputs/apk/basicNightly/release/app-basic-debug.apk
- mv app/build/outputs/apk/fullNightly/release/app-full-nightly-release-unsigned.apk app/build/outputs/apk/fullNightly/release/app-full-debug.apk
- fdroid nightly -v
cache: []