-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
309 lines (269 loc) · 9.42 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
306
307
308
309
variables:
# The common part of the URL for cloning from within a CI
GIT_CLONE_BASE: https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}
PIP_INDEX_URL: https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.adacore-it.com/api/v4/projects/it%2Fpackage-registry/packages/pypi/simple
.basic-setup:
# Use generic_anod_ci here.
- generic_anod_ci
--add-dep eng/ide/gnatstudio-internal
- cat /tmp/ci_env.sh
- . /tmp/ci_env.sh
.basic-setup-dev:
- |
set -x
export PATH=/it/e3/bin:$PATH
.detect-branches:
# Version 1.
# Detects source and target branches. Checkout necessary branch for
# repository when run downstream pipeline is detected.
# ACI_SOURCE_BRANCH is set to source branch (merge request, pull)
# ACI_TARGET_BRANCH is set to target branch of merge request, or 'master'/'edge' for pull
# ACI_REPOSITORY_NAME_EDGE_SUFFIX is set to '-edge' when target repository is 'edge'
# ACI_ANOD_QUALIFIER is set to 'edge' when target repository is 'edge'
# ACI_SUBPROJECTS_ROOT is set to '/tmp' and may be overritten by script
- |
if [[ -n "$ACI_UPSTREAM_SOURCE_BRANCH" ]]; then
ACI_SOURCE_BRANCH="$ACI_UPSTREAM_SOURCE_BRANCH";
elif [[ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]]; then
ACI_SOURCE_BRANCH="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME";
else
ACI_SOURCE_BRANCH="$CI_COMMIT_BRANCH";
fi;
if [[ -n "$ACI_UPSTREAM_TARGET_BRANCH" ]]; then
ACI_TARGET_BRANCH=$ACI_UPSTREAM_TARGET_BRANCH;
elif [[ -n "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]]; then
ACI_TARGET_BRANCH="$CI_MERGE_REQUEST_TARGET_BRANCH_NAME";
elif [[ "x$CI_COMMIT_BRANCH" == "xedge" ]]; then
ACI_TARGET_BRANCH="edge";
else
ACI_TARGET_BRANCH="master";
fi;
if [[ "$ACI_TARGET_BRANCH" == "edge" ]]; then
ACI_REPOSITORY_NAME_EDGE_SUFFIX="-edge";
ACI_ANOD_QUALIFIER="edge"
else
ACI_REPOSITORY_NAME_EDGE_SUFFIX="";
ACI_ANOD_QUALIFIER=""
fi
ACI_SUBPROJECTS_ROOT=/tmp
echo "Source branch: $ACI_SOURCE_BRANCH"
echo "Target branch: $ACI_TARGET_BRANCH"
echo "Name suffix: $ACI_REPOSITORY_NAME_EDGE_SUFFIX"
echo "Qualifier: $ACI_ANOD_QUALIFIER"
echo "Subprojects: $ACI_SUBPROJECTS_ROOT"
# On downstream pipeline checkout the necessary branch
- if [[ "$CI_PIPELINE_SOURCE" == 'pipeline' ]]; then
if `git -C $CI_PROJECT_DIR show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
git -C $CI_PROJECT_DIR checkout $ACI_SOURCE_BRANCH;
elif `git -C $CI_PROJECT_DIR show-ref $ACI_TARGET_BRANCH > /dev/null`; then
git -C $CI_PROJECT_DIR checkout $ACI_TARGET_BRANCH;
fi
fi
.checkout-subproject:
# Version 1.
# Input variables:
# ACI_SUBPROJECTS_ROOT - root directory to checkout repositories.
# ACI_SUBPROJECT_REPOSITORY_URL_PATH - path component of the repository's URL.
# ACI_SUBPROJECT_NAME - name of the directory for subproject.
- |
git -C $ACI_SUBPROJECTS_ROOT clone $GIT_CLONE_BASE/$ACI_SUBPROJECT_REPOSITORY_URL_PATH $ACI_SUBPROJECT_NAME
if `git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME checkout $ACI_SOURCE_BRANCH;
elif `git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME show-ref $ACI_TARGET_BRANCH > /dev/null`; then
git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME checkout $ACI_TARGET_BRANCH;
fi
anod vcs --sandbox-dir /it/wave --add-repo $ACI_SUBPROJECT_NAME $ACI_SUBPROJECTS_ROOT/$ACI_SUBPROJECT_NAME
stages:
- build_and_test
- build_dependent
- run_downstream_ci
###############
# ISSUE CHECK #
###############
issue-check:
services:
- image:e3
stage: build_and_test
interruptible: true # Cancel job if the branch is pushed
variables: # do not checkout the git repository, not needed
GIT_STRATEGY: none
rules: # Launch only on merge requests
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- require_issue # launch the verification
#########
# BUILD #
#########
build_and_test_dev:
services:
- image:sandbox
- cpu:8
- mem:16
stage: build_and_test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
- if: $CI_COMMIT_BRANCH == 'master' && $CI_COMMIT_TITLE =~ /Merge branch.*/
- if: $CI_COMMIT_BRANCH == 'edge' && $CI_COMMIT_TITLE =~ /Merge branch.*/
script:
- !reference [.basic-setup-dev]
- !reference [.detect-branches]
- |
# Install GNAT (with gcov) and gcovr
anod install --sandbox-dir /it/wave gnatall
python3 -m pip install gcovr
# Fetch tests' data into `./data/`
PACKAGE=vss-tests-data.tar.bz2
VERSION=5
VSS_URL=https://gitlab.adacore-it.com/api/v4/projects/129
curl -L --header "JOB-TOKEN: $CI_JOB_TOKEN" \
$VSS_URL/packages/generic/$PACKAGE/$VERSION/$PACKAGE |\
tar xjf - -C ./data
# Make directory for XUnit test reports
export XUNIT_XML_PATH=.xunit-logs/
mkdir -p $XUNIT_XML_PATH
# Build VSS and run tests
( eval $(anod printenv --sandbox-dir /it/wave gnatall) ;\
make COVERAGE_MODE=gcov build-libs-static check misc ;\
make -C testsuite/json_schema ;\
ENABLE_GCOV=y gcovr --print-summary --cobertura gcov.xml )
make clean
# Run spell checker
- make spellcheck_json
coverage: /^\s*lines:\s*\d+.\d+\%/
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: gcov.xml
codequality:
- spellcheck.json
junit: .xunit-logs/*.xml
.build_and_test:
stage: build_and_test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- generic_anod_ci
- . /tmp/ci_env.sh
# Build & test using anod
- anod build vss $ACI_TRACK_QUALIFIER --latest
- anod test vss $ACI_TRACK_QUALIFIER --latest
- testsuite_reports
build_and_test:linux:
extends: .build_and_test
services:
- image:pe-base
- cpu:8
- mem:16
build_and_test:windows:
extends: .build_and_test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
services:
- image:e3-windows-core-2022
- cpu:8
- platform:x86_64-windows-2022
build_gnatdoc:
services:
- image:sandbox
- cpu:8
- mem:16
stage: build_dependent
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
script:
- !reference [.basic-setup]
- !reference [.detect-branches]
- ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/markdown
- ACI_SUBPROJECT_NAME=markdown
- !reference [.checkout-subproject]
- ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/gnatdoc
- ACI_SUBPROJECT_NAME=gnatdoc$ACI_REPOSITORY_NAME_EDGE_SUFFIX
- !reference [.checkout-subproject]
- |
cd /it/wave
# Tell the anod sandbox to use our repository
anod vcs --add-repo vss $CI_PROJECT_DIR
# Build the ALS as a test
anod build gnatdoc4 --qualifier=$ACI_ANOD_QUALIFIER
build_lsif:
services:
- image:sandbox
- cpu:8
- mem:16
stage: build_dependent
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
script:
- !reference [.basic-setup]
- !reference [.detect-branches]
- |
export GPR_PROJECT_PATH=`pwd`/gnat:$GPR_PROJECT_PATH
mkdir subprojects
ACI_SUBPROJECTS_ROOT=`pwd`/subprojects
- export GPR_PROJECT_PATH=`pwd`/subprojects/gnatdoc/gnat:$GPR_PROJECT_PATH
- ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/gnatdoc
- ACI_SUBPROJECT_NAME=gnatdoc
- !reference [.checkout-subproject]
- export GPR_PROJECT_PATH=`pwd`/subprojects/lsif-ada/gnat:$GPR_PROJECT_PATH
- ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/lsif-ada
- ACI_SUBPROJECT_NAME=lsif-ada
- !reference [.checkout-subproject]
- |
anod install --sandbox-dir /it/wave stable-gnatall
anod install --sandbox-dir /it/wave stable-langkit_support
anod install --sandbox-dir /it/wave stable-libgpr2 --qualifier=bare
anod install --sandbox-dir /it/wave stable-libadalang
( eval $(anod printenv --sandbox-dir /it/wave stable-gnatall) ;\
eval $(anod printenv --sandbox-dir /it/wave stable-langkit_support) ;\
eval $(anod printenv --sandbox-dir /it/wave stable-libgpr2 --qualifier=bare) ;\
eval $(anod printenv --sandbox-dir /it/wave stable-libadalang) ;\
make -C subprojects/lsif-ada; \
./subprojects/lsif-ada/bin/lsif-ada vss_documentation.gpr > dump.lsif)
artifacts:
reports:
lsif: dump.lsif
.run_ci_common: &run_ci_common
stage: build_dependent
needs: ["build_and_test:linux"]
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
when: never
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
allow_failure: true
trigger:
strategy: depend
inherit:
variables: false
variables:
ACI_UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
ACI_UPSTREAM_MERGE_REQUEST_IID: $CI_MERGE_REQUEST_IID
ACI_TRACK: edge
run_lal_ci:
<<: *run_ci_common
trigger:
project: eng/libadalang/libadalang
run_als_ci:
<<: *run_ci_common
trigger:
project: eng/ide/ada_language_server
run_gnatdoc_ci:
<<: *run_ci_common
trigger:
project: eng/ide/gnatdoc
run_gs_ci:
<<: *run_ci_common
trigger:
project: eng/ide/gnatstudio
run_lsif_ci:
<<: *run_ci_common
trigger:
project: eng/ide/lsif-ada