summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 7d14dc617c21cfa45699f34f5023e05f2dfeb0e0 (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
stages:
  - build
  - coverage
  - analysis
  - deploy
  - report

cache:
  paths:
    - _ccache/

variables:
  FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v20"
  COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v7"
  DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v14"
  MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v10"
  MESON_TEST_TIMEOUT_MULTIPLIER: 4
  G_MESSAGES_DEBUG: all
  MESON_COMMON_OPTIONS: "--buildtype debug --wrap-mode=nodownload --fatal-meson-warnings"

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

# Some jobs run on CI runners which don’t have good isolation between CI jobs,
# and don’t have much available resource. Limit those jobs to only ones on the
# origin repository (GNOME/glib), rather than people’s forks. Code in the origin
# repository can be trusted.
.only-origin:
  only:
    - branches@GNOME/glib
  except:
    - tags

# 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.
.only-schedules:
  only:
    - schedules
  except:
    - tags

.build-linux:
  before_script:
    - bash .gitlab-ci/show-execution-environment.sh
    - cp -r $HOME/subprojects/* subprojects/

installed-tests:
  extends:
    - .build-linux
    - .only-schedules
  image: $FEDORA_IMAGE
  stage: build
  needs: []
  script:
    # dtrace is disabled because it breaks the static-link.py test
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            --prefix=/usr --libdir=/usr/lib64
            -Dinstalled_tests=true
            -Ddefault_library=both
            -Ddtrace=false
            _build
    - ninja -C _build
    - sudo ninja -C _build install
    # Remove old headers, possibly present in current installation
    - sudo rm -f /usr/include/glib-2.0/glib/gurifuncs.h
    - sudo chown -R `id -un`:`id -gn` _build/
    # 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/
            --parallel=0
            glib
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    expire_in: 1 week
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"
      - "_build/installed-tests-report/"

G_DISABLE_ASSERT:
  extends:
    - .build-linux
    - .only-schedules
  image: $FEDORA_IMAGE
  stage: build
  needs: []
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            -Dsystemtap=true
            -Ddtrace=true
            -Dinstalled_tests=true
            -Dglib_assert=false
            _build
    - ninja -C _build
    - bash -x ./.gitlab-ci/run-tests.sh
  artifacts:
    reports:
      junit:
        - _build/meson-logs/testlog.junit.xml
        - _build/meson-logs/testlog-*.junit.xml
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    expire_in: 1 week
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"

valgrind:
  extends:
    - .build-linux
    - .only-schedules
  image: $FEDORA_IMAGE
  stage: analysis
  needs: []
  variables:
    MESON_TEST_TIMEOUT_MULTIPLIER: 15
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            -Dsystemtap=true
            -Ddtrace=true
            -Dinstalled_tests=true
            _build
    - ninja -C _build
    # Valgrind doesn’t work when the soft FD limit is set too high
    # See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2710
    - ulimit -Sn 1024
    - bash -x ./.gitlab-ci/run-tests.sh
                 --setup valgrind
                 --no-suite slow
  artifacts:
    reports:
      junit: "_build/meson-logs/testlog-valgrind.junit.xml"
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    expire_in: 1 week
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"

.cross-build-linux:
  extends: .build-linux
  stage: build
  needs: []
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    expire_in: 1 week
    paths:
      - "_build/meson-logs"


macos:
  extends: .only-origin
  stage: build
  tags:
    - macos
  needs: []
  variables:
    GIT_SUBMODULE_STRATEGY: normal
    # libpcre2 gets built as a subproject, but the default Clang options on
    # macOS limit string lengths to 4095B — pcre2_error.c has a string of length
    # 4380B
    CFLAGS: '-Wno-overlength-strings'
  before_script:
    - bash .gitlab-ci/show-execution-environment.sh
    - pip3 install --user meson==1.0.0
    - pip3 install --user ninja
    - export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
  script:
    # 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
    - meson ${MESON_COMMON_OPTIONS}
            --wrap-mode=default
            --werror
            _build
    - ninja -C _build
    - .gitlab-ci/run-tests.sh
  artifacts:
    reports:
      junit:
        - _build/meson-logs/testlog.junit.xml
        - _build/meson-logs/testlog-*.junit.xml
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    expire_in: 1 week
    paths:
      - "_build/config.h"
      - "_build/glib/glibconfig.h"
      - "_build/meson-logs"

scan-build:
  extends:
    - .build-linux
    - .only-schedules
  image: $FEDORA_IMAGE
  stage: analysis
  needs: []
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            --default-library=both
            --prefix=$HOME/glib-installed
            --localstatedir=/var
            --libdir=lib
            -Dsystemtap=true
            -Ddtrace=true
            -Dinstalled_tests=true
            _scan_build
    - ninja -C _scan_build scan-build
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    expire_in: 1 week
    paths:
      - "_scan_build/meson-logs/scanbuild"

coverity:
  extends:
    - .build-linux
    - .only-schedules
  image: $COVERITY_IMAGE
  stage: analysis
  needs: []
  variables:
    # cov-build doesn’t like GLIB_DEPRECATED_ENUMERATOR
    CFLAGS: '-DGLIB_DISABLE_DEPRECATION_WARNINGS'
  script:
    - meson ${MESON_COMMON_OPTIONS}
            --werror
            --default-library=both
            --prefix=$HOME/glib-installed
            --localstatedir=/var
            --libdir=lib
            -Dsystemtap=true
            -Ddtrace=true
            -Dinstalled_tests=true
            _coverity_build
    - $HOME/cov-analysis-linux64-*/bin/cov-build --dir cov-int ninja -C _coverity_build
    - tar cfz cov-int.tar.gz cov-int
    - curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
           --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
           --form file=@cov-int.tar.gz --form version="$CI_COMMIT_SHA"
           --form description="$CI_COMMIT_SHA / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
  artifacts:
    name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    expire_in: 1 week
    paths:
      - "cov-int/build-log.txt"

dist-job:
  image: $FEDORA_IMAGE
  stage: build
  only:
    - tags
  script:
    # Ignore extra git security checks as we don't care in CI.
    - git config --global --add safe.directory "${PWD}"
    - git submodule update --init
    - for m in $(git submodule foreach -q 'echo $path'); do git config --global --add safe.directory "${PWD}/${m}"; done
    - meson subprojects download
    - 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 -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
  artifacts:
    paths:
      - "${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"
      - "${CI_PROJECT_DIR}/_build/meson-dist/glib-*.tar.xz"

issue-bot:
  stage: report
  image: registry.gitlab.com/gitlab-org/distribution/issue-bot:latest
  script: /issue-bot
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule"
      when: on_failure