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