.gitlab-ci.yml 7.89 KB
Newer Older
1
stages:
2 3 4 5
  - build     # Build in various conf, keeps the artifacts
  - test      # Use the build artifacts to run the tests
  - packaging # Publish some packages (rpm, deb…)
  - external  # Interact with some external service (codecov, coverity…)
louiz’'s avatar
louiz’ committed
6
  - deploy
7

louiz’'s avatar
louiz’ committed
8
before_script:
louiz’'s avatar
louiz’ committed
9 10
  - uname -a
  - whoami
louiz’'s avatar
louiz’ committed
11

12 13 14 15
variables:
  COMPILER: "g++"
  BUILD_TYPE: "Debug"
  BOTAN: "-DWITH_BOTAN=1"
louiz’'s avatar
louiz’ committed
16
  UDNS: "-DWITH_UDNS=1"
17 18
  SYSTEMD: "-DWITH_SYSTEMD=1"
  LIBIDN: "-DWITH_LIBIDN=1"
19
  SQLITE3: "-DWITH_SQLITE3=1"
20 21 22 23 24

#
## Build jobs
#

25
.template:basic_build: &basic_build
louiz’'s avatar
louiz’ committed
26
  stage: build
27 28
  tags:
    - docker
louiz’'s avatar
louiz’ committed
29
  script:
30
    - "echo Running cmake with the following parameters: -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${SQLITE3}"
louiz’'s avatar
louiz’ committed
31 32
    - mkdir build/
    - cd build/
33
    - cmake .. -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${SQLITE3}
34
    - make everything -j$(nproc || echo 1)
35 36
    - make coverage_check -j$(nproc || echo 1)
  artifacts:
louiz’'s avatar
louiz’ committed
37
    expire_in: 2 weeks
38 39 40 41 42
    paths:
      - build/

.template:fedora_build: &fedora_build
  <<: *basic_build
louiz’'s avatar
louiz’ committed
43
  image: docker.louiz.org/louiz/biboumi/test-fedora:latest
44 45 46

.template:debian_build: &debian_build
  <<: *basic_build
louiz’'s avatar
louiz’ committed
47
  image: docker.louiz.org/louiz/biboumi/test-debian:latest
48

louiz’'s avatar
louiz’ committed
49 50 51 52
.template:alpine_build: &alpine_build
  variables:
    SYSTEMD: "-DWITHOUT_SYSTEMD=1"
  <<: *basic_build
louiz’'s avatar
louiz’ committed
53
  image: docker.louiz.org/louiz/biboumi/test-alpine:latest
louiz’'s avatar
louiz’ committed
54

55 56 57 58 59
build:fedora:
  <<: *fedora_build

build:debian:
  <<: *debian_build
60

louiz’'s avatar
louiz’ committed
61 62 63
build:alpine:
  <<: *alpine_build

64 65 66
build:1:
  variables:
    BOTAN: "-DWITHOUT_BOTAN=1"
67
  <<: *fedora_build
68 69 70

build:2:
  variables:
louiz’'s avatar
louiz’ committed
71
    UDNS: "-DWITHOUT_UDNS=1"
72
  <<: *fedora_build
73 74 75

build:3:
  variables:
76
    SQLITE3: "-DWITHOUT_SQLITE3=1"
77
  <<: *fedora_build
78 79 80

build:4:
  variables:
81
    SQLITE3: "-DWITHOUT_SQLITE3=1"
82
    BOTAN: "-DWITHOUT_BOTAN=1"
83
    LIBIDN: "-DWITHOUT_LIBIDN=1"
84
  <<: *fedora_build
85 86 87

build:5:
  variables:
88
    SQLITE3: "-DWITHOUT_SQLITE3=1"
louiz’'s avatar
louiz’ committed
89
    UDNS: "-DWITHOUT_UDNS=1"
90
  <<: *fedora_build
91 92 93 94

build:6:
  variables:
    BOTAN: "-DWITHOUT_BOTAN=1"
louiz’'s avatar
louiz’ committed
95
    UDNS: "-DWITHOUT_UDNS=1"
96
  <<: *fedora_build
97

98
build:7:
99
  variables:
louiz’'s avatar
louiz’ committed
100
    UDNS: "-DWITHOUT_UDNS=1"
101 102 103 104 105 106
  <<: *fedora_build


