-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
171 lines (156 loc) · 6.6 KB
/
.gitlab-ci.yml
File metadata and controls
171 lines (156 loc) · 6.6 KB
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
# Fraxinus GitLab CI/CD configuration file
default:
#image: olevs/custusx-build-ubuntu2004 #Dockerhub
image: gitlab.sintef.no:5050/custusx/custusx/custusx-build-ubuntu2004
stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
.build-variables:
stage: build
variables:
VERSION: ${CI_COMMIT_SHORT_SHA}
OS: OS
BASE_DIR: /builds/Fraxinus/$OS #Reusing CX build folders don't work
GIT_CLONE_PATH: $BASE_DIR/FX/FX #Changes CI_PROJECT_DIR
BUILD_DIR: $BASE_DIR/CX/build_Release
CX_SOURCE_PATH: $BASE_DIR/CX/CX
.create-installer:
script:
- cd $BUILD_DIR
# Remove old installer
- rm -f Fraxinus*.tar.gz
- cpack
# The file Fraxinus*.tar.gz should now be in CX/build_Release, and html_pure and html_dev in CX/build_Release/doc
- cd $CI_PROJECT_DIR
- mkdir -p $OS/package_artefacts
- cp -R $BUILD_DIR/Fraxinus*.tar.gz $OS/package_artefacts/
- cp -R $BUILD_DIR/doc/html_pure $OS/package_artefacts/html_pure/
- cp -R $BUILD_DIR/doc/html_dev $OS/package_artefacts/html_dev/
- echo "Compile complete."
artifacts:
paths:
- $OS/package_artefacts/Fraxinus*.tar.gz
- $OS/package_artefacts/html_pure/
- $OS/package_artefacts/html_dev/
.reuse-build:
extends:
- .build-variables
- .create-installer
before_script:
- echo "Run cxFraxinusPrivateInstaller.py"
- ls $BASE_DIR
- if [ $CI_COMMIT_TAG ]; then CX_COMMIT=$CI_COMMIT_TAG; else CX_COMMIT=$CI_COMMIT_BRANCH; fi
- rm -rf $BASE_DIR/CTK # Make sure we got a fresh CTK after changing the library
- test -d $BASE_DIR/VTK/build_Release
&& eval ./script/cxFraxinusPrivateInstaller.py -s --full -t Release --user_doc --developer_doc --main_branch $CX_COMMIT --gitrepo_main_site_base https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.sintef.no/custusx
components CustusX Fraxinus FraxinusTracking USSimulator CTK
|| eval ./script/cxFraxinusPrivateInstaller.py -s --all --full -t Release --user_doc --developer_doc --main_branch $CX_COMMIT --gitrepo_main_site_base https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.sintef.no/custusx
build-ubuntu20:
extends: .reuse-build
image: gitlab.sintef.no:5050/custusx/custusx/custusx-build-ubuntu2004:25.02.02
variables:
OS: Ubuntu2004
build-ubuntu22:
extends: .reuse-build
image: gitlab.sintef.no:5050/custusx/custusx/custusx-build-ubuntu2204:25.02.02
variables:
OS: Ubuntu2204
.old-test-job: # This job runs the Unit + Integration tests
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... "
- if [ $CI_COMMIT_TAG ]; then CX_COMMIT=$CI_COMMIT_TAG; else CX_COMMIT=$CI_COMMIT_BRANCH; fi
- xvfb-run ./script/cxJenkinsMasterBuildScript.py --test_package --main_branch $CX_COMMIT --gitrepo_main_site_base https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.sintef.no/custusx
#Open source:
#- xvfb-run ./script/cxOpenSourceMasterBuildScript.py --test_package --main_branch $CX_COMMIT --gitrepo_main_site_base https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.sintef.no/custusx
- cp -r /builds/custusx/CustusX/test_results ${CI_PROJECT_DIR}/test_results
artifacts:
when: always
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
paths:
- test_results/*junit.xml
reports:
junit: test_results/*junit.xml
.test-job: # This job runs the Unit + Integration tests
stage: test # It only starts when the job in the build stage completes successfully.
extends: .build-variables
script:
- echo "Running unit tests... "
- if [ $CI_COMMIT_TAG ]; then CX_COMMIT=$CI_COMMIT_TAG; else CX_COMMIT=$CI_COMMIT_BRANCH; fi
# Checkout CX repo if missing, else only delete package_artefacts folder
- test -d $CX_SOURCE_PATH
&& eval rm -rf $CX_SOURCE_PATH/package_artefacts
|| eval git clone -b $CX_COMMIT https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.sintef.no/custusx/CustusX.git $CX_SOURCE_PATH
# Copy installer into CX repository
- mkdir -p $CX_SOURCE_PATH/package_artefacts
- cp -R $OS/package_artefacts/Fraxinus*.tar.gz $CX_SOURCE_PATH/package_artefacts/
- ls $CX_SOURCE_PATH/package_artefacts 2> /dev/null
- xvfb-run ./script/cxJenkinsMasterBuildScript.py --test_package --main_branch $CX_COMMIT --gitrepo_main_site_base https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.sintef.no/custusx
- cp -R $CX_SOURCE_PATH/test_results ${CI_PROJECT_DIR}/test_results/
artifacts:
when: always
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
paths:
- test_results/*junit.xml
reports:
junit: test_results/*junit.xml
test-ubuntu20:
extends: .test-job
needs: ["build-ubuntu20"] # Run as soon as previous job is finished
image: gitlab.sintef.no:5050/custusx/custusx/custusx-build-ubuntu2004:25.02.02
variables:
OS: Ubuntu2004
test-ubuntu22:
extends: .test-job
needs: ["build-ubuntu22"]
image: gitlab.sintef.no:5050/custusx/custusx/custusx-build-ubuntu2204:25.02.02
variables:
OS: Ubuntu2204
.deploy:
stage: deploy
extends: .build-variables
environment: production
script:
- echo "Deploying application..."
- cd $CI_PROJECT_DIR/Ubuntu2004/package_artefacts
- INSTALLER_FILE=$(find Fraxinus*.tar.gz)
- 'curl
--header "JOB-TOKEN: $CI_JOB_TOKEN"
--upload-file $INSTALLER_FILE
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/Fraxinus/$VERSION/Ubuntu2004/$INSTALLER_FILE"'
- cd $CI_PROJECT_DIR/Ubuntu2204/package_artefacts
- INSTALLER_FILE=$(find Fraxinus*.tar.gz)
- 'curl
--header "JOB-TOKEN: $CI_JOB_TOKEN"
--upload-file $INSTALLER_FILE
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/Fraxinus/$VERSION/Ubuntu2204/$INSTALLER_FILE"'
deploy-commmit:
extends: .deploy
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH # Only run for changes to the default (develop) branch
when: never
- if: '$CI_COMMIT_TAG == null' # Run for all commits, except tags
when: never # Don't deploy for develop branch either
deploy-tag:
extends: .deploy
variables:
VERSION: ${CI_COMMIT_TAG}
rules:
- if: '$CI_COMMIT_TAG != null' # Run if a tag is present (= release or release candidate)
pages:
stage: deploy
extends: .build-variables
environment: production
variables:
OS: Ubuntu2004
script:
- mv $OS/package_artefacts/html_pure/ public/user_doc/
- mv $OS/package_artefacts/html_dev/ public/developer_doc/
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run for all changes to the default (develop) branch only