summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 8465c87aefbb7670256b47a717c94487f21035a5 (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
# -*- indent-tabs-mode: nil -*-
include:
  - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
  - project: 'freedesktop/ci-templates'
    ref: '98b1218f146a1ec96d65e3ce0041f9a6ec5cb5e6'
    file: '/templates/fedora.yml'

# From https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/master/src/gitlab-ci.tmpl
workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
      when: never
    - if: $CI_COMMIT_BRANCH

variables:
  FDO_UPSTREAM_REPO: 'cairo/cairo'
  FDO_DISTRIBUTION_VERSION: '40'
  FDO_DISTRIBUTION_TAG: '2024-06-06.0'

  # TODO: should probably get its own image at some point instead of reusing the GStreamer one
  # See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/.gitlab-image-tags.yml for latest
  # (This one is from the lastest stable branch since it's likely to stay around unchanged for longer)
  WINDOWS_IMAGE: "registry.freedesktop.org/gstreamer/gstreamer/amd64/windows:2024-03-05.0-1.24"

  DEFAULT_MESON_ARGS: >
    --default-library=both

stages:
  - prep
  - build
  - test

# Global CI policy: This can be used to configure global behaviour our our jobs
default:
  retry:
    max: 2
    when:
      - 'runner_system_failure'
      - 'stuck_or_timeout_failure'
      - 'scheduler_failure'
      - 'api_failure'
  interruptible: true

.ccache_setup:
  variables:
    CCACHE_BASEDIR: "$CI_PROJECT_DIR"
    CCACHE_DIR: "$CI_PROJECT_DIR/ccache"
    CC: "ccache gcc"
    CXX: "ccache g++"
  before_script:
    - mkdir -p ccache
    - ccache --show-stats
  cache:
    # Each job will have it's own cache
    key: "$CI_JOB_NAME"
    paths:
      - ccache/

fedora image:
  extends:
   - '.fdo.container-build@fedora'
  stage: 'prep'
  variables:
    FDO_DISTRIBUTION_PACKAGES: >
      meson
      ninja-build
      ccache
      gcc
      g++
      zlib-devel
      expat-devel
      libpng-devel
      fontconfig-devel
      freetype-devel
      libX11-devel
      libXrender-devel
      glib2-devel
      librsvg2-devel
      gtk2-devel
      poppler-glib-devel
      libspectre-devel
      ghostscript
      pixman-devel
      systemd-devel
      systemd-udev
      expat-devel
      which
      diffutils
      xorg-x11-server-Xvfb
      dejavu-sans-fonts
      dejavu-sans-mono-fonts
      dejavu-serif-fonts
      google-noto-emoji-color-fonts
      google-noto-sans-vf-fonts
      fonttools
      util-linux
      poppler-utils
      clang

.build fedora:
  extends:
    - '.fdo.distribution-image@fedora'
    - '.ccache_setup'
  stage: 'build'
  variables:
    MESON_ARGS: >
      ${DEFAULT_MESON_ARGS}
      ${EXTRA_MESON_ARGS}
      --werror
    CFLAGS: '-Wno-error=deprecated-declarations'
  script:
    - meson setup ${MESON_ARGS} builddir
    - meson compile -C builddir

    # Run test scripts
    - mkdir builddir/src/.libs
    - touch builddir/src/.libs/libfoo.so
    # Run all the tests, except for the big test executable which
    # gets run separately
    - meson test -C builddir --no-suite=slow --print-errorlogs

    - meson install -C builddir
  artifacts:
    expire_in: "7 days"
    when: "always"
    paths:
      - "*"

fedora build shared:
  extends:
    - '.build fedora'
  variables:
    EXTRA_MESON_ARGS: '--default-library=shared'

fedora build static:
  extends:
    - '.build fedora'
  variables:
    EXTRA_MESON_ARGS: '--default-library=static'

fedora build clang:
  extends:
    - '.build fedora'
  variables:
    EXTRA_MESON_ARGS: '--default-library=shared'
  script:
    - export CC=clang
    - meson setup ${MESON_ARGS} builddir
    - meson compile -C builddir

.test fedora:
  dependencies:
    - 'fedora build shared'
  needs:
    - 'fedora build shared'
  extends:
    - '.fdo.distribution-image@fedora'
    - '.ccache_setup'
  stage: 'test'
  artifacts:
    when: 'always'
    expire_in: "7 days"
    paths:
      - builddir/meson-logs/*
      - builddir/test/*.log
      - builddir/test/pdiff/*.log
      - builddir/test/output
    exclude:
      - "builddir/test/**/*.cs"
      - "builddir/test/**/*.trace"

fedora build check-refs.sh:
  extends: '.test fedora'
  script:
    # Check for duplicate reference images
    - ./test/check-refs.sh "$(pwd)/builddir/test/pdiff/perceptualdiff"

test fedora pdf:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_pdf_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-pdf-argb32.txt)
    - export CAIRO_TEST_IGNORE_pdf_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-pdf-rgb24.txt)
    - export CAIRO_TEST_TARGET=pdf
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora ps2:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_ps2_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-ps2-argb32.txt)
    - export CAIRO_TEST_IGNORE_ps2_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-ps2-rgb24.txt)
    - export CAIRO_TEST_TARGET=ps2
    - export CAIRO_TEST_UGLY_HACK_TO_IGNORE_PS_FAILURES=1
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora ps3:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_ps3_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-ps3-argb32.txt)
    - export CAIRO_TEST_IGNORE_ps3_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-ps3-rgb24.txt)
    - export CAIRO_TEST_TARGET=ps3
    - export CAIRO_TEST_UGLY_HACK_TO_IGNORE_PS_FAILURES=1
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora script:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_UGLY_HACK_TO_SOMETIMES_IGNORE_SCRIPT_XCB_HUGE_IMAGE_SHM=1
    - export CAIRO_TEST_IGNORE_script_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-script-argb32.txt)
    - export CAIRO_TEST_TARGET=script
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora image:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_image_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-image-argb32.txt)
    - export CAIRO_TEST_IGNORE_image_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-image-rgb24.txt)
    - export CAIRO_TEST_IGNORE_image16_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-image16-rgb24.txt)
    - export CAIRO_TEST_TARGET=image,image16
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora recording:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_recording_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-recording-argb32.txt)
    - export CAIRO_TEST_IGNORE_recording_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-recording-rgb24.txt)
    - export CAIRO_TEST_TARGET=recording
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora svg:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_svg11_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-svg11-argb32.txt)
    - export CAIRO_TEST_IGNORE_svg11_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-svg11-rgb24.txt)
    - export CAIRO_TEST_TARGET=svg11
    - export CAIRO_BOILERPLATE_OPEN_NO_DAEMON=1
    - export CAIRO_BOILERPLATE_DO_NOT_CRASH_ON_ANY2PPM_ERROR=1
    - export ANY2PPM="timeout 3m ./any2ppm"
    - ulimit -S -s 131072
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora xcb:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_xcb_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-xcb-argb32.txt)
    - export CAIRO_TEST_IGNORE_xcb_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xcb-rgb24.txt)
    - export CAIRO_TEST_IGNORE_xcb_window_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xcb-window-rgb24.txt)
    - export CAIRO_TEST_IGNORE_xcb_window__rgb24=$(tr '\n' ',' < '.gitlab-ci/ignore-xcb-window&-rgb24.txt')
    - export CAIRO_TEST_IGNORE_xcb_render_0_0_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-xcb-render-0-0-argb32.txt)
    - export CAIRO_TEST_IGNORE_xcb_render_0_0_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xcb-render-0-0-rgb24.txt)
    - export CAIRO_TEST_IGNORE_xcb_fallback_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xcb-fallback-rgb24.txt)
    - export CAIRO_TEST_TARGET="xcb,xcb-window,xcb-window&,xcb-render-0_0,xcb-fallback"
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

