@@ -5,6 +5,69 @@ variables:
5
5
stages :
6
6
- build_and_test
7
7
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
8
71
9
72
# Build and test with ANOD
10
73
# TODO: add a build and test based on Alire in parallel to this.
@@ -15,57 +78,53 @@ build_and_test:
15
78
- mem:16
16
79
stage : build_and_test
17
80
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.*/
18
85
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]
32
92
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]
36
97
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";
43
115
fi
44
116
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
69
128
- e3-testsuite-report
70
129
--failure-exit-code 1
71
130
--xunit-output $CI_PROJECT_DIR/xunit_output.xml
@@ -83,7 +142,7 @@ build_and_test:
83
142
export GPR_PROJECT_PATH=/it/wave/x86_64-linux/als/src/subprojects/gnatdoc/gnat:$GPR_PROJECT_PATH;
84
143
export GPR_PROJECT_PATH=/it/wave/x86_64-linux/als/src/subprojects/VSS/gnat:$GPR_PROJECT_PATH;
85
144
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 )
87
146
88
147
- if [ ! -z ${FAILED+x} ]; then echo "There was at least one testcase failure" && exit 1; fi
89
148
0 commit comments