-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
448 lines (387 loc) · 11.7 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
436
437
438
439
440
441
442
443
444
445
446
447
448
# 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: "10"
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
- cpack -G DEB
- rm -rf src _CPack_Packages # exclude from artifacts
- cd ..
artifacts:
expire_in: 1 year
paths:
- build/
appimage:linux:
image: registry.gitlab.com/inkscape/inkscape-ci-docker/ubuntu-2004
# appimage creator script does not support recent OS (yet)
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:x64:
stage: build
tags:
- mac
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"'
- if: '$CI_PROJECT_NAMESPACE == "dehesselle"'
variables:
INK_BUILD: $CI_PIPELINE_IID
MACOSX_DEPLOYMENT_TARGET: "10.13"
WRK_DIR: /Users/Shared/work
script:
- packaging/macos/build.sh
artifacts:
expire_in: 1 year
paths:
- Inkscape*.dmg
- toolset_overlay.tar.xz
inkscape:macos:arm:
extends: inkscape:macos:x64
tags:
- saas-macos-medium-m1
image: macos-12-xcode-13
variables:
MACOSX_DEPLOYMENT_TARGET: "11.3"
CCACHE_DIR: $CI_PROJECT_DIR/ccache
SYS_USRLOCAL_IGNORE: "true"
cache:
key: "cache-macos"
paths:
- ccache
.windows:
stage: build
tags:
- shared-windows
rules:
- *do_not_run_for_schedules
- *run_otherwise
cache:
key: "cache-windows"
paths:
- ccache
when: always
variables:
MSYSTEM: MINGW64
CCACHE_DIR: $CI_PROJECT_DIR/ccache
CCACHE_MAXSIZE: "2.0G"
IDW_ARCHIVE: msys64.7z
IDW_RELEASE_TAG: r230618.1
IDW_RELEASE_URL: https://gitlab.com/api/v4/projects/46863172/packages/generic/windows/$IDW_RELEASE_TAG/$IDW_ARCHIVE
before_script:
- wget.exe --quiet --no-check-certificate $IDW_RELEASE_URL
- 7z x -oC:/ $IDW_ARCHIVE
inkscape:windows:build:
extends: .windows
retry: 2
script:
- C:/msys64/msys2_shell.cmd -defterm -no-start -mingw64 -here -c "cmake -Bbuild -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DWITH_INTERNAL_CAIRO=OFF"
- C:/msys64/msys2_shell.cmd -defterm -no-start -mingw64 -here -c "timeout -k 10s 70m ninja -C build"
- 7z a build.7z build
artifacts:
paths:
- build.7z
inkscape:windows:dist:
extends: .windows
parallel:
matrix:
- DIST: [ "7z", "exe", "msi" ]
rules:
- if: $DIST != "7z"
when: manual
allow_failure: true
- *run_otherwise
dependencies:
- inkscape:windows:build
needs:
- inkscape:windows:build
script:
- 7z x build.7z
- C:/msys64/msys2_shell.cmd -defterm -no-start -mingw64 -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:arm:
extends: inkscape:macos:arm
stage: test
dependencies:
- inkscape:macos:arm
needs: ["inkscape:macos:arm"]
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"
- git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA -U0 --no-color | clang-format-diff -p1 -style file | 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!
# 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 $CI_MERGE_REQUEST_DIFF_BASE_SHA -U0 --no-color src/3rdparty/*/ | 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
- ./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
# "borrow" a 3rdparty file to dump header includes
- git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA --name-only -- '**.h' | sed 's!.*!#include"../../../../&"!' | tee src/3rdparty/adaptagrams/libcola/box.cpp
- git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA --name-only -- '**.cpp' | tee clang_tidy_files
- bash buildtools/clangtidy-helper.sh $(cat clang_tidy_files)
# ... 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