forked from GoogleCloudPlatform/slurm-gcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
261 lines (232 loc) · 5.83 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
---
workflow:
rules:
# skip pipeline if the source is a tag
- if: $CI_COMMIT_TAG
when: never
# Skip pipeline on merge request event
# TODO this should be possible, but I'm not sure how it works yet
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- when: always
stages:
- build-images
- test-clusters
variables:
GOOGLE_APPLICATION_CREDENTIALS: $CI_PROJECT_DIR/sa.json
SLURM_VERSION: 23.11.3
BRANCH: $CI_COMMIT_BRANCH
default:
image:
name: registry.gitlab.com/schedmd/slurm-gcp/ci-image:0.0.9
before_script:
- set +o pipefail
- packer --version
- echo $SERVICE_ACCOUNT > $GOOGLE_APPLICATION_CREDENTIALS
- GCP_PROJECT_ID=$(jq -r .project_id < $GOOGLE_APPLICATION_CREDENTIALS)
- GCP_SA_EMAIL=$(jq -r .client_email < $GOOGLE_APPLICATION_CREDENTIALS)
- GCP_SA_ID=$(jq -r .client_id < $GOOGLE_APPLICATION_CREDENTIALS)
- 'echo Slurm version to build: $SLURM_VERSION'
- SLURM_VERSION_ALT=$(tr \. - <<< $SLURM_VERSION)
- IMAGE_FAMILY_ROOT=slurm-gcp-$BRANCH
- gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
- gcloud config set project $GCP_PROJECT_ID
.build-image:
stage: build-images
retry: 2
artifacts:
name: image-manifest-$BRANCH-$IMAGE_OS
paths:
- packer/manifest.json
script:
- echo "Building $IMAGE_OS image for $BRANCH"
- cd packer
- packer init .
- >
packer build -var-file builds/$IMAGE_OS.hcl
-var "project_id=$GCP_PROJECT_ID"
-var "slurm_version=$SLURM_VERSION"
-var "slurmgcp_version=$BRANCH"
$EXTRA_VARS
.
- echo "packer build $IMAGE_OS completed"
.build-core-image:
extends: .build-image
rules:
- changes:
paths:
- .gitlab-ci.yml
- scripts/*.{py,sh}
- scripts/Pipfile
- scripts/requirements.txt
- ansible/**/*
- third_party/ansible/**/*
- packer/**/*
# skip image build and test for all except a couple images on push
# build and test all on manual/scheduled pipelines
.build-extra-image:
extends: .build-image
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: never
- if: $ONLY_CORE
when: never
- changes:
paths:
- .gitlab-ci.yml
- scripts/*.{py,sh}
- scripts/Pipfile
- scripts/requirements.txt
- ansible/**/*
- third_party/ansible/**/*
- packer/**/*
build-hpc-centos-7:
extends: .build-extra-image
variables:
IMAGE_OS: hpc-centos-7
build-hpc-centos-7-k80:
extends: .build-extra-image
variables:
IMAGE_OS: hpc-centos-7-k80
build-hpc-rocky-linux-8:
extends: .build-core-image
variables:
IMAGE_OS: hpc-rocky-linux-8
build-debian-11:
extends: .build-extra-image
variables:
IMAGE_OS: debian-11
# build-debian-11-arm64:
# extends: .build-extra-image
# variables:
# IMAGE_OS: debian-11-arm64
build-ubuntu-2004-lts:
extends: .build-core-image
variables:
IMAGE_OS: ubuntu-2004-lts
# build-ubuntu-2004-lts-arm64:
# extends: .build-extra-image
# variables:
# IMAGE_OS: ubuntu-2004-lts-arm64
# build-ubuntu-2204-lts:
# extends: .build-extra-image
# variables:
# IMAGE_OS: ubuntu-2204-lts
build-ubuntu-2204-lts-arm64:
extends: .build-extra-image
variables:
IMAGE_OS: ubuntu-2204-lts-arm64
.test-image:
stage: test-clusters
retry: 1
artifacts:
name: $CI_COMMIT_REF_NAME-$CI_JOB_NAME-logs
when: always
paths:
- test/cluster_logs/
script:
- IMAGE_FAMILY=$IMAGE_FAMILY_ROOT-$IMAGE_OS
- echo "Image family $IMAGE_FAMILY"
- >
IMAGE_NAME=$(
jq -r '.last_run_uuid as $uuid | .builds | map(select(.packer_run_uuid == $uuid))
| .[].artifact_id' < packer/manifest.json || true
)
- echo "Testing ${IMAGE_NAME:-$IMAGE_FAMILY}"
- cd test
- CLUSTER_NAME="test$(tr -dc a-z </dev/urandom | head -c2)"
- echo $CLUSTER_NAME | tee cluster_name
- export PATH=/venv/bin:$PATH
- pip3 install -r requirements.txt
- >
pytest -vs
--project-id=$GCP_PROJECT_ID
--cluster-name=$CLUSTER_NAME
--image-project=$GCP_PROJECT_ID
--image-family=$IMAGE_FAMILY
--image=${IMAGE_NAME:-null}
-m "${ARCH}"
# after_script:
# - cd test
# - pipenv install
# - pipenv run ./cleanup.py $(cat cluster_name)
.test-extra-image:
extends: .test-image
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: never
- if: $ONLY_CORE
when: never
- when: always
test-hpc-centos-7:
extends: .test-extra-image
needs:
- job: build-hpc-centos-7
optional: true
variables:
IMAGE_OS: hpc-centos-7
ARCH: x86_64
test-hpc-centos-7-k80:
extends: .test-extra-image
needs:
- job: build-hpc-centos-7-k80
optional: true
variables:
IMAGE_OS: hpc-centos-7-k80
ARCH: x86_64
test-hpc-rocky-linux-8:
extends: .test-image
needs:
- job: build-hpc-rocky-linux-8
optional: true
variables:
IMAGE_OS: hpc-rocky-linux-8
ARCH: x86_64
test-debian-11:
extends: .test-extra-image
needs:
- job: build-debian-11
optional: true
variables:
IMAGE_OS: debian-11
ARCH: x86_64
# test-debian-11-arm64:
# extends: .test-extra-image
# needs:
# - job: build-debian-11-arm64
# optional: true
# variables:
# IMAGE_OS: debian-11-arm64
# ARCH: arm64
test-ubuntu-2004-lts:
extends: .test-image
needs:
- job: build-ubuntu-2004-lts
optional: true
variables:
IMAGE_OS: ubuntu-2004-lts
ARCH: x86_64
# test-ubuntu-2004-lts-arm64:
# extends: .test-extra-image
# needs:
# - job: build-ubuntu-2004-lts-arm64
# optional: true
# variables:
# IMAGE_OS: ubuntu-2004-lts-arm64
# ARCH: arm64
# test-ubuntu-2204-lts:
# extends: .test-extra-image
# needs:
# - job: build-ubuntu-2204-lts
# optional: true
# variables:
# IMAGE_OS: ubuntu-2204-lts
# ARCH: x86_64
test-ubuntu-2204-lts-arm64:
extends: .test-extra-image
needs:
- job: build-ubuntu-2204-lts-arm64
optional: true
variables:
IMAGE_OS: ubuntu-2204-lts-arm64
ARCH: arm64