-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
435 lines (380 loc) · 11.9 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# Dependencies are managed in the Dockerfile in the inkscape-ci-docker
# Git repository. Change them there, wait a bit, and then we'll use
# the new ones here in these builds.
image: registry.gitlab.com/inkscape/inkscape-ci-docker/master
# This file is structured in four parts:
# I) definitions
# II) build jobs
# III) checks that are run on merge requests
# IV) building inkscape.gitlab.io/inkscape (doc and scan)
#
#######################
# #
# Definitions #
# #
#######################
# all jobs are safe to interrupt
default:
interruptible: true
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
timeout: 3h
#speedup git on runners
variables:
GIT_DEPTH: "50"
GIT_SUBMODULE_STRATEGY: recursive
#reusable templates
.ccache_init: &ccache_init
before_script:
- mkdir -p ccache
- export CCACHE_BASEDIR=${PWD}
- export CCACHE_DIR=${PWD}/ccache
.cmake: &cmake
- mkdir -p build/conf
- cd build
- cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=$PWD/install_dir/ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# basic workflow setup:
# - run pipelines for all branches without an open MR
# - run MR pipeline only as soon as an MR is opened
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
.run_MR: &run_for_MR
if: '$CI_MERGE_REQUEST_ID'
.run_no_MR: &do_not_run_for_MR
if: '$CI_MERGE_REQUEST_ID'
when: never
.run_no_schedules: &do_not_run_for_schedules
if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
.run_otherwise: &run_otherwise
when: on_success
#######################
# #
# Building inkscape #
# #
#######################
# Linux, Appimage, macOS, Windows.
inkscape:linux:
stage: build
rules:
- *do_not_run_for_schedules
- *run_otherwise
cache:
key: "cache-linux"
paths:
- ccache/
<<: *ccache_init
script:
- *cmake
- make -j3 install
- make -j3 tests
- make -j3 unit_tests
#- cpack -G DEB
- rm -rf src _CPack_Packages # exclude from artifacts
- cd ..
artifacts:
expire_in: 1 year
paths:
- build/
appimage:linux:
stage: build
rules:
- *do_not_run_for_schedules
- *run_otherwise
cache:
key: "cache-appimage"
paths:
- ccache/
<<: *ccache_init
script:
- bash -ex packaging/appimage/generate.sh
artifacts:
expire_in: 1 year
paths:
- Inkscape*.AppImage*
inkscape:macos:
stage: build
parallel:
matrix:
- RUNNER: [ "macosarm" ]
rules:
- *do_not_run_for_schedules
# Mac runner is restricted to "inkscape" and "dehesselle" namespaces; only generate pipelines for those
- if: $CI_PROJECT_NAMESPACE != "inkscape" && $CI_PROJECT_NAMESPACE != "dehesselle"
when: never
# Intel runner
- if: $RUNNER == "macosintel"
variables:
MACOSX_DEPLOYMENT_TARGET: "10.13"
# Apple Silicon runner
- if: $RUNNER == "macosarm"
variables:
SDKROOT: /opt/sdks/MacOSX11.3.sdk
tags:
- ${RUNNER}
variables:
INK_BUILD: $CI_PIPELINE_IID
WRK_DIR: /Users/Shared/work
script:
- packaging/macos/build.sh
artifacts:
expire_in: 1 year
paths:
- Inkscape*.dmg
- toolset_overlay.tar.xz
.windows:
stage: build
tags:
- saas-windows-medium-amd64
cache:
key: "cache-windows"
paths:
- ccache
when: always
variables:
MSYSTEM: UCRT64
CCACHE_DIR: $CI_PROJECT_DIR/ccache
CCACHE_MAXSIZE: "1.0G"
# IDW = Inkscape Deps Windows, https://gitlab.com/inkscape/deps/windows
IDW_VERSION: 69
IDW_NAME: ink$IDW_VERSION
IDW_RELEASE_URL: $CI_API_V4_URL/projects/46863172/packages/generic/windows/r$IDW_VERSION/$IDW_NAME.7z
before_script:
- wget.exe --quiet --no-check-certificate $IDW_RELEASE_URL
- 7z x -oC:/ "$Env:IDW_NAME.7z"
inkscape:windows:
extends: .windows
retry: 2
parallel:
matrix:
- DIST: [ "7z", "exe", "msi" ]
rules:
- *do_not_run_for_schedules
- if: $DIST != "7z"
when: manual
allow_failure: true
- *run_otherwise
script:
- . "C:/$Env:IDW_NAME/msys2_shell.cmd" -defterm -no-start -ucrt64 -here -c "cmake -B build -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
# If we are building the MSI package, install extra build dependencies
- if ("${DIST}" -eq "msi") { & "$Env:CI_PROJECT_DIR\buildtools\windows-deps-install-wix4.ps1" }
# Kill the job before hitting runner's timeout. This way we can preserve the cache so the next retry
# will be able to advance the build further and eventually finish (after up to two retries, 3 jobs in total).
# Calculation is: 20 minutes for download and extraction of msys2
# 80 minutes build (4800 seconds, see 'sleep' below)
# 20 minutes as buffer and save cache
# --- --------------------------------
# 120 minutes runner timeout
- Start-Job -ScriptBlock{sleep 4800; taskkill /t /F /IM "ninja.exe"}
- . "C:/$Env:IDW_NAME/msys2_shell.cmd" -defterm -no-start -ucrt64 -here -c "ninja -C build dist-win-${DIST}"
artifacts:
paths:
- build/inkscape*.${DIST}
#tests, always run after building
test:linux:
stage: test
rules:
- *do_not_run_for_schedules
- *run_otherwise
dependencies:
- inkscape:linux
needs: ["inkscape:linux"]
script:
- sed -i '/<policy domain="coder" rights="none"/d' /etc/ImageMagick-6/policy.xml
- cd build
- ctest -V
artifacts:
paths:
- build/testfiles
- build/Testing
when: on_failure
.test:macos:
extends: inkscape:macos
stage: test
parallel:
matrix:
- RUNNER: [ "macosintel" ]
script:
- packaging/macos/test.sh
artifacts:
paths:
- testfiles.tar.xz
when: on_failure
###########################
# #
# MR code checkers #
# #
###########################
### This script checks for *merge requests* that they conform to the code style. It allows failures.
# cf ./_clang-format and https://inkscape.org/develop/coding-style/
codequality:
stage: test
needs: []
rules:
- *do_not_run_for_schedules
- *run_for_MR
script:
- git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- echo "Your commit does not comply exactly with the clang-format style checker.\nPlease review the following diff or apply it with\n \$ git apply <<EOF"
- bash buildtools/codequality.sh $CI_MERGE_REQUEST_DIFF_BASE_SHA | tee clang_format.diff
- echo "EOF"
- if [[ -s clang_format.diff ]]; then false; fi
allow_failure: true
artifacts:
paths:
- clang_format.diff
### We embed script from third party libraries, that we sometimes update from their source. Hence we should NEVER modify them here before submitting the patch upstream!
# Submodules do not need this treatment, so are exempted from the check.
# Ideally, we should remove all this code and use them as packaged libraries. Unfortunately this check only works for merge requests.
codeprotect:
stage: test
needs: []
rules:
- *do_not_run_for_schedules
- *run_for_MR
script:
- git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA src/3rdparty/*/ > changed
- git submodule foreach --quiet 'echo $name' > submodules
- comm -23 changed submodules | tee forbidden
- if [[ -s forbidden ]]; then echo "This commit modifies files that are in an dependency library. Make sure you update upstream first, *then* force the merge in Inkscape."; false; fi
#### All files should have a licence
check-license-headers:
stage: test
needs: []
rules:
- *do_not_run_for_schedules
- *run_for_MR
script:
- python3 buildtools/check_license_headers.py
### Several translation tests:
# - verify that the list of translatable files (POTFILES.*.in) are up to date
# - check if we can successfully re-generate inkscape.pot
# - sync all .po files with the updated inkscape.pot and run some automated checks on them
# (artifacts from this job are also used to generate translations statistics for the website)
translations:
stage: test
needs: []
rules:
- *run_otherwise
script:
# make sure dependencies for inkscape.pot are up-to-date
- mkdir build && cd build && cmake .. && make inkscape_pot && cd .. || exit 1
- cd po/
# update POTFILES.*.in
- ./generate_POTFILES.sh
# update inkscape.pot and sync all .po files
- rm -f inkscape.pot
- cd ../build && make inkscape_pot && cd ../po || exit 1
- ../buildtools/post_translation_statistics.sh
- ./update_po_files.sh
# check if POTFILES.*.in should be updated in the repo (shall we automate this?)
- 'if [ -n "$(git diff POTFILES.*.in)" ]; then
git diff POTFILES.*.in;
echo "New translatable strings in source files found.";
echo "Please add the paths to POTFILES.*.in so they can be translated";
echo "(or add them to POTFILES.skip to exclude them from translations).";
exit 1;
fi'
artifacts:
name: "translations"
paths:
- po/
### clang-tidy is an utility to check that some c++ code good practices and patterns are respected. We use it at 1% of its possibilities (only when it suggests fixes).
# ... here only on modified files
clangtidy:linux:
stage: test
needs: []
rules:
- *do_not_run_for_schedules
- *run_for_MR
script:
- git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- bash buildtools/clangtidy.sh $CI_MERGE_REQUEST_DIFF_BASE_SHA
# ... here on master commits
clangtidyfull:linux:
stage: test
needs: []
rules:
- *do_not_run_for_MR
- *do_not_run_for_schedules
- <<: *run_otherwise
changes:
- src/*
cache:
key: "cache-clang"
paths:
- ccache/
<<: *ccache_init
script:
- bash buildtools/clangtidy-helper.sh
# Look for icon problems
media-check:
stage: test
needs: []
rules:
- *do_not_run_for_schedules
- *run_otherwise
script:
- python3 buildtools/media-check-icons.py
- python3 buildtools/media-check-keys.py
##################################################
# #
# Building https://inkscape.gitlab.io/inkscape #
# #
##################################################
### scan-build is a static analysis tool. This job is *slow*.
scan-build:
stage: test
rules:
- if: $SCHEDULED_JOB_NAME == "clang"
needs: []
script:
- apt-get update -yqq && apt-get install -y clang
- mkdir -p clang-build
- cd clang-build
- scan-build cmake .. -DCMAKE_BUILD_TYPE=Debug
- VERBOSE=1 scan-build -o ../scan make -j2
artifacts:
paths:
- scan/
### doxygen
source-doc:
stage: build
rules:
- if: $SCHEDULED_JOB_NAME == "source-doc"
script:
- cd buildtools
- doxygen Doxyfile
- doxygen Doxyfile-extensions
- cd ..
artifacts:
paths:
- doc/doxygen
- doc/doxygen-extensions
# uploads the clang scan to user.gitlab.io/inkscape/
pages:
stage: deploy
rules:
- if: $SCHEDULED_JOB_NAME == "clang"
- if: $SCHEDULED_JOB_NAME == "source-doc"
cache:
key: "cache-pages"
paths:
- public
dependencies:
- source-doc
- scan-build
script:
- mkdir -p public/
- sed "s/%DATE%/$(date '+%B %d, %Y')/" buildtools/ci-index.html > public/index.html
- if test -e scan; then rm -fr public/scan-build && cp -rv scan/* public/scan-build; fi
- if test -e doc/doxygen; then rm -fr public/doxygen && cp -rv doc/doxygen/html/. public/doxygen; fi
- if test -e doc/doxygen-extensions; then rm -fr public/doxygen-extensions && cp -rv doc/doxygen-extensions/html/. public/doxygen-extensions; fi
artifacts:
paths:
- public