Skip to content

Commit 853e902

Browse files
committed
Merge branch 'topic/ci' into 'master'
Run CI on pull for 'master'/'edge' only and on merge request. See merge request eng/ide/ada_language_server!1197
2 parents 75c0078 + c865089 commit 853e902

File tree

1 file changed

+106
-47
lines changed

1 file changed

+106
-47
lines changed

.gitlab-ci.yml

Lines changed: 106 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,69 @@ variables:
55
stages:
66
- build_and_test
77

8+
.detect-branches:
9+
# Version 1.
10+
# Detects source and target branches. Checkout necessary branch for
11+
# repository when run downstream pipeline is detected.
12+
# ACI_SOURCE_BRANCH is set to source branch (merge request, pull)
13+
# ACI_TARGET_BRANCH is set to target branch of merge request, or 'master'/'edge' for pull
14+
# ACI_REPOSITORY_NAME_EDGE_SUFFIX is set to '-edge' when target repository is 'edge'
15+
# ACI_ANOD_QUALIFIER is set to 'edge' when target repository is 'edge'
16+
# ACI_SUBPROJECTS_ROOT is set to '/tmp' and may be overritten by script
17+
- |
18+
if [[ -n "$ACI_UPSTREAM_SOURCE_BRANCH" ]]; then
19+
ACI_SOURCE_BRANCH="$ACI_UPSTREAM_SOURCE_BRANCH";
20+
elif [[ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]]; then
21+
ACI_SOURCE_BRANCH="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME";
22+
else
23+
ACI_SOURCE_BRANCH="$CI_COMMIT_BRANCH";
24+
fi;
25+
if [[ -n "$ACI_UPSTREAM_TARGET_BRANCH" ]]; then
26+
ACI_TARGET_BRANCH=$ACI_UPSTREAM_TARGET_BRANCH;
27+
elif [[ -n "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]]; then
28+
ACI_TARGET_BRANCH="$CI_MERGE_REQUEST_TARGET_BRANCH_NAME";
29+
elif [[ "x$CI_COMMIT_BRANCH" == "xedge" ]]; then
30+
ACI_TARGET_BRANCH="edge";
31+
else
32+
ACI_TARGET_BRANCH="master";
33+
fi;
34+
if [[ "$ACI_TARGET_BRANCH" == "edge" ]]; then
35+
ACI_REPOSITORY_NAME_EDGE_SUFFIX="-edge";
36+
ACI_ANOD_QUALIFIER="edge"
37+
else
38+
ACI_REPOSITORY_NAME_EDGE_SUFFIX="";
39+
ACI_ANOD_QUALIFIER=""
40+
fi
41+
ACI_SUBPROJECTS_ROOT=/tmp
42+
echo "Source branch: $ACI_SOURCE_BRANCH"
43+
echo "Target branch: $ACI_TARGET_BRANCH"
44+
echo "Name suffix: $ACI_REPOSITORY_NAME_EDGE_SUFFIX"
45+
echo "Qualifier: $ACI_ANOD_QUALIFIER"
46+
echo "Subprojects: $ACI_SUBPROJECTS_ROOT"
47+
48+
# On downstream pipeline checkout the necessary branch
49+
- if [[ "$CI_PIPELINE_SOURCE" == 'pipeline' ]]; then
50+
if `git -C $CI_PROJECT_DIR show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
51+
git -C $CI_PROJECT_DIR checkout $ACI_SOURCE_BRANCH;
52+
elif `git -C $CI_PROJECT_DIR show-ref $ACI_TARGET_BRANCH > /dev/null`; then
53+
git -C $CI_PROJECT_DIR checkout $ACI_TARGET_BRANCH;
54+
fi
55+
fi
56+
57+
.checkout-subproject:
58+
# Version 1.
59+
# Input variables:
60+
# ACI_SUBPROJECTS_ROOT - root directory to checkout repositories.
61+
# ACI_SUBPROJECT_REPOSITORY_URL_PATH - path component of the repository's URL.
62+
# ACI_SUBPROJECT_NAME - name of the directory for subproject.
63+
- |
64+
git -C $ACI_SUBPROJECTS_ROOT clone $GIT_CLONE_BASE/$ACI_SUBPROJECT_REPOSITORY_URL_PATH $ACI_SUBPROJECT_NAME
65+
if `git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
66+
git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME checkout $ACI_SOURCE_BRANCH;
67+
elif `git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME show-ref $ACI_TARGET_BRANCH > /dev/null`; then
68+
git -C $ACI_SUBPROJECTS_ROOT -C $ACI_SUBPROJECT_NAME checkout $ACI_TARGET_BRANCH;
69+
fi
70+
anod vcs --sandbox-dir /it/wave --add-repo $ACI_SUBPROJECT_NAME $ACI_SUBPROJECTS_ROOT/$ACI_SUBPROJECT_NAME
871
972
# Build and test with ANOD
1073
# TODO: add a build and test based on Alire in parallel to this.
@@ -15,57 +78,53 @@ build_and_test:
1578
- mem:16
1679
stage: build_and_test
1780
interruptible: true
81+
rules:
82+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
83+
- if: $CI_COMMIT_BRANCH == 'master' && $CI_COMMIT_TITLE =~ /Merge branch.*/
84+
- if: $CI_COMMIT_BRANCH == 'edge' && $CI_COMMIT_TITLE =~ /Merge branch.*/
1885
script:
19-
- . ~/.aws_container_credentials
20-
- export PATH=/it/e3/bin:$PATH
21-
22-
# Check whether we're in an MR targeting 'edge' and setup some
23-
# variables if so.
24-
- TARGET_BRANCH="master"
25-
- if [ "x$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" = "xedge" ]; then
26-
echo "Targeting the edge branch." ;
27-
REPO_SUFFIX="-edge" ;
28-
BUILD_SPACE_SUFFIX="_edge" ;
29-
QUALIFIER="edge" ;
30-
TARGET_BRANCH="edge" ;
31-
fi
86+
- !reference [.detect-branches]
87+
88+
- |
89+
ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/spawn
90+
ACI_SUBPROJECT_NAME=spawn
91+
- !reference [.checkout-subproject]
3292

33-
# Setup the 'anod vcs' for this repo
34-
- cd /it/wave
35-
- anod vcs --add-repo ada_language_server${REPO_SUFFIX} $CI_PROJECT_DIR
93+
- |
94+
ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/vss
95+
ACI_SUBPROJECT_NAME=vss
96+
- !reference [.checkout-subproject]
3697

37-
# Figure out if we're on a sync branch
38-
- BRANCH=master
39-
- if [[ $CI_COMMIT_BRANCH =~ ^sync/ ]]; then
40-
BRANCH=$CI_COMMIT_BRANCH;
41-
elif [[ $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ ^sync/ ]]; then
42-
BRANCH=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME;
98+
- |
99+
ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/markdown
100+
ACI_SUBPROJECT_NAME=markdown
101+
- !reference [.checkout-subproject]
102+
103+
- |
104+
ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/gnatdoc
105+
ACI_SUBPROJECT_NAME=gnatdoc$ACI_REPOSITORY_NAME_EDGE_SUFFIX
106+
- !reference [.checkout-subproject]
107+
108+
- |
109+
ACI_SUBPROJECT_REPOSITORY_URL_PATH=/eng/ide/gnatstudio-internal
110+
ACI_SUBPROJECT_NAME=gnatstudio-internal$ACI_REPOSITORY_NAME_EDGE_SUFFIX
111+
- !reference [.checkout-subproject]
112+
113+
- if [[ "$ACI_TARGET_BRANCH" == "edge" ]]; then
114+
BUILD_SPACE_SUFFIX="_edge";
43115
fi
44116

45-
# Setup the 'anod vcs' for the other repos, if we're on
46-
# a "sync" branch.
47-
- for subproject in vss spawn gnatdoc ; do
48-
echo "for subproject $subproject ..." ;
49-
cd /tmp ;
50-
git clone $GIT_CLONE_BASE/eng/ide/$subproject ;
51-
cd $subproject ;
52-
if `git show-ref $BRANCH > /dev/null` ; then
53-
echo "... checking out $BRANCH"
54-
git checkout $BRANCH ;
55-
cd /it/wave ;
56-
anod vcs --add-repo $subproject /tmp/$subproject ;
57-
else
58-
echo "... checking out $TARGET_BRANCH"
59-
git checkout $TARGET_BRANCH ;
60-
fi ;
61-
done ;
62-
63-
# Build & test using anod
64-
- cd /it/wave
65-
- anod build als --qualifier=$QUALIFIER --minimal
66-
- anod test als --qualifier=$QUALIFIER --minimal
67-
68-
# Process the report
117+
- |
118+
# Setup the 'anod vcs' for this repo
119+
cd /it/wave
120+
anod vcs --add-repo ada_language_server$ACI_REPOSITORY_NAME_EDGE_SUFFIX $CI_PROJECT_DIR
121+
122+
# Build & test using anod
123+
cd /it/wave
124+
- anod build als --qualifier=$ACI_ANOD_QUALIFIER --minimal
125+
- anod test als --qualifier=$ACI_ANOD_QUALIFIER --minimal
126+
127+
# Process the report
69128
- e3-testsuite-report
70129
--failure-exit-code 1
71130
--xunit-output $CI_PROJECT_DIR/xunit_output.xml
@@ -83,7 +142,7 @@ build_and_test:
83142
export GPR_PROJECT_PATH=/it/wave/x86_64-linux/als/src/subprojects/gnatdoc/gnat:$GPR_PROJECT_PATH;
84143
export GPR_PROJECT_PATH=/it/wave/x86_64-linux/als/src/subprojects/VSS/gnat:$GPR_PROJECT_PATH;
85144
cd /it/wave/x86_64-linux/als/src;
86-
lsif-ada gnat/lsp_server.gpr > $CI_PROJECT_DIR/dump.lsif )
145+
lsif-ada gnat/lsp_server.gpr > $CI_PROJECT_DIR/dump.lsif 2>/dev/null )
87146

88147
- if [ ! -z ${FAILED+x} ]; then echo "There was at least one testcase failure" && exit 1; fi
89148

0 commit comments

Comments
 (0)