.gitlab-ci.yml 6.71 KB
Newer Older
1
2
# -*- indent-tabs-mode: nil -*-

3
variables:
4
  # Container(OCI) images for various distros
5

6
7
8
  AMD64_FEDORA_LATEST:       "registry.gitlab.gnome.org/gnome/librsvg-oci-images/amd64/fedora:latest"
  AMD64_OPENSUSE_TUMBLEWEED: "registry.gitlab.gnome.org/gnome/librsvg-oci-images/amd64/opensuse:tumbleweed"
  AMD64_DEBIAN_TESTING:      "registry.gitlab.gnome.org/gnome/librsvg-oci-images/amd64/debian:testing"
9

Dunja Lalic's avatar
Dunja Lalic committed
10
  LIBRSVG_DEBUG: "yes"
11
12
  # Turn compiler warnings into errors
  RUSTFLAGS: '-D warnings'
Dunja Lalic's avatar
Dunja Lalic committed
13

14
15
image: $AMD64_OPENSUSE_TUMBLEWEED

Federico Mena Quintero's avatar
Federico Mena Quintero committed
16
stages:
Dunja Lalic's avatar
Dunja Lalic committed
17
18
  - check
  - build
19
  - lint
Dunja Lalic's avatar
Dunja Lalic committed
20
21
22
  - unit test
  - acceptance test
  - cross distro
23
  - release
Dunja Lalic's avatar
Dunja Lalic committed
24
25
  - docs

26
default:
27
  interruptible: true
28
29

.cache:
Dunja Lalic's avatar
Dunja Lalic committed
30
  variables:
31
    # Only stuff inside the repo directory can be cached
Dunja Lalic's avatar
Dunja Lalic committed
32
33
34
    # Override the CARGO_HOME variable to force its location
    CARGO_HOME: "${CI_PROJECT_DIR}/cargo_cache"
  before_script:
35
    - mkdir -p cargo_cache
36
  cache:
Dunja Lalic's avatar
Dunja Lalic committed
37
38
39
    key:
      files:
        - Cargo.lock
Jordan Petridis's avatar
Jordan Petridis committed
40
    paths:
41
      # Rust cache
Dunja Lalic's avatar
Dunja Lalic committed
42
43
44
45
46
47
48
      # https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
      - cargo_cache/bin
      - cargo_cache/registry/index
      - cargo_cache/registry/cache
      - cargo_cache/git/db
    policy: pull

49
50
.cache_push:
  extends: .cache
51
52
53
  after_script:
    # Fix up ownership of the cache, not all builds use sudo
    - sudo chown -R "$(id -u):$(id -g)" ${CI_PROJECT_DIR}/cargo_cache
Dunja Lalic's avatar
Dunja Lalic committed
54
55
56
57
58
  cache:
    policy: pull-push

check:
  stage: check
59
  extends: '.cache_push'
Dunja Lalic's avatar
Dunja Lalic committed
60
61
  needs: []
  script:
62
    - sudo -E cargo check --all-targets
63

Dunja Lalic's avatar
Dunja Lalic committed
64
fmt:
65
  stage: lint
66
  extends: '.cache'
Dunja Lalic's avatar
Dunja Lalic committed
67
68
  needs:
    - job: check
69
  script:
Dunja Lalic's avatar
Dunja Lalic committed
70
    - sudo -E cargo fmt --all -- --check
71
72
73

clippy:
  stage: lint
74
  extends: '.cache'
Dunja Lalic's avatar
Dunja Lalic committed
75
76
  needs:
    - job: check
77
  script:
Sven Neumann's avatar
Sven Neumann committed
78
    - cargo clippy --version
79
80
    - gitlab-clippy --version
    - sudo -E cargo clippy
81
  after_script:
82
    - sudo -E cargo clippy --message-format=json | /opt/cargo/bin/gitlab-clippy -o gl-code-quality-report.json
