summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 3beaa1fd880c20ecbd2bdf60e3d49080f86e2ce0 (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
# -*- indent-tabs-mode: nil -*-

variables:
  # Container(OCI) images for various distros and architectures and compilers

  AMD64_FEDORA_LATEST:       "registry.gitlab.gnome.org/gnome/librsvg-oci-images/amd64/fedora:latest"
  AMD64_FEDORA_RAWHIDE:      "registry.gitlab.gnome.org/gnome/librsvg-oci-images/amd64/fedora:rawhide"
  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"
  AMD64_UBUNTU_BIONIC:       "registry.gitlab.gnome.org/gnome/librsvg-oci-images/amd64/ubuntu:18.04"

  I386_DEBIAN_TESTING:       "registry.gitlab.gnome.org/gnome/librsvg-oci-images/i386/debian:testing"
  I386_UBUNTU_BIONIC:        "registry.gitlab.gnome.org/gnome/librsvg-oci-images/i386/ubuntu:18.04"

  RUSTC_1_26:                "registry.gitlab.gnome.org/gnome/librsvg-oci-images/rustc:1.26"
  RUSTC_1_27:                "registry.gitlab.gnome.org/gnome/librsvg-oci-images/rustc:1.27"
  RUSTC_1_28:                "registry.gitlab.gnome.org/gnome/librsvg-oci-images/rustc:1.28"

  DEFAULT_IMAGE: $AMD64_OPENSUSE_TUMBLEWEED
  LIBRSVG_DEBUG: "yes"

stages:
  - check
  - build
  - lint
  - unit test
  - acceptance test
  - cross distro
  - docs

.global_before: &global_before
  - uname -v
  - rustc --version
  - cargo --version
  - mkdir -p cargo_cache
  - printenv

.common:
  variables:
    # Only stuff inside the repo directory can be cached
    # Override the CARGO_HOME variable to force its location
    CARGO_HOME: "${CI_PROJECT_DIR}/cargo_cache"
  before_script:
    - *global_before
  cache:
    key:
      files:
        - Cargo.lock
        - Makefile
      prefix: "check"
    paths:
      # 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

.cache:
  cache:
    key:
      prefix: "${CI_JOB_NAME}"
    policy: pull-push

check:
  image: $DEFAULT_IMAGE
  stage: check
  extends:
    - .common
    - .cache
  needs: []
  script:
    - sudo -E cargo check

fmt:
  image: $DEFAULT_IMAGE
  stage: lint
  extends: .common
  needs:
    - job: check
      artifacts: false
  script:
    - sudo -E cargo fmt --all -- --check

clippy:
  image: $DEFAULT_IMAGE
  stage: lint
  extends: .common
  needs:
    - job: check
      artifacts: false
  script:
    - cargo clippy --version
    - sudo CARGO_HOME=$CARGO_HOME cargo clippy --all

cargo_test:
  image: $DEFAULT_IMAGE
  stage: unit test
  extends: .common
  cache:
    key:
      prefix: "make_check"
    policy: pull-push
  needs:
    - job: check
      artifacts: false
  variables:
    OUT_DIR: "${CI_PROJECT_DIR}/tests/output"
  script:
    - sudo -E cargo test -- --skip "cmdline"

.make:
  stage: acceptance test
  extends:
    - .common
    - .cache
  needs:
    - job: cargo_test
      artifacts: false
  script:
    - sudo ./autogen.sh --enable-gtk-doc --enable-vala
    - sudo -E make
    - sudo -E make check
  artifacts:
    when: 'always'
    untracked: true
    expire_in: 1 day
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: manual
      allow_failure: true
    - if: '$CI_PIPELINE_SOURCE == "schedule"'

make_check:
  image: $AMD64_OPENSUSE_TUMBLEWEED
  stage: acceptance test
  extends: .make
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'

fedora:rawhide:
  image: $AMD64_FEDORA_RAWHIDE
  stage: cross distro
  extends: .make

fedora:latest:
  image: $AMD64_FEDORA_LATEST
  stage: cross distro
  extends: .make

debian:testing:
  image: $AMD64_DEBIAN_TESTING
  stage: cross distro
  extends: .make
  variables:
    LIBRSVG_DEBUG: "no"
    RSVG_TEST_TOLERANCE: "255"
  before_script:
    - *global_before
    - export PATH=$PATH:/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0
  script:
    # TODO: delete after sudo is no longer needed
    - ./autogen.sh --enable-gtk-doc --enable-vala
    - make
    - make check
    - make distcheck

release:
  image: $AMD64_OPENSUSE_TUMBLEWEED
  extends: .make
  variables:
    DESTDIR: "/tmp/distcheck"
  script:
    - sudo ./autogen.sh --enable-gtk-doc --enable-vala
    - sudo -E make
    - sudo -E make distcheck
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: manual
      allow_failure: true
    - if: '$CI_PIPELINE_SOURCE == "schedule"'

pages:
  image: $DEFAULT_IMAGE
  stage: docs
  extends: .common
  script:
    - mkdir -p public/doc
    - sudo -E cargo doc --document-private-items --no-deps
    - cp -r target/doc/* public/doc
  artifacts:
    paths:
      - public
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'