summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: d7567c7f97d4251746ab57f2b4c8fe378255ea73 (plain)
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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
stages:
  - style-check
  - build
  - coverage
  - analysis
  - deploy

cache:
  paths:
    - _ccache/

variables:
  FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v6"
  DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v6"
  ANDROID_IMAGE: "registry.gitlab.gnome.org/gnome/glib/android-ndk:v2"
  MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v2"
  WINDOWS_IMAGE: "registry.gitlab.gnome.org/gnome/glib/windows:v2"
  MESON_TEST_TIMEOUT_MULTIPLIER: 2
  G_MESSAGES_DEBUG: all
  MESON_COMMON_OPTIONS: "--buildtype debug --fatal-meson-warnings --wrap-mode=nodownload"

.only-default:
  only:
    - branches
  except:
    - tags

.build:
  extends: .only-default
  before_script:
    - cp -r $HOME/subprojects/* subprojects/

style-check-diff:
  extends: .only-default
  image: $DEBIAN_IMAGE
  stage: style-check
  allow_failure: true
  script:
    - .gitlab-ci/run-style-check-diff.sh

fedora-x86_64:
  extends: .build
  image: $FEDORA_IMAGE
  stage: build
  variables:
    CFLAGS: "-coverage -ftest-coverage -fprofile-arcs"
  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
    - mkdir -p _coverage
    - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
    - .gitlab-ci/run-tests.sh
    - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov"
  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"
      - "_coverage"

debian-stable-x86_64:
  extends: .build
  image: $DEBIAN_IMAGE
  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"

installed-tests:
  extends: .build
  image: $FEDORA_IMAGE
  stage: build
  script:
    # FIXME Install xdg-desktop-portal build deps before compiling glib,
    # so it doesn't overwrite our own glib build
    - sudo dnf install -y autoconf automake gettext-devel libtool diffutils fontconfig-devel json-glib-devel geoclue2-devel pipewire-devel fuse-devel make
    # 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
    - sudo chown -R `id -un`:`id -gn` _build/
    # FIXME Install newer xdg-desktop-portal with
    # GMemoryMonitor support, see:
    # https://github.com/flatpak/xdg-desktop-portal/pull/365
    - git clone --single-branch https://github.com/flatpak/xdg-desktop-portal.git
    - cd xdg-desktop-portal
    - ./autogen.sh --prefix=/usr --libdir=/usr/lib64 --disable-libportal --disable-dependency-tracking && make && sudo make install
    - cd ..
    # FIXME install newer gobject-introspection
    # with GMemoryMonitor support, see:
    # https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/193
    - sudo dnf install -y meson flex bison python3-devel
    - git clone --single-branch https://gitlab.gnome.org/GNOME/gobject-introspection.git
    - cd gobject-introspection
    - /usr/bin/meson _build --prefix=/usr --libdir=/usr/lib64
    - ninja -C _build
    - sudo ninja -C _build install
    - cd ..
    # FIXME: Add update until stable https://bodhi.fedoraproject.org/updates/FEDORA-2019-e830287661
    - sudo dnf upgrade -y --enablerepo=updates-testing --advisory=FEDORA-2019-e830287661
    # FIXME: Add update until stable https://bodhi.fedoraproject.org/updates/FEDORA-2019-161b129d4d
    - sudo dnf upgrade -y --enablerepo=updates-testing --advisory=FEDORA-2019-161b129d4d
    # Work-around https://gitlab.gnome.org/GNOME/gnome-desktop-testing/merge_requests/2
    - mkdir -p _build/installed-tests-report/logs/
    - GLIB_TEST_COMPILATION=1 gnome-desktop-testing-runner
            --report-directory=_build/installed-tests-report/failed/
            --log-directory=_build/installed-tests-report/logs/
            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/"

G_DISABLE_ASSERT:
  extends: .build
  image: $FEDORA_IMAGE
  stage: build
  variables:
    CPPFLAGS: "-DG_DISABLE_ASSERT"
  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
  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"

valgrind:
  extends: .build
  image: $FEDORA_IMAGE
  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"

.cross-template: &cross-template
  extends: .build
  stage: build
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/meson-logs"

cross-android_api21_arm64:
  <<: *cross-template
  image: $ANDROID_IMAGE
  script:
    # FIXME: add --werror
    # 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
    - ninja -C _build

cross-android_api28_arm64:
  <<: *cross-template
  image: $ANDROID_IMAGE
  script:
    # FIXME: add --werror
    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt -Dinternal_pcre=true _build
    - ninja -C _build

cross-mingw64:
  <<: *cross-template
  image: $MINGW_IMAGE
  script:
    # FIXME: Add --werror
    - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_mingw64.txt _build
    - ninja -C _build

msys2-mingw32:
  extends: .only-default
  stage: build
  tags:
    - win32
  variables:
    MSYSTEM: "MINGW32"
    CHERE_INVOKING: "yes"
  script:
    - C:\msys64\usr\bin\pacman --noconfirm -Syyuu --ask 20
    - C:\msys64\usr\bin\bash -lc "bash -x ./.gitlab-ci/test-msys2.sh"
  artifacts:
    reports:
      junit: "_build/%CI_JOB_NAME%-report.xml"
    name: "glib-%CI_JOB_NAME%-%CI_COMMIT_REF_NAME%"
    when: always
    paths:
      - _build/meson-logs
      - "_build/%CI_JOB_NAME%-report.xml"
      - _coverage/

vs2017-x64:
  extends: .only-default
  image: $WINDOWS_IMAGE
  stage: build
  tags:
    - windows
  script:
    # Make sure powershell exists on errors
    # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-6
    - $ErrorActionPreference = "Stop"
    - cp -r C:/subprojects/* subprojects/
    - pip install --upgrade meson
    # For some reason, options are separated by newline instead of space, so we
    # have to replace them first.
    - $env:MESON_COMMON_OPTIONS = $env:MESON_COMMON_OPTIONS.replace("`n"," ")
    # Gitlab executes PowerShell in docker, but VsDevCmd.bat is a batch script.
    # Environment variables substitutions is done by PowerShell before calling
    # cmd.exe, that's why we use $env:FOO instead of %FOO%
    - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
        meson build $env:MESON_COMMON_OPTIONS &&
        ninja -C build"
  artifacts:
    reports:
      junit: "_build/%CI_JOB_NAME%-report.xml"
    name: "glib-%CI_JOB_NAME%-%CI_COMMIT_REF_NAME%"
    when: always
    paths:
      - _build/meson-logs
      - "_build/%CI_JOB_NAME%-report.xml"

freebsd-11-x86_64:
  stage: build
  only:
    - branches@GNOME/glib
  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
  script:
    # We cannot use -Wl,--no-undefined because GLib uses 'environ' variable.
    # FreeBSD iconv doesn't handle transliteration, so we use (external) GNU libiconv here.
    # FreeBSD supports xattr, but its API is different from Linux xattr.
    # FIXME: extattr(2) support: https://gitlab.gnome.org/GNOME/glib/issues/1404
    - meson ${MESON_COMMON_OPTIONS} -Db_lundef=false -Diconv=external -Dxattr=false _build
    - ninja -C _build
    - bash -x ./.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"

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
  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
  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:
    - 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
    - meson ${MESON_COMMON_OPTIONS}
            _build
    - ninja -C _build
    # FIXME: Multiple unit tests currently fails
    - .gitlab-ci/run-tests.sh || 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"
      - "_build/${CI_JOB_NAME}-report.xml"

coverage:
  extends: .only-default
  image: $FEDORA_IMAGE
  stage: coverage
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    paths:
      - _coverage/
  script:
    - bash -x ./.gitlab-ci/coverage-docker.sh
  coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'

scan-build:
  extends: .build
  image: $FEDORA_IMAGE
  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
            _scan_build
    - ninja -C _scan_build scan-build
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_scan_build/meson-logs/scanbuild"

pages:
  stage: deploy
  only:
    - master
  script:
    - mv _coverage/ public/
  artifacts:
    paths:
      - public

dist-job:
  image: $FEDORA_IMAGE
  stage: build
  only:
    - tags
  script:
    - meson ${MESON_COMMON_OPTIONS} --buildtype release -Dgtk_doc=true -Dman=true _build
    - cd _build
    - ninja dist
    - ninja glib-doc gobject-doc gio-doc
    - tar -c -f "glib-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/glib html
    - tar -c -f "gobject-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gobject html
    - tar -c -f "gio-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gio html
  artifacts:
    paths:
      - "${CI_PROJECT_DIR}/_build/glib-docs.tar.xz"
      - "${CI_PROJECT_DIR}/_build/gobject-docs.tar.xz"
      - "${CI_PROJECT_DIR}/_build/gio-docs.tar.xz"
      - "${CI_PROJECT_DIR}/_build/meson-dist/glib-*.tar.xz"