summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: b1eb777260e4207cab8d881aa23305030c3b2f70 (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
variables:

stages:
  - style-check
  - build
  - analysis
  - docs
  - deploy

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

style-check-diff:
  extends: .only-default
  image: fedora:latest
  stage: style-check
  script:
    - dnf install -y clang-tools-extra curl diffutils git
    - sh -x ./.gitlab-ci/run-style-check.sh

# Recipe for setting up the build
# @PROJECT_DEPS: the dependencies of the project (on Fedora)
# @MESON_VERSION: the version of Meson required by the project
.build-setup:
  image: fedora:latest
  extends: .only-default
  before_script:
    # Undo delangification present in the Fedora Docker images
    - rm -f /etc/rpm/macros.image-language-conf
    - dnf reinstall -y glib2 glibc || dnf update -y glib2 glibc
    # Add French locale support for tests
    - dnf install -y glibc-langpack-fr
    - dnf install -y ${PROJECT_DEPS}
    - pip3 install --user meson==${MESON_VERSION}
    - export PATH="$PATH:$HOME/.local/bin"

# Default build recipe
# @PROJECT_DEPS: the dependencies of the project (on Fedora)
# @MESON_VERSION: the version of Meson required by the project
# @MESON_EXTRA_FLAGS: extra arguments for the meson setup invocation
.build-default:
  image: fedora:latest
  extends: .only-default
  before_script:
    # Undo delangification present in the Fedora Docker images
    - rm -f /etc/rpm/macros.image-language-conf
    - dnf reinstall -y glib2 glibc || dnf update -y glib2 glibc
    # Add French locale support for tests
    - dnf install -y glibc-langpack-fr
    - dnf install -y ${PROJECT_DEPS}
    - pip3 install --user meson==${MESON_VERSION}
    - export PATH="$PATH:$HOME/.local/bin"
  script:
    - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build .
    - meson compile -C _build
    - meson install -C _build
    - meson test -C _build --no-suite=style
  artifacts:
    reports:
      junit: "_build/meson-logs/testlog.junit.xml"
    when: always
    name: "libgweather-${CI_COMMIT_REF_NAME}"
    paths:
      - "${CI_PROJECT_DIR}/_build/meson-logs"
      - "${CI_PROJECT_DIR}/_build/libgweather/GWeather-4.0.gir"
      - "${CI_PROJECT_DIR}/_build/libgweather/gweather4.vapi"

# Inherit to build the API reference via gi-docgen
# @PROJECT_DEPS: the dependencies of the project (on Fedora)
# @MESON_VERSION: the version of Meson required by the project
# @MESON_EXTRA_FLAGS: extra arguments for the meson setup invocation
# @DOCS_FLAGS: doc-related arguments for the meson setup invocation
# @DOCS_PATH: the docs output directory under the build directory
.gidocgen-build:
  image: fedora:latest
  before_script:
    - export PATH="$HOME/.local/bin:$PATH"
    - dnf install -y python3 python3-pip python3-wheel gobject-introspection-devel graphviz ninja-build redhat-rpm-config
    - dnf install -y ${PROJECT_DEPS}
    - pip3 install --user meson==${MESON_VERSION} gi-docgen jinja2 Markdown markupsafe pygments toml typogrify
  script:
    - meson setup ${MESON_EXTRA_FLAGS} ${DOCS_FLAGS} _docs .
    - meson compile -C _docs
    - |
      pushd "_docs/${DOCS_PATH}" > /dev/null
      tar cf ${CI_PROJECT_NAME}-docs.tar .
      popd > /dev/null
    - mv _docs/${DOCS_PATH}/${CI_PROJECT_NAME}-docs.tar .
  artifacts:
    when: always
    name: 'Documentation'
    expose_as: 'Download the API reference'
    paths:
      - ${CI_PROJECT_NAME}-docs.tar

fedora-x86_64:
  extends: .build-default
  stage: build
  needs: []
  variables:
    PROJECT_DEPS:
      gdk-pixbuf2-devel
      geocode-glib-devel
      gettext
      git
      gobject-introspection-devel
      itstool
      json-glib-devel
      libsoup-devel
      libxml2-devel
      ninja-build
      pylint
      python3
      python3-gobject
      python3-pip
      python3-wheel
      redhat-rpm-config
      vala
    MESON_VERSION: "0.57.2"
    MESON_EXTRA_FLAGS: "--buildtype=debug -Dwerror=true -Dgtk_doc=false -Dsoup2=true"

fedora-x86_64-soup3:
  extends: .build-default
  stage: build
  needs: []
  variables:
    PROJECT_DEPS:
      gcc-c++
      gdk-pixbuf2-devel
      geocode-glib-devel
      gettext
      git
      gnutls-devel
      gobject-introspection-devel
      itstool
      json-glib-devel
      libnghttp2-devel
      libpsl-devel
      libsoup-devel
      libxml2-devel
      ninja-build
      pylint
      python3
      python3-gobject
      python3-pip
      python3-wheel
      redhat-rpm-config
      sqlite-devel
      vala
    MESON_VERSION: "0.57.2"
    MESON_EXTRA_FLAGS: "--buildtype=debug -Dwerror=true -Dgtk_doc=false -Dsoup2=false"
  before_script:
    # Undo delangification present in the Fedora Docker images
    - rm -f /etc/rpm/macros.image-language-conf
    - dnf reinstall -y glib2 glibc || dnf update -y glib2 glibc
    # Add French locale support for tests
    - dnf install -y glibc-langpack-fr
    - dnf install -y ${PROJECT_DEPS}
    - pip3 install --user meson==${MESON_VERSION}
    - export PATH="$PATH:$HOME/.local/bin"
    # Build newer glib and glib-networking for libsoup3, can be removed with Fedora 35's release
    - git clone https://gitlab.gnome.org/GNOME/glib.git && pushd glib
    - git checkout 2.70.0
    - meson _build --prefix=/usr
    - ninja -C _build install
    - popd
    - git clone https://gitlab.gnome.org/GNOME/glib-networking.git && pushd glib-networking
    - git checkout 2.70.0
    - meson _build --prefix=/usr
    - ninja -C _build install
    - popd
    # Build libsoup3 and geocode-glib against libsoup3
    - git clone --depth=1 https://gitlab.gnome.org/GNOME/libsoup.git && pushd libsoup
    - meson _build --prefix=/usr -Dtls_check=false -Dgtk_doc=false
    - ninja -C _build install
    - popd
    - git clone https://gitlab.gnome.org/GNOME/geocode-glib.git && pushd geocode-glib
    - meson _build --prefix=/usr -Dsoup2=false -Denable-gtk-doc=false
    - ninja -C _build install
    - popd

static-scan:
  extends: .build-setup
  stage: analysis
  needs: []
  variables:
    PROJECT_DEPS:
      clang
      clang-analyzer
      clang-tools-extra
      gdk-pixbuf2-devel
      geocode-glib-devel
      gettext
      git
      gobject-introspection-devel
      itstool
      json-glib-devel
      libsoup-devel
      libxml2-devel
      ninja-build
      pylint
      python3
      python3-gobject
      python3-pip
      python3-wheel
      redhat-rpm-config
    MESON_VERSION: "0.57.2"
    MESON_EXTRA_FLAGS: "--buildtype=debug -Dgtk_doc=false -Dintrospection=false -Dsoup2=true"
  script:
    - meson setup --prefix /usr ${MESON_EXTRA_FLAGS} _scan_build .
    - ninja -C _scan_build scan-build
  artifacts:
    name: "gweather-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_scan_build/meson-logs/scanbuild"

asan-build:
  extends: .build-setup
  stage: analysis
  needs: []
  variables:
    PROJECT_DEPS:
      clang
      clang-analyzer
      clang-tools-extra
      gdk-pixbuf2-devel
      geocode-glib-devel
      gettext
      git
      gobject-introspection-devel
      itstool
      json-glib-devel
      libasan
      libsoup-devel
      libxml2-devel
      ninja-build
      pylint
      python3
      python3-gobject
      python3-pip
      python3-wheel
      redhat-rpm-config
      vala
    MESON_VERSION: "0.57.2"
    MESON_EXTRA_FLAGS: "--buildtype=debug -Db_sanitize=address -Db_lundef=false -Dintrospection=false -Dgtk_doc=false -Dsoup2=true"
  script:
    - CC=clang meson setup --prefix /usr ${MESON_EXTRA_FLAGS} _asan_build .
    - meson compile -C _asan_build
    - meson test -C _asan_build --no-suite=style --no-suite=lint
  artifacts:
    name: "gweather-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_asan_build/meson-logs"
  allow_failure: true

coverage:
  extends: .build-setup
  stage: analysis
  needs: []
  variables:
    PROJECT_DEPS:
      gdk-pixbuf2-devel
      geocode-glib-devel
      gettext
      git
      gobject-introspection-devel
      itstool
      json-glib-devel
      lcov
      libsoup-devel
      libxml2-devel
      ninja-build
      pylint
      python3
      python3-gobject
      python3-pip
      python3-wheel
      redhat-rpm-config
    MESON_VERSION: "0.57.2"
    MESON_EXTRA_FLAGS: "--buildtype=debug -Dgtk_doc=false -Dintrospection=false -Dsoup2=true"
    CFLAGS: "-coverage -ftest-coverage -fprofile-arcs"
  script:
    - meson setup --prefix /usr ${MESON_EXTRA_FLAGS} _build .
    - meson compile -C _build
    - meson install -C _build
    - mkdir -p _coverage
    - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
    - meson test -C _build --no-suite=style --no-suite=lint
    - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov"
    - bash -x .gitlab-ci/gen-coverage.sh
  coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
  artifacts:
    name: "gweather-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    when: always
    paths:
      - "_build/meson-logs"
      - "_coverage"

reference:
  stage: docs
  needs: []
  extends: .gidocgen-build
  variables:
    PROJECT_DEPS:
      gdk-pixbuf2-devel
      geocode-glib-devel
      gettext
      git
      gobject-introspection-devel
      itstool
      json-glib-devel
      libsoup-devel
      libxml2-devel
      ninja-build
      pylint
      python3
      python3-gobject
      python3-pip
      python3-wheel
      redhat-rpm-config
      vala
    MESON_VERSION: "0.57.2"
    MESON_EXTRA_FLAGS: "-Dsoup2=true"
    DOCS_FLAGS: "-Dgtk_doc=true"
    DOCS_PATH: doc/libgweather-4.0

pages:
  stage: deploy
  needs: ['reference']
  script:
    - mkdir public && cd public
    - tar xf ../${CI_PROJECT_NAME}-docs.tar
  artifacts:
    paths:
      - public
  only:
    - master
    - main