-
Notifications
You must be signed in to change notification settings - Fork 9
/
.gitlab-ci.yml
305 lines (270 loc) · 7.72 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
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
include:
- project: eng/gpr/gpr-issues
file: /.gitlab/.gitlab-ci-shared.yml
stages:
- build
- test
- post
.gpr2_test_template:
extends: .test_template
cache:
- key: $CI_COMMIT_REF_SLUG
fallback_keys:
- main
policy: pull
paths:
- cache
###########
## BUILD ##
###########
build:
extends: .job_template
stage: build
variables:
JOB_SUBPROJECTS: eng/gpr/gprconfig_kb
cache:
- key: $CI_COMMIT_REF_SLUG
fallback_keys:
- main
paths:
- cache
script:
# Tune to use our build & test plan
- anod tune --plan $CI_PROJECT_DIR/.ci.plan
# if a cached sandbox exists, use it, except for the daily schedule
# where we want to start anew
- if [[ $CI_PIPELINE_SOURCE != "schedule" ]]; then
install_cache full ;
else
rm -rf $CI_PROJECT_DIR/cache ;
fi
# (re)build gpr2
- anod run build
# Save gpr builds in cache to speed up a re-build
- mkdir -p $CI_PROJECT_DIR/cache
- rsync -a $SANDBOX/$HOST/*gpr2* $SANDBOX/$HOST/gnatcoll-core $CI_PROJECT_DIR/cache/
######################
## DEBUG MODE BUILD ##
######################
debug_build:
extends: .job_template
stage: build
variables:
JOB_SUBPROJECTS: eng/gpr/gprconfig_kb
script:
# Tune to use our build & test plan
- anod tune --plan $CI_PROJECT_DIR/.ci.plan
# build libgpr2 in debug mode without rebuilding dependencies
- anod run debug_build
####################
## GPR2 TESTSUITE ##
####################
test_gpr2:
extends: .gpr2_test_template
script:
- install_cache
- run_testsuite gpr2 "" test_gpr2
artifacts:
when:
always
paths:
- testgpr2_result.xml
reports:
junit: testgpr2_result.xml
##################################
## GPR2 TESTSUITE WITH GPR2BUILD #
##################################
test_gpr2_with_gpr2build:
extends: .gpr2_test_template
script:
- install_cache
- run_testsuite gpr2 "-Quse_gpr2build" test_gpr2build
when: manual
artifacts:
when:
always
paths:
- testgpr2build_result.xml
reports:
junit: testgpr2build_result.xml
###################
## GPR1 TESTSUITE #
###################
# Test the gpr1 testsuite with gpr2build.
# Should be run only if gpr2build is available
test_gpr1_testsuite:
extends: .gpr2_test_template
script:
- install_cache
- run_testsuite gprbuild "-Qgpr2build" test_gpr1_testsuite
when: manual
artifacts:
when:
always
paths:
- testgpr1testsuite_result.xml
reports:
junit: testgpr1testsuite_result.xml
##################
## MEMORY LEAKS ##
##################
test_gpr2_valgrind:
extends: .test_template
needs: []
variables:
JOB_SUBPROJECTS: eng/gpr/gprconfig_kb
script: |
# Tune to use our build & test plan
exec anod build gpr2 -Qvalgrind
run_testsuite gpr2 -Qvalgrind test_gpr2_vg
artifacts:
when:
always
paths:
- testgpr2vg_result.xml
reports:
junit: testgpr2vg_result.xml
##############
## COVERAGE ##
##############
test_gpr2_cov:
extends: .test_template
needs: []
variables:
JOB_SUBPROJECTS: eng/gpr/gprconfig_kb
script: |
exec anod build gpr2 -Qcoverage
# do a normal testsuite run but save the exit code instead of just exiting
# so that coverage artifacts can be saved and used.
result=0
run_testsuite gpr2 -Qcoverage test_gpr2_cov || result=$?
mkdir $CI_PROJECT_DIR/coverage
# save coverage results
exec mv $RESULTS_DIR/coverage-cobertura/cobertura.xml $CI_PROJECT_DIR/coverage/
exec mv $RESULTS_DIR/coverage-dhtml $CI_PROJECT_DIR/coverage/dhtml
# export to gitlab pages
if [[ $CI_PIPELINE_SOURCE = "merge_request_event" ]]; then
target_subdir=MRs/$CI_MERGE_REQUEST_IID
else
target_subdir=$CI_COMMIT_BRANCH
fi
exec publish-pages $CI_PROJECT_DIR/coverage/dhtml/ --target-subdir $target_subdir --expires 30
# display coverage stats for global reporting
echo_coverage_stats --coverage-file $RESULTS_DIR/coverage-xml/index.xml
# report initial test status code
exit $result
coverage: '/Stmt Coverage:\s+(?:\d+\.\d+)%/'
artifacts:
when:
always
paths:
- coverage/cobertura.xml
- coverage/dhtml
- testgpr2cov_result.xml
reports:
junit: testgpr2cov_result.xml
coverage_report:
coverage_format: cobertura
path: coverage/cobertura.xml
###############################
# CHECK WE CAN BOOTSTRAP GNAT #
###############################
test_bootstrap:
services:
- image:e3
- cpu:16
extends: .gpr2_test_template
allow_failure: false
variables:
JOB_SUBPROJECTS: eng/gpr/gprconfig_kb eng/gpr/gprname
cache:
- key: $CI_COMMIT_REF_SLUG
policy: pull
paths:
- cache
- key: bootstrap-$CI_COMMIT_REF_SLUG
fallback_keys:
- bootstrap-main
paths:
- bootstrap_cache
script:
- install_cache full
- if [[ $CI_PIPELINE_SOURCE != "schedule" && -d $CI_PROJECT_DIR/bootstrap_cache ]]; then
exec rsync -a $CI_PROJECT_DIR/bootstrap_cache/* $SANDBOX/$HOST/ ;
fi
- rm -rf $CI_PROJECT_DIR/bootstrap_cache ;
# JOB_SUBPROJECTS and repos identified by a "depends-on" in the MR are
# locally cloned and used by anod. However git don't preserve timestamps
# which lead to very long rebuild times (gprbuild then considers all sources
# as being modified), so caching the builds is highly ineffective.
# So in order to have a reasonable rebuild, we install a wrapper to gprbuild
# ensuring that -m is enforced for all packages.
- install_build_wrapper() {
bindir=$(anod info install $* --show working_dir)/install/bin ;
exec mv $bindir/gprbuild $bindir/gprbuild-saved ;
echo '#!'$SHELL > $bindir/gprbuild ;
echo 'gprbuild-saved -m $@' >> $bindir/gprbuild ;
exec cat $bindir/gprbuild ;
exec chmod a+x $bindir/gprbuild ;
}
- anod tune --plan $CI_PROJECT_DIR/.ci.plan
- result=0
# Install gprbuild wrappers for the gprbuild bootstrap part
- anod install gprbuild -Qstable
- install_build_wrapper gprbuild -Qstable
# and run the gnat bootstrap
- anod build gnat || result=$?
- mkdir -p $CI_PROJECT_DIR/bootstrap_cache
# save build for packages that take a long time to build: only a re-build
# will be performed on following runs, which assumably will be faster
# (than the time it takes to save/restore them).
# ??? the build space name is forged in stone here, while we know it can
# change anytime: maybe a hard to maintain choice
- for pkg in libadalang-internal laltools ; do
rsync -a $SANDBOX/$HOST/$pkg $CI_PROJECT_DIR/bootstrap_cache/ ;
done
- exit $result
###################################################
## CHECK USERS OF THE LIBGPR2 LIBRARY (optional) ##
###################################################
test_libgpr2_users:
services:
- image:e3
- cpu:16
extends: .gpr2_test_template
when: manual
variables:
JOB_SUBPROJECTS: eng/gpr/gprconfig_kb eng/gpr/gprname
cache:
- key: $CI_COMMIT_REF_SLUG
policy: pull
paths:
- cache
script:
- install_cache full
- anod tune --plan $CI_PROJECT_DIR/.ci.plan
- anod run libgpr2_users
####################
## POSTPROCESSING ##
####################
post:
extends: .job_template
stage: post
when: always
services:
- cpu:1
- image:pe-base
script:
# generate badge
- cd $CI_PROJECT_DIR
- rm -f test-count.svg
- if ls test*_result.xml &> /dev/null; then
create_xunit_badge --xunit_reports test*_result.xml ;
else
anybadge -l "Tests Passing" -v "Error" -f test-count.svg -c red ;
fi
artifacts:
when:
always
paths:
- test-count.svg