test fedora xlib:
  extends: '.test fedora'
  script:
    - export CAIRO_TEST_IGNORE_xlib_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-xlib-argb32.txt)
    - export CAIRO_TEST_IGNORE_xlib_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xlib-rgb24.txt)
    - export CAIRO_TEST_IGNORE_xlib_window_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xlib-window-rgb24.txt)
    - export CAIRO_TEST_IGNORE_xlib_render_0_0_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xlib-render-0-0-rgb24.txt)
    - export CAIRO_TEST_IGNORE_xlib_fallback_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-xlib-fallback-rgb24.txt)
    - export CAIRO_TEST_TARGET="xlib,xlib-window,xlib-render-0_0,xlib-fallback"
    - export srcdir=../../test
    - (cd builddir/test && xvfb-run ./cairo-test-suite)

mingw-32 build:
  extends:
    - '.fdo.distribution-image@fedora'
  stage: 'build'
  before_script:
    - dnf install -y 'dnf-command(builddep)'
    - dnf builddep -y mingw32-cairo
    - dnf install -y mingw32-gcc-c++
  script:
    - mkdir builddir
    - cd builddir
    # Test building with FreeType enabled and Fontconfig disabled
    - mingw32-meson --default-library=both -Dfontconfig=disabled
    - ninja install
  artifacts:
    expire_in: "7 days"
    when: "always"
    paths:
      - 'builddir/meson-logs/'

mingw-64 build:
  extends:
    - '.fdo.distribution-image@fedora'
  stage: 'build'
  before_script:
    - dnf install -y 'dnf-command(builddep)'
    - dnf builddep -y mingw64-cairo
    - dnf install -y mingw64-gcc-c++
  script:
    - mkdir builddir
    - cd builddir
    - mingw64-meson --default-library=both
    - ninja install
  artifacts:
    expire_in: "7 days"
    when: "always"
    paths:
      - 'builddir/meson-logs/'

# Based on https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/.gitlab-ci.yml (.build windows)
.build windows:
  image: $WINDOWS_IMAGE
  stage: 'build'
  tags:
    - 'docker'
    - 'windows'
    - '2022'
  timeout: '30min'
  variables:
    MESON_ARGS: >
      ${DEFAULT_MESON_ARGS}
      -Dfontconfig=enabled
      -Dfreetype=enabled
      -Dglib=enabled
      -Dzlib=enabled
      ${EXTRA_MESON_ARGS}
  before_script:
    # Make sure meson is up to date, latest fontconfig requires a newer Meson than what's on the image
    - pip3 install -U meson
  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"

    # Copy GLib from existing subproject cache to avoid downloading it
    # FIXME: no longer cached in GStreamer image, using tarball for now
    #- cd $env:CI_PROJECT_DIR
    #- cp -r C:/subprojects/glib subprojects/

    # For some reason, options are separated by newline instead of space, so we
    # have to replace them first.
    - $env:MESON_ARGS = $env:MESON_ARGS.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 subprojects update --reset &&
        meson build $env:MESON_ARGS &&
        ninja -C build"
  artifacts:
    expire_in: "7 days"
    when: "always"
    paths:
      - 'build/meson-logs/'

vs2019 shared amd64:
  extends: '.build windows'
  variables:
    ARCH: 'amd64'
    EXTRA_MESON_ARGS: '--default-library=shared'

vs2019 static amd64:
  extends: '.build windows'
  variables:
    ARCH: 'amd64'
    EXTRA_MESON_ARGS: '--default-library=static'

vs2019 shared x86:
  extends: '.build windows'
  variables:
    ARCH: 'x86'
    EXTRA_MESON_ARGS: '--default-library=shared'

android arm64 fedora:
  # TODO: should probably build our own image here some day
  # See https://gitlab.freedesktop.org/gstreamer/gstreamer/container_registry/7689 for current images
  image: 'registry.freedesktop.org/gstreamer/gstreamer/amd64/android-fedora:2020-10-22.0-master'
  stage: 'build'
  artifacts:
    name: "${CI_JOB_NAME}_${CI_COMMIT_SHA}"
    expire_in: '5 days'
    when: 'always'
    paths:
      - "build/meson-logs/*.txt"
  before_script:
    - dnf install -y python3-pip gcc ninja-build gperf
    - pip3 install --user meson
  script:
    - export PATH="$HOME/.local/bin:$PATH"
    - |
      cat > android-cross-file.txt <<EOF
      [constants]
      ndk_path    = '/android/ndk'
      toolchain   = ndk_path + '/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android'
      api         = '28'

      [host_machine]
      system      = 'android'
      cpu_family  = 'aarch64'
      cpu         = 'aarch64'
      endian      = 'little'

      [properties]
      sys_root        = ndk_path + '/sysroot'
      c_link_args     = ['-fuse-ld=gold']
      cpp_link_args   = ['-fuse-ld=gold']

      [binaries]
      c           = toolchain + api + '-clang'
      cpp         = toolchain + api + '-clang++'
      ar          = toolchain + '-ar'
      strip       = toolchain + '-strip'
      EOF
    - meson setup --cross-file android-cross-file.txt -Dpixman:a64-neon=disabled build
    - meson compile --verbose -C build

macOS x86 host:
  tags:
    - gst-macos-12.3
  stage: 'build'
  artifacts:
    when: 'always'
    expire_in: "7 days"
    paths:
      - build/meson-logs/*.txt
      - build/meson-private/*.pc
      - build/test/*.log
      - build/test/pdiff/*.log
      - build/test/output
    exclude:
      - "build/test/**/*.cs"
      - "build/test/**/*.trace"
  before_script:
    # Install the DejaVu fonts
    - curl -LO https://downloads.sourceforge.net/dejavu/dejavu-fonts-ttf-2.37.zip
    - unzip dejavu-fonts-ttf-2.37.zip
    - cp dejavu-fonts-ttf-2.37/ttf/*.ttf /Library/Fonts
    # Update pip
    - pip3 install --upgrade pip
    # Make sure meson is up to date
    - pip3 install -U meson
    # Need to install certificates for Python
    - pip3 install --upgrade certifi
    # Anther way to install certificates
    - open /Applications/Python\ 3.8/Install\ Certificates.command
    # Get ninja
    - pip3 install -U ninja
  script:
    - CERT_PATH=$(python3 -m certifi) && export SSL_CERT_FILE=${CERT_PATH} && export REQUESTS_CA_BUNDLE=${CERT_PATH}
    # pixman region-test fails to link on macOS
    - meson setup -Dpixman:tests=disabled build
    - meson compile --verbose -C build
    # Test cairo-quartz. Other backends should be covered by other jobs
    - export CAIRO_TEST_IGNORE_quartz_argb32=$(tr '\n' ',' < .gitlab-ci/ignore-quartz-argb32.txt)
    - export CAIRO_TEST_IGNORE_quartz_rgb24=$(tr '\n' ',' < .gitlab-ci/ignore-quartz-rgb24.txt)
    - export CAIRO_TEST_TARGET=quartz
    - (cd build/test && srcdir=../../test ./cairo-test-suite)