-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
81 lines (72 loc) · 3.21 KB
/
.gitlab-ci.yml
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
image: ubuntu:22.04
variables:
SONAR_SERVER_URL: https://sonarcloud.io
SONAR_SCANNER_VERSION: 4.6.1.2450
BUILD_WRAPPER_OUT_DIR: bw-output # Directory where build-wrapper output will be placed
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
# note that SONAR_TOKEN is transmitted to the environment through Gitlab CI
stages:
- .pre
- build
get-sonar-binaries:
# this job download and unpacks the build-wrapper and the sonar-scanner
# in this example it is done for every build.
# This can be optimized by caching the files or better, by including them, in the build docker image.
stage: .pre
before_script:
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt install -y curl zip unzip
script:
# Download sonar-scanner
- curl -sSLo sonar-scanner.zip "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip"
- unzip -o sonar-scanner.zip
- mv sonar-scanner-${SONAR_SCANNER_VERSION}-linux sonar-scanner
# Download build-wrapper
- curl -sSLo build-wrapper.zip "${SONAR_SERVER_URL}/static/cpp/build-wrapper-linux-x86.zip"
- unzip -o build-wrapper.zip
- mv build-wrapper-linux-x86 build-wrapper
cache:
policy: push
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- build-wrapper/ # to share the build-wrapper between jobs
- sonar-scanner/ # to share the sonar-scanner between jobs
build:
stage: build
# install the necessary build tools when needed
before_script:
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt install -y gcc g++ cmake make curl git flex bison libeigen3-dev uuid-dev libboost-system-dev libboost-program-options-dev libboost-test-dev libboost-timer-dev libboost-chrono-dev libboost-serialization-dev libbliss-dev gcovr zip unzip
- git clone --depth 1 --branch 22.12 https://github.com/ths-rwth/carl carl && cd carl
- mkdir build && cd build && cmake .. -DUSE_LIBPOLY=OFF
- make -j`nproc` carl-common
- make -j`nproc` carl-arith
- make -j`nproc` carl-logging
- make -j`nproc` carl-formula
- cd ../..
script:
# prepare the build tree
- mkdir build && cd build && cmake .. -DHYPRO_CICD=ON && cd ..
# run the build inside the build wrapper
- build-wrapper/build-wrapper-linux-x86-64 --out-dir "${BUILD_WRAPPER_OUT_DIR}" cmake --build build/ --config Release
# execute tests - required to get coverage reports
- cd build && make test
# collect coverage and write it to coverage.xml, which will be collected by the scanner
- gcovr -r ../ --sonarqube ../coverage.xml && cd ..
# run the scanner to collect and upload all information on static analysis and coverage
- sonar-scanner/bin/sonar-scanner -X --define sonar.host.url="${SONAR_SERVER_URL}" -Dsonar.token="${SONAR_TOKEN}"
artifacts:
paths:
- .
exclude:
- .git
- .git/**/*
- build/**/*.o
expire_in: 3 days
cache:
policy: pull-push
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- build-wrapper/
- sonar-scanner/