83
84
85
86
87
88
89
90
  artifacts:
    reports:
      codequality: gl-code-quality-report.json
    expire_in: 1 week
  rules:
    - if: '$CODE_QUALITY_DISABLED'
      when: never
    - if: '$CI_PIPELINE_SOURCE == "push"'
91

Dunja Lalic's avatar
Dunja Lalic committed
92
93
cargo_test:
  stage: unit test
94
95
96
  extends:
    # Tests require extra crates, hence cache is pushed
    - .cache_push
Dunja Lalic's avatar
Dunja Lalic committed
97
98
  needs:
    - job: check
99
100
101
102
103
  artifacts:
    when: 'on_failure'
    paths:
      - _build/tests/output
    expire_in: 1 day
104
  variables:
Dunja Lalic's avatar
Dunja Lalic committed
105
106
    OUT_DIR: "${CI_PROJECT_DIR}/tests/output"
  script:
107
    - sudo -E cargo test -- --skip loading_crash --skip reference --skip render_crash
Dunja Lalic's avatar
Dunja Lalic committed
108

109
coverage:
110
  image: "rustlang/rust:nightly-bullseye"
111
112
113
114
115
116
  stage: unit test
  needs:
    - job: check
      artifacts: false
  variables:
    RUSTFLAGS: "-Zinstrument-coverage"
Dunja Lalic's avatar
Dunja Lalic committed
117
    RUSTDOCFLAGS: "-Zinstrument-coverage"
118
119
120
121
122
123
    LLVM_PROFILE_FILE: "coverage-%p-%m.profraw"
  before_script:
    - apt update -yqq && apt install -yqq --no-install-recommends libgdk-pixbuf2.0-dev libpango1.0-dev libcairo2-dev lcov
    - rustup component add llvm-tools-preview
    - curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2 | tar jxf -
  script:
Dunja Lalic's avatar
Dunja Lalic committed
124
    - cargo +nightly test --no-fail-fast || true
Dunja Lalic's avatar
Dunja Lalic committed
125
    - ./grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --ignore-not-existing --ignore "*cargo*" --output-path lcov.info
126
127
    - lcov --summary lcov.info

Dunja Lalic's avatar
Dunja Lalic committed
128
129
130
131
132
133
134
135
136
cargo_bench:
  stage: unit test
  needs:
    - job: check
  script: |
    BENCHES=("box_blur" "composite" "lighting" "path_parser" "pixbuf_from_surface" "pixel_iterators" "pixel_ops" "srgb" "surface_from_pixbuf")
    sudo -E git checkout ${CI_DEFAULT_BRANCH}
    for BENCH in "${BENCHES[@]}"
    do
137
      sudo -E cargo bench --bench $BENCH -- --noplot --save-baseline main
Dunja Lalic's avatar
Dunja Lalic committed
138
139
140
141
    done
    sudo -E git checkout ${CI_COMMIT_SHA}
    for BENCH in "${BENCHES[@]}"
    do
142
      sudo -E cargo bench --bench $BENCH -- --noplot --baseline main
Dunja Lalic's avatar
Dunja Lalic committed
143
144
    done
  rules:
145
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != "main"'
Dunja Lalic's avatar
Dunja Lalic committed
146
147
148
149
150
151
152
      when: manual
      allow_failure: true
  artifacts:
    paths:
      - target/criterion
    expire_in: 1 week

Dunja Lalic's avatar
Dunja Lalic committed
153
.make:
154
  extends: '.cache'
Dunja Lalic's avatar
Dunja Lalic committed
155
156
  needs:
    - job: cargo_test
157
  script:
158
159
    - mkdir -p _build
    - cd _build
160
    - sudo ../autogen.sh --enable-vala
Dunja Lalic's avatar
Dunja Lalic committed
161
162
163
    - sudo -E make
    - sudo -E make check
  artifacts:
164
    when: 'on_failure'
Dunja Lalic's avatar
Dunja Lalic committed
165
    paths:
166
167
      - _build/tests/*.log
      - _build/tests/output
Dunja Lalic's avatar
Dunja Lalic committed
168
169
170
171
172
173
    expire_in: 1 day
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: manual
      allow_failure: true
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
174

175
opensuse:tumbleweed:
Dunja Lalic's avatar
Dunja Lalic committed
176
  stage: acceptance test
177
178
  extends:
    - .make
179
180
    # make check runs extra tests that require extra crates, hence cache is pushed
    - .cache_push
181
  before_script:
182
    - sudo zypper install -y python38-docutils python3-gi-docgen
Dunja Lalic's avatar
Dunja Lalic committed
183
184
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
185
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
Dunja Lalic's avatar
Dunja Lalic committed
186

187
188
189
190
191
192
.distro:
  stage: cross distro
  extends: .make
  variables:
    LIBRSVG_DEBUG: "no"

Dunja Lalic's avatar
Dunja Lalic committed
193
fedora:latest:
194
  image: $AMD64_FEDORA_LATEST
195
  extends: .distro
196

Dunja Lalic's avatar
Dunja Lalic committed
197
debian:testing:
198
  image: $AMD64_DEBIAN_TESTING
199
  extends: .distro
Dunja Lalic's avatar
Dunja Lalic committed
200
  script:
201
    # TODO: delete after sudo is no longer needed on the other builds
202
203
    - mkdir -p _build
    - cd _build
204
    - ../autogen.sh --enable-vala
Dunja Lalic's avatar
Dunja Lalic committed
205
206
    - make
    - make check
207
  allow_failure: true
208

209
msys2-mingw64:
210
  stage: acceptance test
211
212
213
214
215
216
217
218
219
220
221
222
  tags:
    - win32-ps
  variables:
    MSYSTEM: "MINGW64"
    CHERE_INVOKING: "yes"
  script:
    - C:\msys64\usr\bin\pacman --noconfirm -Syyuu
    - C:\msys64\usr\bin\bash -lc "bash -x ./.gitlab-ci/test-msys2.sh"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
    - if: '$CI_PIPELINE_SOURCE == "schedule"'

223
224
distcheck:
  stage: release
225
  extends: .distro
226
  variables:
Dunja Lalic's avatar
Dunja Lalic committed
227
228
    DESTDIR: "/tmp/distcheck"
  script:
229
    - sudo ./autogen.sh --enable-vala
Dunja Lalic's avatar
Dunja Lalic committed
230
231
    - sudo -E make
    - sudo -E make distcheck
Dunja Lalic's avatar
Dunja Lalic committed
232
233
234
235
236
  artifacts:
    when: 'on_success'
    paths:
      - librsvg-*.tar.xz
    expire_in: 1 week
Dunja Lalic's avatar
Dunja Lalic committed
237
238
239
240
241
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: manual
      allow_failure: true
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
242

243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
reference:
  extends: '.cache'
  stage: docs
  needs:
    - job: opensuse:tumbleweed
  before_script:
    - sudo zypper install -y python38-docutils python3-gi-docgen
  script:
    - mkdir -p _build
    - cd _build
    - sudo ../autogen.sh --enable-vala
    - sudo -E make
    - cd ..
    - mkdir -p public/
    - sudo mv _build/doc/Rsvg-2.0 public/
  artifacts:
    paths:
      - public

262
pages:
Dunja Lalic's avatar
Dunja Lalic committed
263
  stage: docs
264
  extends: '.cache'
265
266
  needs:
    - job: reference
267
  script:
268
    - mkdir -p public/internals
Dunja Lalic's avatar
Dunja Lalic committed
269
    - sudo -E cargo doc --document-private-items --no-deps
270
    - cp -r target/doc/* public/internals
271
    - mkdir -p public/doc
272
    - sudo -E cargo doc --no-deps --lib
273
274
275
276
    - cp -r target/doc/* public/doc
  artifacts:
    paths:
      - public
Dunja Lalic's avatar
Dunja Lalic committed
277
  rules:
278
    - if: '$CI_COMMIT_BRANCH == "main"'