-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
156 lines (134 loc) · 5.24 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
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
image: ubuntu:22.04
variables:
SONAR_SERVER_URL: https://sonarcloud.io
SONAR_SCANNER_VERSION: 4.6.1.2450
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # 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
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
# artifacts:
# paths:
# - .
# exclude:
# - .git
# - .git/**/*
# - build/**/*.o
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 && make -j`nproc` && cd ..
# - cmake -S . -B build
# 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
- pwd && ls
artifacts:
paths:
- build/sonar_scanner_example
cache:
policy: pull-push
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- build-wrapper/
- sonar-scanner/
- "${BUILD_WRAPPER_OUT_DIR}"
- carl/
sonarqube-check:
stage: .post
cache:
policy: pull
key: "${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
- "${BUILD_WRAPPER_OUT_DIR}"
script:
- sonar-scanner/bin/sonar-scanner --define sonar.host.url="${SONAR_SERVER_URL}" --define sonar.cfamily.build-wrapper-output="${BUILD_WRAPPER_OUT_DIR}"
# only:
# - merge_requests
# - main
# - develop
# build:
# stage: build
# # instead of calling g++ directly you can also use some build toolkit like make
# # 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 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
# - 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:
# - mkdir build && cd build && cmake .. -DHYPRO_CICD=ON && make -j`nproc`
# cache:
# key: $CI_COMMIT_REF_SLUG
# paths:
# - carl/
# artifacts:
# paths:
# - .
# exclude:
# - .git
# - .git/**/*
# - build/**/*.o
# sonarcloud:
# stage: build
# image:
# name: sonarsource/sonar-scanner-cli:latest
# entrypoint: [""]
# cache:
# key: "${CI_JOB_NAME}"
# paths:
# - .sonar/cache
# script:
# - sonar-scanner
# # rules:
# # - if: $CI_COMMIT_REF_NAME == 'main' || $CI_PIPELINE_SOURCE == 'merge_request_event'
# # run tests using the binary built before
# test:
# stage: test
# before_script:
# - DEBIAN_FRONTEND=noninteractive apt-get update
# - DEBIAN_FRONTEND=noninteractive apt install -y gcc g++ cmake make 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
# script:
# - ctest --test-dir build --output-junit junit.xml
# artifacts:
# reports:
# junit: build/junit.xml