#
## Test jobs
#
107 108 109

.template:basic_test: &basic_test
  stage: test
110 111
  tags:
    - docker
112
  script:
louiz’'s avatar
louiz’ committed
113
    - cd build/
114
    - make coverage_e2e -j$(nproc || echo 1)
115
    - make coverage
116
  artifacts:
117
    expire_in: 2 weeks
118
    paths:
119
      - build/coverage_test_suite/
120
      - build/coverage_e2e/
121
      - build/coverage_total/
122
      - build/coverage_e2e.info
louiz’'s avatar
louiz’ committed
123
    when: always
124
    name: $CI_PROJECT_NAME-test-$CI_JOB_ID
125 126

test:debian:
louiz’'s avatar
louiz’ committed
127
  image: docker.louiz.org/louiz/biboumi/test-debian:latest
128
  <<: *basic_test
129 130
  dependencies:
    - build:debian
131 132

test:fedora:
louiz’'s avatar
louiz’ committed
133
  image: docker.louiz.org/louiz/biboumi/test-fedora:latest
134
  <<: *basic_test
135 136
  dependencies:
    - build:fedora
137

138
test:without_udns:
louiz’'s avatar
louiz’ committed
139
  image: docker.louiz.org/louiz/biboumi/test-fedora:latest
140 141
  <<: *basic_test
  dependencies:
142
    - build:7
143

louiz’'s avatar
louiz’ committed
144
test:alpine:
louiz’'s avatar
louiz’ committed
145
  image: docker.louiz.org/louiz/biboumi/test-alpine:latest
louiz’'s avatar
louiz’ committed
146 147 148 149
  stage: test
  tags:
    - docker
  script:
louiz’'s avatar
louiz’ committed
150
    - cd build/
louiz’'s avatar
louiz’ committed
151 152 153 154
    - make e2e
  dependencies:
    - build:alpine

louiz’'s avatar
louiz’ committed
155
test:freebsd:
156
  only:
157
    - branches@louiz/biboumi
louiz’'s avatar
louiz’ committed
158 159 160 161 162 163
  tags:
    - freebsd
  variables:
    SYSTEMD: "-DWITHOUT_SYSTEMD=1"
  stage: test
  script:
louiz’'s avatar
louiz’ committed
164 165
    - mkdir build/
    - cd build/
166
    - cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${SQLITE3}
louiz’'s avatar
louiz’ committed
167 168 169
    - make check
    - make e2e

170 171 172 173 174 175 176 177
#
## External jobs
#

.template:codecov: &codecov
  stage: external
  tags:
    - docker
louiz’'s avatar
louiz’ committed
178
  image: docker.louiz.org/louiz/biboumi/test-fedora:latest
179 180 181 182

.template:codecov_unittests: &codecov_unittests
  <<: *codecov
  script:
183
    - bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -f ./coverage_test_suite.info -F $(echo $CI_JOB_NAME | sed s/:/_/g | sed s/codecov_//)
184 185 186 187

.template:codecov_e2e: &codecov_e2e
  <<: *codecov
  script:
188
    - bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -f ./coverage_e2e.info -F $(echo $CI_JOB_NAME | sed s/:/_/g | sed s/codecov_//)
189 190 191 192 193 194

codecov:fedora:
  <<: *codecov_e2e
  dependencies:
    - test:fedora

195 196 197 198 199
codecov:without_udns:
  <<: *codecov_e2e
  dependencies:
    - test:without_udns

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
codecov:debian:
  <<: *codecov_e2e
  dependencies:
    - test:debian

codecov:build:1:
  <<: *codecov_unittests
  dependencies:
    - build:1

codecov:build:2:
  <<: *codecov_unittests
  dependencies:
    - build:2

codecov:build:3:
  <<: *codecov_unittests
  dependencies:
    - build:3

codecov:build:4:
  <<: *codecov_unittests
  dependencies:
    - build:4

codecov:build:5:
  <<: *codecov_unittests
  dependencies:
    - build:5

codecov:build:6:
  <<: *codecov_unittests
  dependencies:
    - build:6

codecov:build:7:
  <<: *codecov_unittests
  dependencies:
    - build:7

coverity:
  stage: external
242
  only:
243
    - branches@louiz/biboumi
244 245
  tags:
    - docker
louiz’'s avatar
louiz’ committed
246
  image: docker.louiz.org/louiz/biboumi/test-fedora:latest
247 248
  allow_failure: true
  when: manual
249 250
  script:
    - export PATH=$PATH:~/coverity/bin
louiz’'s avatar
louiz’ committed
251 252
    - mkdir build/
    - cd build/
253
    - cmake .. -DWITHOUT_SYSTEMD=1
254
    - cov-build --dir cov-int   make everything -j$(nproc || echo 1)
255 256
    - tar czvf biboumi_coverity.tgz cov-int
    - curl --form token=$COVERITY_TOKEN   --form email=louiz@louiz.org   --form file=@biboumi_coverity.tgz  --form version="$(git rev-parse --short HEAD)" --form description="Automatic submission by gitlab-ci" https://scan.coverity.com/builds?project=louiz%2Fbiboumi
257
  dependencies: []
258

louiz’'s avatar
louiz’ committed
259 260 261 262
#
## Packaging jobs
#

263 264 265 266 267 268
packaging:rpm:
  stage: packaging
  only:
    - master@louiz/biboumi
  tags:
    - docker
louiz’'s avatar
louiz’ committed
269
  image: docker.louiz.org/louiz/biboumi/test-fedora:latest
270
  script:
louiz’'s avatar
louiz’ committed
271
    - cd build/
272 273 274 275 276 277 278
    - make rpm -j$(nproc || echo 1)
  artifacts:
    paths:
      - build/rpmbuild/RPMS
      - build/rpmbuild/SRPMS
    when: always
    name: $CI_PROJECT_NAME-rpm-$CI_BUILD_ID
279 280
  dependencies:
    - build:fedora
281 282 283 284 285

packaging:deb:
  stage: packaging
  only:
    - master@louiz/biboumi
286
    - debian@louiz/biboumi
287 288 289
  tags:
    - docker
  image: docker.louiz.org/packaging-debian:latest
290
  before_script: []
291 292 293 294
  script:
    - git checkout debian
    - git merge --no-commit --no-ff master
    - mk-build-deps
295
    - apt update -y
296 297
    - apt install -y ./biboumi-build-deps*.deb
    - debuild -b -us -uc
298 299 300
    - mv ../*.deb .
    - mv ../*.build .
    - mv ../*.buildinfo .
301
  dependencies: []
302
  artifacts:
303
    untracked: true
304
    name: $CI_PROJECT_NAME-deb-$CI_BUILD_ID
305 306 307

packaging:archlinux:
  stage: packaging
308 309
  only:
    - master@louiz/biboumi
310 311
  tags:
    - docker
louiz’'s avatar
louiz’ committed
312
  image: docker.louiz.org/louiz/biboumi/test-archlinux:latest
313 314
  before_script: []
  script:
315
    - sudo pacman -Syuu --noconfirm
316 317
    - git clone https://aur.archlinux.org/biboumi-git.git
    - cd biboumi-git
318
    - makepkg -si --noconfirm
319
    - test -e /usr/bin/biboumi
320
  dependencies: []
louiz’'s avatar
louiz’ committed
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

#
## Deploy jobs
#

deploy:docker:
  stage: deploy
  tags:
    - docker-in-docker
  only:
    - master@louiz/biboumi
  variables:
    DOCKER_HOST: tcp://docker.louiz.org:2376
    DOCKER_TLS_VERIFY: 1
    SERVICE_NAME: biboumi
    BIBOUMI_HOSTNAME: test.biboumi.louiz.org
  script:
    - mkdir -p ~/.docker
    - echo "$TLSCACERT" > ~/.docker/ca.pem
    - echo "$TLSCERT" > ~/.docker/cert.pem
    - echo "$TLSKEY" > ~/.docker/key.pem
    - docker version
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN docker.louiz.org
    - docker build -t docker.louiz.org/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME docker/biboumi/alpine
    - docker push docker.louiz.org/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME
    - docker service create --with-registry-auth --detach=false --name $CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME  -e BIBOUMI_PASSWORD=password -e BIBOUMI_XMPP_SERVER_IP=prosody -e BIBOUMI_HOSTNAME=$BIBOUMI_HOSTNAME --network xmpp docker.louiz.org/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME || docker service update $CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME
  environment:
    name: master
    url: https://biboumi.louiz.org
  dependencies: []