.gitlab-ci.yml 15.2 KB
Newer Older
1
stages:
2
  - style-check
3
  - build
4
  - coverage
5
  - analysis
6
  - deploy
7

8 9 10 11
cache:
  paths:
    - _ccache/

12
variables:
13
  FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v9"
14
  DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v6"
15
  ANDROID_IMAGE: "registry.gitlab.gnome.org/gnome/glib/android-ndk:v3"
16
  MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v2"
17
  MESON_TEST_TIMEOUT_MULTIPLIER: 2
18
  G_MESSAGES_DEBUG: all
19 20
  MESON_COMMON_OPTIONS_NO_WARNING: "--buildtype debug --wrap-mode=nodownload"
  MESON_COMMON_OPTIONS: "${MESON_COMMON_OPTIONS_NO_WARNING} --fatal-meson-warnings"
21

22
.only-default:
23 24 25 26 27
  only:
    - branches
  except:
    - tags

28 29 30
.build:
  extends: .only-default
  before_script:
31
    - bash .gitlab-ci/show-execution-environment.sh
32 33
    - cp -r $HOME/subprojects/* subprojects/

34 35 36 37 38 39 40 41
# Some jobs take a long time and are unlikely to find failures (or will find
# failures which are not merge-blockers to fix), so they’re executed on a weekly
# schedule in order to save CI resources and speed up branch pipelines.
.build-only-schedules:
  extends: .build
  only:
    - schedules

42
style-check-diff:
43
  extends: .only-default
44
  image: $DEBIAN_IMAGE
45 46 47
  stage: style-check
  allow_failure: true
  script:
48
    - .gitlab-ci/run-style-check-diff.sh
49

50 51 52 53 54 55 56 57
check-todos:
  extends: .only-default
  image: $DEBIAN_IMAGE
  stage: style-check
  allow_failure: true
  script:
    - .gitlab-ci/run-check-todos.sh

Xavier Claessens's avatar
Xavier Claessens committed
58
fedora-x86_64:
59
  extends: .build
60
  image: $FEDORA_IMAGE
61
  stage: build
62
  variables:
63
    CFLAGS: "-coverage -ftest-coverage -fprofile-arcs"
64
  script:
65 66 67 68
    # FIXME: Cannot use MESON_COMMON_OPTIONS here because meson warns about gtkdoc
    # feature introduced in 0.52 but we only depends on 0.49. So we cannot build
    # with --fatal-meson-warnings.
    - meson ${MESON_COMMON_OPTIONS_NO_WARNING}
69 70 71 72 73 74 75 76
            --werror
            --default-library=both
            --prefix=$HOME/glib-installed
            --libdir=lib
            -Dsystemtap=true
            -Ddtrace=true
            -Dfam=true
            -Dinstalled_tests=true
77
            -Dgtk_doc=true
78
            _build
79
    - ninja -C _build
80
    - mkdir -p _coverage
81
    - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
82
    - .gitlab-ci/run-tests.sh
83
    - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov"
84
  artifacts:
85 86
    reports:
      junit: "_build/${CI_JOB_NAME}-report.xml"
Philip Withnall's avatar
Philip Withnall committed
87
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
88
    when: always
89
    paths:
90 91
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
92
      - "_build/meson-logs"
93 94 95 96 97 98 99 100 101
      - "_build/docs/reference/glib/glib-undeclared.txt"
      - "_build/docs/reference/glib/glib-undocumented.txt"
      - "_build/docs/reference/glib/glib-unused.txt"
      - "_build/docs/reference/gobject/gobject-undeclared.txt"
      - "_build/docs/reference/gobject/gobject-undocumented.txt"
      - "_build/docs/reference/gobject/gobject-unused.txt"
      - "_build/docs/reference/gio/gio-undeclared.txt"
      - "_build/docs/reference/gio/gio-undocumented.txt"
      - "_build/docs/reference/gio/gio-unused.txt"
102
      - "_build/${CI_JOB_NAME}-report.xml"
103
      - "_coverage"
104

Emmanuele Bassi's avatar
Emmanuele Bassi committed
105
debian-stable-x86_64:
106
  extends: .build
107
  image: $DEBIAN_IMAGE
Emmanuele Bassi's avatar
Emmanuele Bassi committed
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
  stage: build
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            --default-library=both
            --prefix=$HOME/glib-installed
            --libdir=lib
            -Dsystemtap=true
            -Ddtrace=true
            -Dfam=true
            -Dinstalled_tests=true
            _build
    - ninja -C _build
    - .gitlab-ci/run-tests.sh
  artifacts:
    reports:
      junit: "_build/${CI_JOB_NAME}-report.xml"
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"
      - "_build/${CI_JOB_NAME}-report.xml"

133
installed-tests:
134
  extends: .build-only-schedules
135
  image: $FEDORA_IMAGE
136 137 138 139 140 141 142 143 144 145 146 147 148
  stage: build
  script:
    # dtrace is disabled because it breaks the static-link.py test
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            --prefix=/usr --libdir=/usr/lib64
            -Dfam=true
            -Dinstalled_tests=true
            -Ddefault_library=both
            -Ddtrace=false
            _build
    - ninja -C _build
    - sudo ninja -C _build install
149 150
    # Remove old headers, possibly present in current installation
    - sudo rm -f /usr/include/glib-2.0/glib/gurifuncs.h
151
    - sudo chown -R `id -un`:`id -gn` _build/
152 153 154
    # FIXME Install newer xdg-desktop-portal with
    # GMemoryMonitor support, see:
    # https://github.com/flatpak/xdg-desktop-portal/pull/365
155
    - git clone --single-branch https://github.com/flatpak/xdg-desktop-portal.git
156
    - cd xdg-desktop-portal
157
    - git reset --hard 1.6.0
158 159 160
    - ./autogen.sh --prefix=/usr --libdir=/usr/lib64 --disable-libportal --disable-dependency-tracking
    - make
    - sudo make install
161 162 163 164
    - cd ..
    # FIXME install newer gobject-introspection
    # with GMemoryMonitor support, see:
    # https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/193
165
    - git clone --single-branch https://gitlab.gnome.org/GNOME/gobject-introspection.git
166 167 168 169 170
    - cd gobject-introspection
    - /usr/bin/meson _build --prefix=/usr --libdir=/usr/lib64
    - ninja -C _build
    - sudo ninja -C _build install
    - cd ..
171 172
    # Work-around https://gitlab.gnome.org/GNOME/gnome-desktop-testing/merge_requests/2
    - mkdir -p _build/installed-tests-report/logs/
173
    - GLIB_TEST_COMPILATION=1 gnome-desktop-testing-runner
174
            --report-directory=_build/installed-tests-report/failed/
175
            --log-directory=_build/installed-tests-report/logs/
176
            --parallel=0
177 178 179 180 181 182 183 184 185 186
            glib
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"
      - "_build/installed-tests-report/"

187
G_DISABLE_ASSERT:
188
  extends: .build-only-schedules
189
  image: $FEDORA_IMAGE
190 191 192 193 194 195 196 197
  stage: build
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            -Dsystemtap=true
            -Ddtrace=true
            -Dfam=true
            -Dinstalled_tests=true
198
            -Dglib_assert=false
199 200
            _build
    - ninja -C _build
201
    - bash -x ./.gitlab-ci/run-tests.sh
202
  artifacts:
203 204
    reports:
      junit: "_build/${CI_JOB_NAME}-report.xml"
205 206 207 208 209 210
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"
211
      - "_build/${CI_JOB_NAME}-report.xml"
212

213
valgrind:
214
  extends: .build-only-schedules
215
  image: $FEDORA_IMAGE
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
  stage: analysis
  variables:
    MESON_TEST_TIMEOUT_MULTIPLIER: 10
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            -Dsystemtap=true
            -Ddtrace=true
            -Dfam=true
            -Dinstalled_tests=true
            _build
    - ninja -C _build
    - bash -x ./.gitlab-ci/run-tests.sh
                 --log-file _build/meson-logs/testlog-valgrind.json
                 --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"
                 --no-suite no-valgrind
                 --no-suite slow
  # FIXME: Remove this when we have zero valgrind leaks.
  # https://gitlab.gnome.org/GNOME/glib/issues/333
  allow_failure: true
  artifacts:
    reports:
      junit: "_build/${CI_JOB_NAME}-report.xml"
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"

246
.cross-template: &cross-template
247
  extends: .build
Xavier Claessens's avatar
Xavier Claessens committed
248 249
  stage: build
  artifacts:
250 251
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
Xavier Claessens's avatar
Xavier Claessens committed
252
    paths:
253
      - "_build/meson-logs"
Xavier Claessens's avatar
Xavier Claessens committed
254

255 256
cross-android_api21_arm64:
  <<: *cross-template
257
  image: $ANDROID_IMAGE
258 259
  script:
    # FIXME: add --werror
260 261 262
    # We use -Diconv=auto to test that we successfully detect that iconv is not
    # provided by android api 21, and detect the external iconv instead.
    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_21.txt -Diconv=auto -Dinternal_pcre=true _build
263 264
    - ninja -C _build

265 266
cross-android_api28_arm64:
  <<: *cross-template
267
  image: $ANDROID_IMAGE
268 269
  script:
    # FIXME: add --werror
270
    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt -Dinternal_pcre=true _build
271 272
    - ninja -C _build

Xavier Claessens's avatar
Xavier Claessens committed
273
cross-mingw64:
274
  <<: *cross-template
275
  image: $MINGW_IMAGE
Xavier Claessens's avatar
Xavier Claessens committed
276 277
  script:
    # FIXME: Add --werror
278
    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_mingw64.txt _build
Xavier Claessens's avatar
Xavier Claessens committed
279 280
    - ninja -C _build

281
msys2-mingw32:
282
  extends: .only-default
283 284
  stage: build
  tags:
285
    - win32-ps
286 287 288 289 290
  variables:
    MSYSTEM: "MINGW32"
    CHERE_INVOKING: "yes"
  script:
    - C:\msys64\usr\bin\pacman --noconfirm -Syyuu --ask 20
291
    - C:\msys64\usr\bin\bash .gitlab-ci/show-execution-environment.sh
292
    - C:\msys64\usr\bin\bash -lc "bash -x ./.gitlab-ci/test-msys2.sh"
293
  artifacts:
294
    reports:
295 296
      junit: "_build/${env:CI_JOB_NAME}-report.xml"
    name: "glib-${env:CI_JOB_NAME}-${env:CI_COMMIT_REF_NAME}"
297
    when: always
298
    paths:
299
      - _build/meson-logs
300
      - "_build/${env:CI_JOB_NAME}-report.xml"
301 302
      - _coverage/

Christoph Reiter's avatar
Christoph Reiter committed
303
vs2017-x64:
304
  extends: .only-default
Christoph Reiter's avatar
Christoph Reiter committed
305 306
  stage: build
  tags:
307
    - win32-ps
Christoph Reiter's avatar
Christoph Reiter committed
308 309 310
  script:
    - .gitlab-ci/test-msvc.bat
  artifacts:
311
    reports:
312 313
      junit: "_build/${env:CI_JOB_NAME}-report.xml"
    name: "glib-${env:CI_JOB_NAME}-${env:CI_COMMIT_REF_NAME}"
Christoph Reiter's avatar
Christoph Reiter committed
314 315 316
    when: always
    paths:
      - _build/meson-logs
317
      - "_build/${env:CI_JOB_NAME}-report.xml"
Christoph Reiter's avatar
Christoph Reiter committed
318

Ting-Wei Lan's avatar
Ting-Wei Lan committed
319 320
freebsd-11-x86_64:
  stage: build
321 322
  only:
    - branches@GNOME/glib
Ting-Wei Lan's avatar
Ting-Wei Lan committed
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
  tags:
    # To run a FreeBSD builder, install gitlab-runner package and start both
    # gitlab-runner and dbus service because we need /var/lib/dbus/machine-id.
    # To compile GLib, you still have to install the following packages:
    # desktop-file-utils gettext libiconv meson pkgconf python3 shared-mime-info
    - freebsd-11
  variables:
    # CPPFLAGS is required because libintl doesn't use pkg-config.
    CPPFLAGS: -I/usr/local/include
    # FIXME: Workaround meson inability to set LD_LIBRARY_PATH.
    # https://github.com/mesonbuild/meson/issues/1383
    # https://github.com/mesonbuild/meson/issues/1635
    # https://github.com/mesonbuild/meson/issues/2881
    LDFLAGS: -L/usr/local/lib -Wl,--disable-new-dtags
    # FreeBSD doesn't have C.UTF-8 locale.
    LANG: en_US.UTF-8
339 340
  before_script:
    - bash .gitlab-ci/show-execution-environment.sh
Ting-Wei Lan's avatar
Ting-Wei Lan committed
341 342
  script:
    # We cannot use -Wl,--no-undefined because GLib uses 'environ' variable.
343
    # FreeBSD iconv doesn't handle transliteration, so we use (external) GNU libiconv here.
Ting-Wei Lan's avatar
Ting-Wei Lan committed
344 345
    # FreeBSD supports xattr, but its API is different from Linux xattr.
    # FIXME: extattr(2) support: https://gitlab.gnome.org/GNOME/glib/issues/1404
346
    - meson ${MESON_COMMON_OPTIONS} -Db_lundef=false -Diconv=external -Dxattr=false _build
Ting-Wei Lan's avatar
Ting-Wei Lan committed
347
    - ninja -C _build
348
    - bash -x ./.gitlab-ci/run-tests.sh
Ting-Wei Lan's avatar
Ting-Wei Lan committed
349
  artifacts:
Ting-Wei Lan's avatar
Ting-Wei Lan committed
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
    reports:
      junit: "_build/${CI_JOB_NAME}-report.xml"
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"
      - "_build/${CI_JOB_NAME}-report.xml"

freebsd-12-x86_64:
  stage: build
  only:
    - branches@GNOME/glib
  tags:
    - freebsd-12
  variables:
    CPPFLAGS: -I/usr/local/include
    LDFLAGS: -L/usr/local/lib -Wl,--disable-new-dtags
    LANG: en_US.UTF-8
370 371
  before_script:
    - bash .gitlab-ci/show-execution-environment.sh
Ting-Wei Lan's avatar
Ting-Wei Lan committed
372 373 374 375 376 377
  script:
    - meson ${MESON_COMMON_OPTIONS} -Db_lundef=false -Diconv=external -Dxattr=false _build
    - ninja -C _build
    - bash -x ./.gitlab-ci/run-tests.sh
  except:
    - tags
Philip Withnall's avatar
Philip Withnall committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
  artifacts:
    reports:
      junit: "_build/${CI_JOB_NAME}-report.xml"
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"
      - "_build/${CI_JOB_NAME}-report.xml"

macos:
  extends: .only-default
  stage: build
  only:
    - branches@GNOME/glib
  tags:
    - macos
  before_script:
397
    - bash .gitlab-ci/show-execution-environment.sh
Philip Withnall's avatar
Philip Withnall committed
398 399 400 401 402
    - pip3 install --user meson==0.49.2
    - pip3 install --user ninja
    - export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
  script:
    # FIXME: Add --werror
403 404 405 406 407
    # FIXME: Use --wrap-mode=default so we download dependencies each time,
    # until the macOS runner is a VM where we can use a pre-made image which
    # already contains the dependencies. See:
    #  - https://gitlab.gnome.org/GNOME/glib/merge_requests/388
    #  - https://gitlab.gnome.org/Infrastructure/Infrastructure/issues/225
Philip Withnall's avatar
Philip Withnall committed
408
    - meson ${MESON_COMMON_OPTIONS}
409
            --wrap-mode=default
Philip Withnall's avatar
Philip Withnall committed
410 411 412 413
            _build
    - ninja -C _build
    # FIXME: Multiple unit tests currently fails
    - .gitlab-ci/run-tests.sh || true
Ting-Wei Lan's avatar
Ting-Wei Lan committed
414
  artifacts:
415 416
    reports:
      junit: "_build/${CI_JOB_NAME}-report.xml"
Ting-Wei Lan's avatar
Ting-Wei Lan committed
417 418 419
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
Ting-Wei Lan's avatar
Ting-Wei Lan committed
420 421
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
Ting-Wei Lan's avatar
Ting-Wei Lan committed
422
      - "_build/meson-logs"
423
      - "_build/${CI_JOB_NAME}-report.xml"
Ting-Wei Lan's avatar
Ting-Wei Lan committed
424

425
coverage:
426
  extends: .only-default
427
  image: $FEDORA_IMAGE
428 429
  stage: coverage
  artifacts:
Philip Withnall's avatar
Philip Withnall committed
430
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
431 432
    paths:
      - _coverage/
433 434
  before_script:
    - bash .gitlab-ci/show-execution-environment.sh
435 436
  script:
    - bash -x ./.gitlab-ci/coverage-docker.sh
437
  coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
438

439
scan-build:
440
  extends: .build-only-schedules
441
  image: $FEDORA_IMAGE
442 443 444 445 446 447 448 449 450 451 452
  stage: analysis
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            --default-library=both
            --prefix=$HOME/glib-installed
            --libdir=lib
            -Dsystemtap=true
            -Ddtrace=true
            -Dfam=true
            -Dinstalled_tests=true
453 454
            _scan_build
    - ninja -C _scan_build scan-build
455 456 457 458
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
459
      - "_scan_build/meson-logs/scanbuild"
460

461 462
pages:
  stage: deploy
463 464
  only:
    - master
465 466 467 468 469
  script:
    - mv _coverage/ public/
  artifacts:
    paths:
      - public
470

471
dist-job:
472
  image: $FEDORA_IMAGE
473 474 475 476
  stage: build
  only:
    - tags
  script:
477 478 479
    # FIXME: Cannot use --fatal-meson-warnings here because meson warns about gtkdoc
    # feature introduced in 0.52 but we only depends on 0.49.
    - meson ${MESON_COMMON_OPTIONS_NO_WARNING} --buildtype release -Dgtk_doc=true -Dman=true _build
480 481
    - cd _build
    - ninja dist
482
    - ninja glib-doc gobject-doc gio-doc
483 484 485
    - tar -c -J -f "glib-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/glib html
    - tar -c -J -f "gobject-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gobject html
    - tar -c -J -f "gio-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gio html
486 487
  artifacts:
    paths:
488 489 490
      - "${CI_PROJECT_DIR}/_build/glib-docs-$CI_COMMIT_TAG.tar.xz"
      - "${CI_PROJECT_DIR}/_build/gobject-docs-$CI_COMMIT_TAG.tar.xz"
      - "${CI_PROJECT_DIR}/_build/gio-docs-$CI_COMMIT_TAG.tar.xz"
491
      - "${CI_PROJECT_DIR}/_build/meson-dist/glib-*.tar.xz"