-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
345 lines (316 loc) · 8.75 KB
/
.gitlab-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
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
343
344
345
image: registry.gitlab.com/josm/docker-library/openjdk:8
variables:
GIT_SUBMODULE_STRATEGY: recursive
PLUGIN_NAME: "OpenQA"
PLUGIN_JAR_BASE_NAME: "openqa"
cache: &global_cache
paths:
- .gradle/wrapper
- .gradle/caches
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
#############################
# Various additional Checks #
#############################
include:
- template: Code-Quality.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
# - template: Container-Scanning.gitlab-ci.yml
# - template: DAST.gitlab-ci.yml
stages:
- build
- test
- deploy
- release
sast:
variables:
GRADLE_PATH: "./gradlew"
FAIL_NEVER: 1
SAST_EXCLUDED_PATHS: ".gradle"
# CI_DEBUG_TRACE: "true"
###############
# Build stage #
###############
assemble:
stage: build
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/
expire_in: 1 day
interruptible: true
assemble with java 11:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk:11
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/
expire_in: 1 day
interruptible: true
assemble with java 17:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk:17
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/
expire_in: 1 day
allow_failure: true
interruptible: true
code_navigation:
stage: build
script:
- apk add --update curl bash
- curl -fLo coursier https://git.io/coursier-cli
- chmod +x coursier
- ./coursier launch com.sourcegraph:lsif-java_2.13:0.7.2 -- index --build-tool gradle
artifacts:
reports:
lsif: dump.lsif
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
allow_failure: true
interruptible: true
cache:
<<: *global_cache
policy: pull
##############
# Test stage #
##############
build:
stage: test
script:
- ./gradlew build generatePot --stacktrace #--info
artifacts:
paths:
- build
expire_in: 1 day
needs: ["assemble"]
dependencies:
- assemble
interruptible: true
test:
stage: test
script:
- ./gradlew check --stacktrace --continue #--info
- ./gradlew jacocoTestReport
- ./gradlew jacocoTestCoverageVerification
artifacts:
paths:
- build
reports:
junit: build/test-results/**/TEST-*.xml
needs: ["assemble"]
dependencies:
- assemble
interruptible: true
coverage: '/Instruction coverage: \d+\.\d+/'
coverage:
stage: deploy
needs: ["test"]
dependencies:
- test
image: haynes/jacoco2cobertura:1.0.8
script:
- python /opt/cover2cover.py build/reports/jacoco/test/jacocoTestReport.xml $CI_PROJECT_DIR/src/main/java/ > build/reports/jacoco/test/coverage.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: "build/reports/jacoco/test/coverage.xml"
interruptible: true
cache:
<<: *global_cache
policy: pull
translate:
stage: test
script:
- ./gradlew generatePot --stacktrace
artifacts:
paths:
- build
needs: ["assemble"]
cache:
<<: *global_cache
policy: pull
compile against min JOSM:
stage: test
script:
- ./gradlew compileJava_minJosm --stacktrace
needs: ["assemble"]
dependencies:
- assemble
interruptible: true
cache:
<<: *global_cache
policy: pull
compile against latest JOSM:
stage: test
script:
- ./gradlew compileJava_latestJosm --stacktrace
needs: ["assemble"]
dependencies:
- assemble
interruptible: true
cache:
<<: *global_cache
policy: pull
build with java 11:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk:11
script:
- ./gradlew build --stacktrace
needs: ["assemble with java 11"]
dependencies:
- assemble with java 11
interruptible: true
cache:
<<: *global_cache
policy: pull
build with java 17:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk:17
script:
- ./gradlew build --stacktrace
allow_failure: true
needs: ["assemble with java 17"]
dependencies:
- assemble with java 17
interruptible: true
cache:
<<: *global_cache
policy: pull
################
# Deploy stage #
################
#upload to transifex:
# image: python:3.6-stretch
# stage: deploy
# environment:
# name: transifex
# url: https://www.transifex.com/josm/josm/josm-plugin_openqa/
# before_script:
# - apt-get update && apt-get install -yq gettext git
# - pip install git+https://github.com/transifex/transifex-client.git
# script:
# - TX_TOKEN="$TRANSIFEX_TOKEN" tx push -s --no-interactive
# needs: ["assemble"]
# only:
# - master
# interruptible: true
GitLab Maven repo:
stage: deploy
environment:
name: GitLab.com / Maven packages
url: $CI_PROJECT_URL/-/packages
script:
- ./gradlew publishAllPublicationsToGitlabRepository
needs: ["build", "compile against min JOSM", "compile against latest JOSM"]
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG != null && $CI_PIPELINE_SOURCE != "schedule"'
when: always
cache:
<<: *global_cache
policy: pull
#################
# Release stage #
#################
release:
stage: release
environment:
name: pages branch / dist directory
url: ${CI_PAGES_URL}/${CI_PROJECT_NAME}
script:
- &clone_pages_branch |
echo "$SSH_PRIVATE_DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git clone --depth 1 --branch pages git@${CI_SERVER_HOST}:${CI_PROJECT_PATH} pages
- ¤t_version |
version=`git describe --always --dirty`
longVersion=`git describe --always --long --dirty`
commitMessage="Release version $longVersion"
- |
#mkdir -pv "pages/public/dist/$version"
#cp -v "build/dist/"* "build/tmp/jar/MANIFEST.MF" "pages/public/dist/$version"
rm -fv "pages/public/dist/latest"
ln -s "./$version" "pages/public/dist/latest"
- &push_pages_branch |
cd pages/
git config user.name "Deploy with GitLab CI"
git config user.email "${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}@${CI_SERVER_HOST}"
git stage .
git commit -a -m "$commitMessage"
git push origin pages
needs: ["build", "compile against min JOSM", "compile against latest JOSM"]
dependencies:
- build
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG != null && $CI_PIPELINE_SOURCE != "schedule"'
when: manual
cache:
<<: *global_cache
policy: pull
release hotfix:
stage: release
environment:
name: pages branch / dist directory
url: ${CI_PAGES_URL}/${CI_PROJECT_NAME}
script:
- *clone_pages_branch
- *current_version
- |
mkdir -pv "pages/public/dist/$version"
cp -v "build/dist/"* "build/tmp/jar/MANIFEST.MF" "pages/public/dist/$version"
- *push_pages_branch
needs: ["compile against min JOSM", "compile against latest JOSM", "build"]
dependencies:
- build
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG != null && $CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: always
publish update site:
stage: release
environment:
name: pages branch / snapshot update site
url: ${CI_PAGES_URL}/${CI_PROJECT_NAME}/snapshot/${CI_COMMIT_REF_NAME}/update-site
script:
- *clone_pages_branch
- |
commitHash=`git rev-parse HEAD`
commitMessage="Make latest commit from ${CI_COMMIT_REF_NAME} available via JOSM update site ($commitHash)"
- |
rm -vrf "pages/public/snapshot/${CI_COMMIT_REF_NAME}"
mkdir -pv "pages/public/snapshot/${CI_COMMIT_REF_NAME}"
rm -vrf "pages/public/snapshot/libs"
mkdir -pv "pages/public/snapshot/libs"
cp -v "build/snapshot-update-site" "pages/public/snapshot/${CI_COMMIT_REF_NAME}/update-site"
cp -v "build/dist/"* "pages/public/snapshot/${CI_COMMIT_REF_NAME}"
cp -v "build/dist/${PLUGIN_JAR_BASE_NAME}.jar" "pages/public/snapshot/${CI_COMMIT_REF_NAME}/${PLUGIN_JAR_BASE_NAME}-dev.jar"
- *push_pages_branch
needs: ["compile against min JOSM", "compile against latest JOSM", "build"]
dependencies:
- build
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_REF_NAME != null'
when: always
release to Gitlab.com:
stage: release
environment:
name: GitLab.com / Releases
url: $CI_PROJECT_URL/-/releases
script:
- ./gradlew releaseToGitlab
needs: ["GitLab Maven repo"]
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG != null && $CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: always
cache:
<<: *global_cache
policy: pull