@@ -7,8 +7,6 @@ variables:
7
7
# Because we are installing git-crypt as part of the job, we cannot reuse old
8
8
# checkouts where git-crypt is already initialised as this results in an error
9
9
GIT_STRATEGY: clone
10
- # Write the Azimuth URL to an envfile in the local directory
11
- AZIMUTH_URL_ENVFILE: ${CI_PROJECT_DIR}/azimuth.env
12
10
# Use the pipeline credentials for Terraform
13
11
# This assumes that we are using GitLab-managed Terraform state (recommended when available)
14
12
TF_HTTP_USERNAME: gitlab-ci-token
@@ -19,10 +17,16 @@ stages:
19
17
- scheduled
20
18
# This stage owns the deploy and teardown jobs for dynamic environments
21
19
- aio
22
- # This stage owns the deploy job for our staging environment
20
+ # This stage runs tests for dynamic environments
21
+ - aio_test
22
+ # This stage owns the deploy job for the staging environment
23
23
- staging
24
- # This stage owns the deploy job for our production environment
24
+ # This stage owns the test job for the staging environment
25
+ - staging_test
26
+ # This stage owns the deploy job for the production environment
25
27
- production
28
+ # This stage owns the test job for the production environment
29
+ - production_test
26
30
27
31
#####
28
32
# This job checks to see if there is a new release that needs to be merged
@@ -76,9 +80,7 @@ check_for_release:
76
80
fi
77
81
78
82
#####
79
- # This job deploys a dynamic review environment for the current branch
80
- #
81
- # Runs for every commit to every branch except main
83
+ # This job deploys a dynamic review environment for a merge request
82
84
#
83
85
# Each environment is a single node deployment that is isolated from the other
84
86
# branches with it's own GitLab environment, Terraform state and OpenStack resources
@@ -98,8 +100,8 @@ deploy_aio:
98
100
when: never
99
101
# Allow deployments to be manually triggered even when there are no changed files
100
102
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "web"
101
- # Run when there is a push to a branch that is not main changes one of the relevant files
102
- - if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "push "
103
+ # Run when there is a push to a branch with a merge request that changes one of the relevant files
104
+ - if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "merge_request_event "
103
105
changes:
104
106
# Files that affect the aio environment
105
107
- env
@@ -109,19 +111,52 @@ deploy_aio:
109
111
- environments/singlenode/**/*
110
112
- environments/site/**/*
111
113
- environments/aio/**/*
112
- artifacts:
113
- reports:
114
- dotenv: azimuth.env
115
114
environment:
116
115
name: aio/$CI_COMMIT_REF_SLUG
117
- url: $AZIMUTH_URL
118
116
on_stop: stop_aio
119
117
variables:
120
118
# This is normally taken from the GitLab environment name, but in this case that
121
119
# depends on the branch name so we need to be explicit about the config to use
122
120
AZIMUTH_CONFIG_ENVIRONMENT: aio
121
+ ANSIBLE_FORCE_COLOR: true
122
+ before_script:
123
+ - source ./bin/ci-setup
123
124
script:
124
- - ./bin/ci-exec provision
125
+ - ansible-playbook stackhpc.azimuth_ops.provision
126
+
127
+ #####
128
+ # This job executes tests against dynamic review environments each time they are deployed
129
+ #####
130
+ test_aio:
131
+ stage: aio_test
132
+ rules:
133
+ # Do not run for commits to main
134
+ - if: $CI_COMMIT_BRANCH == "main"
135
+ when: never
136
+ # Allow deployments to be manually triggered even when there are no changed files
137
+ - if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "web"
138
+ # Run when there is a push to a branch with a merge request that changes one of the relevant files
139
+ - if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "merge_request_event"
140
+ changes:
141
+ # Files that affect the aio environment
142
+ - env
143
+ - env.secret
144
+ - requirements.yml
145
+ - environments/base/**/*
146
+ - environments/singlenode/**/*
147
+ - environments/site/**/*
148
+ - environments/aio/**/*
149
+ environment:
150
+ name: aio/$CI_COMMIT_REF_SLUG
151
+ variables:
152
+ AZIMUTH_CONFIG_ENVIRONMENT: aio
153
+ ANSIBLE_FORCE_COLOR: true
154
+ before_script:
155
+ - source ./bin/ci-setup
156
+ script:
157
+ - ansible-playbook stackhpc.azimuth_ops.generate_tests
158
+ # Use the unrestricted application credential to execute the tests, as per the docs
159
+ - OS_CLOUD=unrestricted ./bin/run-tests
125
160
126
161
#####
127
162
# This job tears down dynamic review environments
@@ -139,7 +174,7 @@ stop_aio:
139
174
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "web"
140
175
when: manual
141
176
allow_failure: true
142
- - if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "push "
177
+ - if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "merge_request_event "
143
178
changes:
144
179
# Files that affect the aio environment
145
180
- env
@@ -157,14 +192,16 @@ stop_aio:
157
192
variables:
158
193
AZIMUTH_CONFIG_ENVIRONMENT: aio
159
194
GIT_STRATEGY: none
195
+ ANSIBLE_FORCE_COLOR: true
160
196
before_script:
161
197
- git clone ${CI_REPOSITORY_URL} ${CI_PROJECT_NAME}
162
198
- cd ${CI_PROJECT_NAME}
163
199
# Use the commit SHA if it still exists because git garbage collection hasn't run yet
164
200
# If not, assume the branch has been merged and run the destroy from main instead
165
201
- git checkout ${CI_COMMIT_SHA} || git checkout main
202
+ - source ./bin/ci-setup
166
203
script:
167
- - ./bin/ci-exec destroy
204
+ - ansible-playbook stackhpc.azimuth_ops. destroy
168
205
169
206
#####
170
207
# This job deploys Azimuth to the staging environment
@@ -192,14 +229,48 @@ deploy_staging:
192
229
- environments/site/**/*
193
230
- environments/site-ha/**/*
194
231
- environments/staging/**/*
195
- artifacts:
196
- reports:
197
- dotenv: azimuth.env
198
232
environment:
199
233
name: staging
200
- url: $AZIMUTH_URL
234
+ variables:
235
+ ANSIBLE_FORCE_COLOR: true
236
+ before_script:
237
+ - source ./bin/ci-setup
238
+ script:
239
+ - ansible-playbook stackhpc.azimuth_ops.provision
240
+
241
+ #####
242
+ # This job executes tests against the staging environment each time it is deployed
243
+ #####
244
+ test_staging:
245
+ stage: staging_test
246
+ rules:
247
+ # Prevent the job from running on any branch that is not main
248
+ - if: $CI_COMMIT_BRANCH != "main"
249
+ when: never
250
+ # Allow deployments to be manually triggered on main even when there are no changed files
251
+ - if: $CI_PIPELINE_SOURCE == "web"
252
+ # Run for commits to main that change particular files
253
+ - if: $CI_PIPELINE_SOURCE == "push"
254
+ changes:
255
+ # Files that affect the staging environment
256
+ - env
257
+ - env.secret
258
+ - requirements.yml
259
+ - environments/base/**/*
260
+ - environments/ha/**/*
261
+ - environments/site/**/*
262
+ - environments/site-ha/**/*
263
+ - environments/staging/**/*
264
+ environment:
265
+ name: staging
266
+ variables:
267
+ ANSIBLE_FORCE_COLOR: true
268
+ before_script:
269
+ - source ./bin/ci-setup
201
270
script:
202
- - ./bin/ci-exec provision
271
+ - ansible-playbook stackhpc.azimuth_ops.generate_tests
272
+ # Use the unrestricted application credential to execute the tests, as per the docs
273
+ - OS_CLOUD=unrestricted ./bin/run-tests
203
274
204
275
#####
205
276
# This job deploys Azimuth to the production environment
@@ -231,11 +302,41 @@ deploy_production:
231
302
- environments/site-ha/**/*
232
303
- environments/production/**/*
233
304
when: manual
234
- artifacts:
235
- reports:
236
- dotenv: azimuth.env
237
305
environment:
238
306
name: production
239
- url: $AZIMUTH_URL
307
+ variables:
308
+ ANSIBLE_FORCE_COLOR: true
309
+ before_script:
310
+ - source ./bin/ci-setup
311
+ script:
312
+ - ansible-playbook stackhpc.azimuth_ops.provision
313
+
314
+ #####
315
+ # This job executes tests against the production environment each time it is deployed
316
+ #####
317
+ test_production:
318
+ stage: production_test
319
+ rules:
320
+ - if: $CI_COMMIT_BRANCH != "main"
321
+ when: never
322
+ - if: $CI_PIPELINE_SOURCE == "web"
323
+ - if: $CI_PIPELINE_SOURCE == "push"
324
+ changes:
325
+ - env
326
+ - env.secret
327
+ - requirements.yml
328
+ - environments/base/**/*
329
+ - environments/ha/**/*
330
+ - environments/site/**/*
331
+ - environments/site-ha/**/*
332
+ - environments/production/**/*
333
+ environment:
334
+ name: production
335
+ variables:
336
+ ANSIBLE_FORCE_COLOR: true
337
+ before_script:
338
+ - source ./bin/ci-setup
240
339
script:
241
- - ./bin/ci-exec provision
340
+ - ansible-playbook stackhpc.azimuth_ops.generate_tests
341
+ # Use the unrestricted application credential to execute the tests, as per the docs
342
+ - OS_CLOUD=unrestricted ./bin/run-tests
0 commit comments