-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
215 lines (162 loc) · 5.8 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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
image: debian:stable
stages:
- setup:1
- setup:2
- build
- test
- coverage
- deploy
variables:
RVNBINRESOURCE_COMMIT: 019ba2f29e24e5e559e81efd6121397abd850cc2
RVNSQLITE_COMMIT: bb34a68f8198bfea15283da5feb5df67422d26d2
RVNJSONRESOURCE_COMMIT: 57e0d5ca3697da1ab4dae968bd96c1cd995b99df
RVNMETADATA_COMMIT: 3c888dee8371e73b046dbb958af7cb3b479ea82c
.build_dependency:
script:
- if [[ -d $DEPENDENCY_NAME ]]; then echo "Already built"; exit 0; fi
- apt-get update && apt-get install -y git $DEPENDENCY_DEPENDENCIES
- base_url=$(dirname $(git remote get-url origin))
- mkdir $DEPENDENCY_NAME
- cd /tmp
- export GIT_SSL_CAINFO="$CI_SERVER_TLS_CA_FILE"
- git clone $base_url/$DEPENDENCY_NAME.git
- cd $DEPENDENCY_NAME
- git fetch origin $DEPENDENCY_COMMIT
- git checkout $DEPENDENCY_COMMIT
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=$CI_PROJECT_DIR/$DEPENDENCY_NAME
$DEPENDENCY_CMAKE_EXTRA_ARGS ..
- make
- make install
cache:
key: $DEPENDENCY_NAME-$DEPENDENCY_COMMIT
paths:
- $DEPENDENCY_NAME/
artifacts:
paths:
- $DEPENDENCY_NAME/
prepare:rvnbinresource:
stage: setup:1
extends: .build_dependency
variables:
DEPENDENCY_NAME: rvnbinresource
DEPENDENCY_COMMIT: $RVNBINRESOURCE_COMMIT
DEPENDENCY_DEPENDENCIES: "cmake g++ libboost-test-dev libboost-filesystem-dev"
prepare:rvnjsonresource:
stage: setup:1
extends: .build_dependency
variables:
DEPENDENCY_NAME: rvnjsonresource
DEPENDENCY_COMMIT: $RVNJSONRESOURCE_COMMIT
DEPENDENCY_DEPENDENCIES: "cmake g++ libboost-test-dev libboost-filesystem-dev"
prepare:rvnsqlite:
stage: setup:1
extends: .build_dependency
variables:
DEPENDENCY_NAME: rvnsqlite
DEPENDENCY_COMMIT: $RVNSQLITE_COMMIT
DEPENDENCY_DEPENDENCIES: "cmake g++ libboost-test-dev libsqlite3-dev"
prepare:rvnmetadata:
stage: setup:2
extends: .build_dependency
dependencies:
- prepare:rvnsqlite
- prepare:rvnbinresource
- prepare:rvnjsonresource
variables:
DEPENDENCY_NAME: rvnmetadata
DEPENDENCY_COMMIT: $RVNMETADATA_COMMIT
DEPENDENCY_DEPENDENCIES: "cmake g++ libboost-test-dev libboost-filesystem-dev libboost-program-options-dev libmagic-dev libsqlite3-dev"
DEPENDENCY_CMAKE_EXTRA_ARGS: |
-Drvnbinresource_DIR=$CI_PROJECT_DIR/rvnbinresource/share/cmake/rvnbinresource
-Drvnsqlite_DIR=$CI_PROJECT_DIR/rvnsqlite/share/cmake/rvnsqlite
-Drvnjsonresource_DIR=$CI_PROJECT_DIR/rvnjsonresource/share/cmake/rvnjsonresource
-Dsqlite3_DIR=$CI_PROJECT_DIR/rvnsqlite/share/cmake/sqlite3
.build:
stage: build
dependencies:
- prepare:rvnsqlite
- prepare:rvnbinresource
- prepare:rvnjsonresource
- prepare:rvnmetadata
script:
- mkdir build
- cd build
- cmake -DCMAKE_C_COMPILER=$CMAKE_C_COMPILER -DCMAKE_CXX_COMPILER=$CMAKE_CXX_COMPILER
-DBUILD_TEST_COVERAGE=$BUILD_TEST_COVERAGE
-Drvnbinresource_DIR=$CI_PROJECT_DIR/rvnbinresource/share/cmake/rvnbinresource
-Drvnjsonresource_DIR=$CI_PROJECT_DIR/rvnjsonresource/share/cmake/rvnjsonresource
-Drvnmetadata_DIR=$CI_PROJECT_DIR/rvnmetadata/share/cmake/rvnmetadata
-Dmagic_DIR=$CI_PROJECT_DIR/rvnmetadata/share/cmake/magic
-Drvnsqlite_DIR=$CI_PROJECT_DIR/rvnsqlite/share/cmake/rvnsqlite
-Dsqlite3_DIR=$CI_PROJECT_DIR/rvnsqlite/share/cmake/sqlite3
..
- make
artifacts:
paths:
- build/
build:gcc:
extends: .build
before_script:
- apt-get update && apt-get install -y cmake g++ libboost-test-dev libboost-filesystem-dev libmagic-dev libsqlite3-dev
variables:
CMAKE_C_COMPILER: gcc
CMAKE_CXX_COMPILER: g++
BUILD_TEST_COVERAGE: "ON"
build:clang:
extends: .build
before_script:
- apt-get update && apt-get install -y cmake clang libboost-test-dev libboost-filesystem-dev libmagic-dev libsqlite3-dev
variables:
CMAKE_C_COMPILER: clang
CMAKE_CXX_COMPILER: clang++
BUILD_TEST_COVERAGE: "OFF"
.test:
stage: test
before_script:
- apt-get update && apt-get install -y cmake libboost-test-dev libboost-filesystem-dev libmagic-dev libsqlite3-dev
script:
- cd build/
- ctest --output-on-failure
artifacts:
paths:
- build
test:gcc:
extends: .test
dependencies:
- build:gcc
test:clang:
extends: .test
dependencies:
- build:clang
coverage:gcc:
stage: coverage
before_script:
- apt-get update && apt-get install -y lcov
dependencies:
- test:gcc
script:
- lcov --directory build/ --capture --output-file coverage.info
- lcov --remove coverage.info '/usr/*' --output-file coverage.info
- lcov --remove coverage.info $CI_PROJECT_DIR'/rvnbinresource/*' --output-file coverage.info
- lcov --remove coverage.info $CI_PROJECT_DIR'/rvnsqlite/*' --output-file coverage.info
- lcov --remove coverage.info $CI_PROJECT_DIR'/rvnmetadata/*' --output-file coverage.info
- lcov --list coverage.info
- genhtml coverage.info -o coverage_report
coverage: "/\\s+Total:\\|(\\d+\\.\\d+)%/"
artifacts:
paths:
- coverage_report/
pages:
stage: deploy
dependencies:
- coverage:gcc
script:
- mv coverage_report/ public/
artifacts:
paths:
- public
expire_in: 30 days
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH