Imported Upstream version 2.72.3
[platform/upstream/glib.git] / .gitlab-ci.yml
1 stages:
2   - style-check
3   - build
4   - coverage
5   - analysis
6   - deploy
7
8 cache:
9   paths:
10     - _ccache/
11
12 variables:
13   FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v13"
14   COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v3"
15   DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v9"
16   ANDROID_IMAGE: "registry.gitlab.gnome.org/gnome/glib/android-ndk:v6"
17   MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v5"
18   MESON_TEST_TIMEOUT_MULTIPLIER: 2
19   G_MESSAGES_DEBUG: all
20   MESON_COMMON_OPTIONS_NO_WARNING: "--buildtype debug --wrap-mode=nodownload"
21   MESON_COMMON_OPTIONS: "${MESON_COMMON_OPTIONS_NO_WARNING} --fatal-meson-warnings"
22
23 .only-default:
24   only:
25     - branches
26   except:
27     - tags
28
29 # Some jobs run on CI runners which don’t have good isolation between CI jobs,
30 # and don’t have much available resource. Limit those jobs to only ones on the
31 # origin repository (GNOME/glib), rather than people’s forks. Code in the origin
32 # repository can be trusted.
33 .only-origin:
34   only:
35     - branches@GNOME/glib
36   except:
37     - tags
38
39 # Some jobs take a long time and are unlikely to find failures (or will find
40 # failures which are not merge-blockers to fix), so they’re executed on a weekly
41 # schedule in order to save CI resources and speed up branch pipelines.
42 .only-schedules:
43   only:
44     - schedules
45   except:
46     - tags
47
48 .build-linux:
49   before_script:
50     - bash .gitlab-ci/show-execution-environment.sh
51     - cp -r $HOME/subprojects/* subprojects/
52
53 style-check-diff:
54   extends: .only-default
55   image: $DEBIAN_IMAGE
56   stage: style-check
57   allow_failure: true
58   script:
59     - .gitlab-ci/run-style-check-diff.sh
60     - .gitlab-ci/run-shellcheck.sh
61     - .gitlab-ci/run-black.sh
62     - .gitlab-ci/run-flake8.sh
63
64 check-todos:
65   extends: .only-default
66   image: $DEBIAN_IMAGE
67   stage: style-check
68   allow_failure: true
69   script:
70     - .gitlab-ci/run-check-todos.sh
71
72 fedora-x86_64:
73   extends:
74     - .build-linux
75     - .only-default
76   image: $FEDORA_IMAGE
77   stage: build
78   needs: []
79   variables:
80     CFLAGS: "-coverage -ftest-coverage -fprofile-arcs"
81   script:
82     # FIXME: Cannot use MESON_COMMON_OPTIONS here because meson warns about gtkdoc
83     # feature fully functional in 0.54, but we only depend on 0.52. So we cannot build
84     # with --fatal-meson-warnings.
85     - meson ${MESON_COMMON_OPTIONS_NO_WARNING}
86             --werror
87             --default-library=both
88             --prefix=$HOME/glib-installed
89             --localstatedir=/var
90             --libdir=lib
91             -Dsystemtap=true
92             -Ddtrace=true
93             -Dinstalled_tests=true
94             -Dgtk_doc=true
95             _build
96     - ninja -C _build
97     - mkdir -p _coverage
98     - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
99     - .gitlab-ci/run-tests.sh
100     - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov"
101   artifacts:
102     reports:
103       junit: "_build/${CI_JOB_NAME}-report.xml"
104     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
105     when: always
106     paths:
107       - "_build/config.h"
108       - "_build/glib/glibconfig.h"
109       - "_build/meson-logs"
110       - "_build/docs/reference/glib/glib-undeclared.txt"
111       - "_build/docs/reference/glib/glib-undocumented.txt"
112       - "_build/docs/reference/glib/glib-unused.txt"
113       - "_build/docs/reference/gobject/gobject-undeclared.txt"
114       - "_build/docs/reference/gobject/gobject-undocumented.txt"
115       - "_build/docs/reference/gobject/gobject-unused.txt"
116       - "_build/docs/reference/gio/gio-undeclared.txt"
117       - "_build/docs/reference/gio/gio-undocumented.txt"
118       - "_build/docs/reference/gio/gio-unused.txt"
119       - "_build/${CI_JOB_NAME}-report.xml"
120       - "_coverage"
121
122 debian-stable-x86_64:
123   extends:
124     - .build-linux
125     - .only-default
126   image: $DEBIAN_IMAGE
127   stage: build
128   needs: []
129   script:
130     - meson ${MESON_COMMON_OPTIONS}
131             --werror
132             --default-library=both
133             --prefix=$HOME/glib-installed
134             --localstatedir=/var
135             --libdir=lib
136             -Dsystemtap=true
137             -Ddtrace=true
138             -Dfam=true
139             -Dinstalled_tests=true
140             _build
141     - ninja -C _build
142     - .gitlab-ci/run-tests.sh
143   artifacts:
144     reports:
145       junit: "_build/${CI_JOB_NAME}-report.xml"
146     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
147     when: always
148     paths:
149       - "_build/config.h"
150       - "_build/glib/glibconfig.h"
151       - "_build/meson-logs"
152       - "_build/${CI_JOB_NAME}-report.xml"
153
154 installed-tests:
155   extends:
156     - .build-linux
157     - .only-schedules
158   image: $FEDORA_IMAGE
159   stage: build
160   needs: []
161   script:
162     # dtrace is disabled because it breaks the static-link.py test
163     - meson ${MESON_COMMON_OPTIONS}
164             --werror
165             --prefix=/usr --libdir=/usr/lib64
166             -Dinstalled_tests=true
167             -Ddefault_library=both
168             -Ddtrace=false
169             _build
170     - ninja -C _build
171     - sudo ninja -C _build install
172     # Remove old headers, possibly present in current installation
173     - sudo rm -f /usr/include/glib-2.0/glib/gurifuncs.h
174     - sudo chown -R `id -un`:`id -gn` _build/
175     # Work-around https://gitlab.gnome.org/GNOME/gnome-desktop-testing/merge_requests/2
176     - mkdir -p _build/installed-tests-report/logs/
177     - GLIB_TEST_COMPILATION=1 gnome-desktop-testing-runner
178             --report-directory=_build/installed-tests-report/failed/
179             --log-directory=_build/installed-tests-report/logs/
180             --parallel=0
181             glib
182   artifacts:
183     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
184     when: always
185     paths:
186       - "_build/config.h"
187       - "_build/glib/glibconfig.h"
188       - "_build/meson-logs"
189       - "_build/installed-tests-report/"
190
191 G_DISABLE_ASSERT:
192   extends:
193     - .build-linux
194     - .only-schedules
195   image: $FEDORA_IMAGE
196   stage: build
197   needs: []
198   script:
199     - meson ${MESON_COMMON_OPTIONS}
200             --werror
201             -Dsystemtap=true
202             -Ddtrace=true
203             -Dinstalled_tests=true
204             -Dglib_assert=false
205             _build
206     - ninja -C _build
207     - bash -x ./.gitlab-ci/run-tests.sh
208   artifacts:
209     reports:
210       junit: "_build/${CI_JOB_NAME}-report.xml"
211     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
212     when: always
213     paths:
214       - "_build/config.h"
215       - "_build/glib/glibconfig.h"
216       - "_build/meson-logs"
217       - "_build/${CI_JOB_NAME}-report.xml"
218
219 valgrind:
220   extends:
221     - .build-linux
222     - .only-schedules
223   image: $FEDORA_IMAGE
224   stage: analysis
225   needs: []
226   variables:
227     MESON_TEST_TIMEOUT_MULTIPLIER: 10
228   script:
229     - meson ${MESON_COMMON_OPTIONS}
230             --werror
231             -Dsystemtap=true
232             -Ddtrace=true
233             -Dinstalled_tests=true
234             _build
235     - ninja -C _build
236     - bash -x ./.gitlab-ci/run-tests.sh
237                  --log-file _build/meson-logs/testlog-valgrind.json
238                  --wrap "valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full --leak-resolution=high --num-callers=50 --show-leak-kinds=definite,possible --show-error-list=yes --suppressions=${CI_PROJECT_DIR}/glib.supp"
239                  --no-suite no-valgrind
240                  --no-suite slow
241   # FIXME: Remove this when we have zero valgrind leaks.
242   # https://gitlab.gnome.org/GNOME/glib/issues/333
243   allow_failure: true
244   artifacts:
245     reports:
246       junit: "_build/${CI_JOB_NAME}-report.xml"
247     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
248     when: always
249     paths:
250       - "_build/config.h"
251       - "_build/glib/glibconfig.h"
252       - "_build/meson-logs"
253
254 .cross-build-linux:
255   extends: .build-linux
256   stage: build
257   needs: []
258   artifacts:
259     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
260     when: always
261     paths:
262       - "_build/meson-logs"
263
264 cross-android_api28_arm64:
265   extends:
266     - .cross-build-linux
267     - .only-default
268   image: $ANDROID_IMAGE
269   script:
270     # FIXME: add --werror
271     - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt _build
272     - ninja -C _build
273
274 cross-mingw64:
275   extends:
276     - .cross-build-linux
277     - .only-default
278   image: $MINGW_IMAGE
279   script:
280     # FIXME: Add --werror
281     - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_mingw64.txt _build
282     - ninja -C _build
283   artifacts:
284     reports:
285       junit: "_build/${env:CI_JOB_NAME}-report.xml"
286     name: "glib-${env:CI_JOB_NAME}-${env:CI_COMMIT_REF_NAME}"
287     when: always
288     paths:
289       - _build/meson-logs
290       - "_build/${env:CI_JOB_NAME}-report.xml"
291       - _build/glib/libglib-2.0-0.dll
292       - _build/gio/libgio-2.0-0.dll
293       - _build/gmodule/libgmodule-2.0-0.dll
294       - _build/gthread/libgthread-2.0-0.dll
295       - _build/gobject/libgobject-2.0-0.dll
296
297 msys2-mingw32:
298   extends: .only-default
299   stage: build
300   tags:
301     - win32-ps
302   needs: []
303   variables:
304     MSYSTEM: "MINGW32"
305     CHERE_INVOKING: "yes"
306   script:
307     - C:\msys64\usr\bin\pacman --noconfirm -Syyuu --ask 20
308     - C:\msys64\usr\bin\bash .gitlab-ci/show-execution-environment.sh
309     - C:\msys64\usr\bin\bash -lc "bash -x ./.gitlab-ci/test-msys2.sh"
310   artifacts:
311     reports:
312       junit: "_build/${env:CI_JOB_NAME}-report.xml"
313     name: "glib-${env:CI_JOB_NAME}-${env:CI_COMMIT_REF_NAME}"
314     when: always
315     paths:
316       - _build/meson-logs
317       - "_build/${env:CI_JOB_NAME}-report.xml"
318       - _coverage/
319
320 vs2017-x64:
321   extends: .only-default
322   stage: build
323   tags:
324     - win32-ps
325   needs: []
326   script:
327     # FIXME: These should use --wrap-mode=nodownload but the Windows CI machines
328     # aren’t currently set up for that.
329     - .gitlab-ci/test-msvc.bat ${MESON_COMMON_OPTIONS} --wrap-mode=default
330   artifacts:
331     reports:
332       junit: "_build/${env:CI_JOB_NAME}-report.xml"
333     name: "glib-${env:CI_JOB_NAME}-${env:CI_COMMIT_REF_NAME}"
334     when: always
335     paths:
336       - _build/meson-logs
337       - "_build/${env:CI_JOB_NAME}-report.xml"
338       - _build/glib/libglib-2.0-0.dll
339       - _build/gio/libgio-2.0-0.dll
340       - _build/gmodule/libgmodule-2.0-0.dll
341       - _build/gthread/libgthread-2.0-0.dll
342       - _build/gobject/libgobject-2.0-0.dll
343
344 vs2017-x64-static:
345   extends: .only-default
346   stage: build
347   tags:
348     - win32-ps
349   needs: []
350   script:
351     # FIXME: These should use --wrap-mode=nodownload but the Windows CI machines
352     # aren’t currently set up for that.
353     - .gitlab-ci/test-msvc.bat ${MESON_COMMON_OPTIONS} --wrap-mode=default --default-library=static
354   artifacts:
355     reports:
356       junit: "_build/${env:CI_JOB_NAME}-report.xml"
357     name: "glib-${env:CI_JOB_NAME}-${env:CI_COMMIT_REF_NAME}"
358     when: always
359     paths:
360       - _build/meson-logs
361       - "_build/${env:CI_JOB_NAME}-report.xml"
362
363 freebsd-12-x86_64:
364   # The FreeBSD 13 build is run on each commit, so the FreeBSD 12 build can be
365   # run less regularly to save CI resources. The chance of a regression on
366   # FreeBSD 12 and not FreeBSD 13 is tiny.
367   extends: .only-schedules
368   stage: build
369   tags:
370     # To run a FreeBSD builder, install gitlab-runner package and start both
371     # gitlab-runner and dbus service because we need /var/lib/dbus/machine-id.
372     # To compile GLib, you still have to install the following packages:
373     # desktop-file-utils gettext libiconv meson pkgconf python3 shared-mime-info
374     - freebsd-12
375   needs: []
376   variables:
377     # CPPFLAGS is required because libintl doesn't use pkg-config.
378     CPPFLAGS: -I/usr/local/include
379     # FIXME: Workaround meson inability to set LD_LIBRARY_PATH.
380     # https://github.com/mesonbuild/meson/issues/1383
381     # https://github.com/mesonbuild/meson/issues/1635
382     # https://github.com/mesonbuild/meson/issues/2881
383     LDFLAGS: -L/usr/local/lib -Wl,--disable-new-dtags
384     # FreeBSD supports C.UTF-8 locale since 12.1.
385     LANG: C.UTF-8
386   before_script:
387     - bash .gitlab-ci/show-execution-environment.sh
388   script:
389     # We cannot use -Wl,--no-undefined because GLib uses 'environ' variable.
390     # FreeBSD iconv doesn't handle transliteration, so we use (external) GNU libiconv here.
391     # FreeBSD supports xattr, but its API is different from Linux xattr.
392     # FIXME: extattr(2) support: https://gitlab.gnome.org/GNOME/glib/issues/1404
393     # localstatedir is needed for access to /var/lib/dbus/machine-id
394     - meson ${MESON_COMMON_OPTIONS} --localstatedir=/var -Db_lundef=false -Diconv=external -Dxattr=false _build
395     - ninja -C _build
396     - bash -x ./.gitlab-ci/run-tests.sh
397   artifacts:
398     reports:
399       junit: "_build/${CI_JOB_NAME}-report.xml"
400     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
401     when: always
402     paths:
403       - "_build/config.h"
404       - "_build/glib/glibconfig.h"
405       - "_build/meson-logs"
406       - "_build/${CI_JOB_NAME}-report.xml"
407
408 freebsd-13-x86_64:
409   extends: .only-origin
410   stage: build
411   tags:
412     - freebsd-13
413   needs: []
414   variables:
415     CPPFLAGS: -I/usr/local/include
416     LDFLAGS: -L/usr/local/lib -Wl,--disable-new-dtags
417     LANG: C.UTF-8
418   before_script:
419     - bash .gitlab-ci/show-execution-environment.sh
420   script:
421     - meson ${MESON_COMMON_OPTIONS} --localstatedir=/var -Db_lundef=false -Diconv=external -Dxattr=false _build
422     - ninja -C _build
423     - bash -x ./.gitlab-ci/run-tests.sh
424   artifacts:
425     reports:
426       junit: "_build/${CI_JOB_NAME}-report.xml"
427     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
428     when: always
429     paths:
430       - "_build/config.h"
431       - "_build/glib/glibconfig.h"
432       - "_build/meson-logs"
433       - "_build/${CI_JOB_NAME}-report.xml"
434
435 macos:
436   extends: .only-origin
437   stage: build
438   tags:
439     - macos
440   needs: []
441   before_script:
442     - bash .gitlab-ci/show-execution-environment.sh
443     - pip3 install --user meson==0.60.1
444     - pip3 install --user ninja
445     - export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
446   script:
447     # FIXME: Use --wrap-mode=default so we download dependencies each time,
448     # until the macOS runner is a VM where we can use a pre-made image which
449     # already contains the dependencies. See:
450     #  - https://gitlab.gnome.org/GNOME/glib/merge_requests/388
451     #  - https://gitlab.gnome.org/Infrastructure/Infrastructure/issues/225
452     - meson ${MESON_COMMON_OPTIONS}
453             --wrap-mode=default
454             --werror
455             _build
456     - ninja -C _build
457     - .gitlab-ci/run-tests.sh
458   artifacts:
459     reports:
460       junit: "_build/${CI_JOB_NAME}-report.xml"
461     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
462     when: always
463     paths:
464       - "_build/config.h"
465       - "_build/glib/glibconfig.h"
466       - "_build/meson-logs"
467       - "_build/${CI_JOB_NAME}-report.xml"
468
469 coverage:
470   extends: .only-default
471   image: $FEDORA_IMAGE
472   stage: coverage
473   needs: ['fedora-x86_64', 'msys2-mingw32']
474   artifacts:
475     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
476     paths:
477       - _coverage/
478   before_script:
479     - bash .gitlab-ci/show-execution-environment.sh
480   script:
481     - bash -x ./.gitlab-ci/coverage-docker.sh
482   coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
483
484 scan-build:
485   extends:
486     - .build-linux
487     - .only-schedules
488   image: $FEDORA_IMAGE
489   stage: analysis
490   needs: []
491   script:
492     - meson ${MESON_COMMON_OPTIONS}
493             --werror
494             --default-library=both
495             --prefix=$HOME/glib-installed
496             --localstatedir=/var
497             --libdir=lib
498             -Dsystemtap=true
499             -Ddtrace=true
500             -Dinstalled_tests=true
501             _scan_build
502     - ninja -C _scan_build scan-build
503   artifacts:
504     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
505     when: always
506     paths:
507       - "_scan_build/meson-logs/scanbuild"
508
509 coverity:
510   extends:
511     - .build-linux
512     - .only-schedules
513   image: $COVERITY_IMAGE
514   stage: analysis
515   needs: []
516   variables:
517     # cov-build doesn’t like GLIB_DEPRECATED_ENUMERATOR
518     CFLAGS: '-DGLIB_DISABLE_DEPRECATION_WARNINGS'
519   script:
520     - meson ${MESON_COMMON_OPTIONS}
521             --werror
522             --default-library=both
523             --prefix=$HOME/glib-installed
524             --localstatedir=/var
525             --libdir=lib
526             -Dsystemtap=true
527             -Ddtrace=true
528             -Dinstalled_tests=true
529             _coverity_build
530     - $HOME/cov-analysis-linux64-*/bin/cov-build --dir cov-int ninja -C _coverity_build
531     - tar cfz cov-int.tar.gz cov-int
532     - curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
533            --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
534            --form file=@cov-int.tar.gz --form version="$CI_COMMIT_SHA"
535            --form description="$CI_COMMIT_SHA / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
536   artifacts:
537     name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
538     when: always
539     paths:
540       - "cov-int/build-log.txt"
541
542 pages:
543   stage: deploy
544   only:
545     - main
546   needs: ['coverage', 'style-check-diff']
547   script:
548     - mv _coverage/ public/
549   artifacts:
550     paths:
551       - public
552
553 dist-job:
554   image: $FEDORA_IMAGE
555   stage: build
556   only:
557     - tags
558   script:
559     # FIXME: Cannot use MESON_COMMON_OPTIONS here because meson warns about gtkdoc
560     # feature fully functional in 0.54, but we only depend on 0.52. So we cannot build
561     # with --fatal-meson-warnings.
562     - meson ${MESON_COMMON_OPTIONS_NO_WARNING} --buildtype release -Dgtk_doc=true -Dman=true _build
563     - cd _build
564     - ninja dist
565     - ninja glib-doc gobject-doc gio-doc
566     - tar -c -J -f "glib-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/glib html
567     - tar -c -J -f "gobject-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gobject html
568     - tar -c -J -f "gio-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gio html
569   artifacts:
570     paths:
571       - "${CI_PROJECT_DIR}/_build/glib-docs-$CI_COMMIT_TAG.tar.xz"
572       - "${CI_PROJECT_DIR}/_build/gobject-docs-$CI_COMMIT_TAG.tar.xz"
573       - "${CI_PROJECT_DIR}/_build/gio-docs-$CI_COMMIT_TAG.tar.xz"
574       - "${CI_PROJECT_DIR}/_build/meson-dist/glib-*.tar.xz"