5
5
push :
6
6
branches :
7
7
- main
8
+ paths :
9
+ - ' **'
10
+ - ' !dev/**'
11
+ - ' dev/setup-env.sh'
12
+ - ' !docs/**'
13
+ - ' !README.md'
14
+ - ' !.gitignore'
8
15
pull_request :
16
+ paths :
17
+ - ' **'
18
+ - ' !dev/**'
19
+ - ' dev/setup-env.sh'
20
+ - ' !docs/**'
21
+ - ' !README.md'
22
+ - ' !.gitignore'
9
23
jobs :
10
24
openstack :
11
25
name : openstack-ci
@@ -23,43 +37,57 @@ jobs:
23
37
ANSIBLE_FORCE_COLOR : True
24
38
OS_CLOUD : openstack
25
39
TF_VAR_cluster_name : slurmci-${{ matrix.os_version }}-${{ github.run_number }}
26
- CI_CLOUD : ${{ vars.CI_CLOUD }}
40
+ CI_CLOUD : ${{ vars.CI_CLOUD }} # default from repo settings
27
41
TF_VAR_os_version : ${{ matrix.os_version }}
28
42
steps :
29
43
- uses : actions/checkout@v2
30
44
45
+ - name : Override CI_CLOUD if PR label is present
46
+ if : ${{ github.event_name == 'pull_request' }}
47
+ run : |
48
+ # Iterate over the labels
49
+ labels=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[].name')
50
+ echo $labels
51
+ for label in $labels; do
52
+ if [[ $label == CI_CLOUD=* ]]; then
53
+ # Extract the value after 'CI_CLOUD='
54
+ CI_CLOUD_OVERRIDE=${label#CI_CLOUD=}
55
+ echo "CI_CLOUD=${CI_CLOUD_OVERRIDE}" >> $GITHUB_ENV
56
+ fi
57
+ done
58
+
31
59
- name : Record settings for CI cloud
32
60
run : |
33
- echo CI_CLOUD: ${{ vars .CI_CLOUD }}
61
+ echo CI_CLOUD: ${{ env .CI_CLOUD }}
34
62
35
63
- name : Setup ssh
36
64
run : |
37
65
set -x
38
66
mkdir ~/.ssh
39
- echo "${{ secrets[format('{0}_SSH_KEY', vars .CI_CLOUD)] }}" > ~/.ssh/id_rsa
67
+ echo "${{ secrets[format('{0}_SSH_KEY', env .CI_CLOUD)] }}" > ~/.ssh/id_rsa
40
68
chmod 0600 ~/.ssh/id_rsa
41
69
shell : bash
42
-
70
+
43
71
- name : Add bastion's ssh key to known_hosts
44
72
run : cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
45
73
shell : bash
46
-
74
+
47
75
- name : Install ansible etc
48
76
run : dev/setup-env.sh
49
77
50
78
- name : Install OpenTofu
51
79
uses : opentofu/setup-opentofu@v1
52
80
with :
53
81
tofu_version : 1.6.2
54
-
82
+
55
83
- name : Initialise terraform
56
84
run : terraform init
57
85
working-directory : ${{ github.workspace }}/environments/.stackhpc/terraform
58
-
86
+
59
87
- name : Write clouds.yaml
60
88
run : |
61
89
mkdir -p ~/.config/openstack/
62
- echo "${{ secrets[format('{0}_CLOUDS_YAML', vars .CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
90
+ echo "${{ secrets[format('{0}_CLOUDS_YAML', env .CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
63
91
shell : bash
64
92
65
93
- name : Setup environment-specific inventory/terraform inputs
@@ -77,14 +105,14 @@ jobs:
77
105
. venv/bin/activate
78
106
. environments/.stackhpc/activate
79
107
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
80
- terraform apply -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
108
+ terraform apply -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
81
109
82
110
- name : Delete infrastructure if provisioning failed
83
111
run : |
84
112
. venv/bin/activate
85
113
. environments/.stackhpc/activate
86
114
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
87
- terraform destroy -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
115
+ terraform destroy -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
88
116
if : failure() && steps.provision_servers.outcome == 'failure'
89
117
90
118
- name : Configure cluster
@@ -111,14 +139,14 @@ jobs:
111
139
run : |
112
140
. venv/bin/activate
113
141
. environments/.stackhpc/activate
114
-
142
+
115
143
# load ansible variables into shell:
116
144
ansible-playbook ansible/ci/output_vars.yml \
117
145
-e output_vars_hosts=openondemand \
118
146
-e output_vars_path=$APPLIANCES_ENVIRONMENT_ROOT/vars.txt \
119
147
-e output_vars_items=bastion_ip,bastion_user,openondemand_servername
120
148
source $APPLIANCES_ENVIRONMENT_ROOT/vars.txt
121
-
149
+
122
150
# setup ssh proxying:
123
151
sudo apt-get --yes install proxychains
124
152
echo proxychains installed
@@ -155,7 +183,7 @@ jobs:
155
183
# ansible login -v -a "sudo scontrol reboot ASAP nextstate=RESUME reason='rebuild image:${{ steps.packer_build.outputs.NEW_COMPUTE_IMAGE_ID }}' ${TF_VAR_cluster_name}-compute-[0-3]"
156
184
# ansible compute -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
157
185
# ansible-playbook -v ansible/ci/check_slurm.yml
158
-
186
+
159
187
- name : Test reimage of login and control nodes (via rebuild adhoc)
160
188
run : |
161
189
. venv/bin/activate
@@ -164,7 +192,7 @@ jobs:
164
192
ansible all -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
165
193
ansible-playbook -v ansible/site.yml
166
194
ansible-playbook -v ansible/ci/check_slurm.yml
167
-
195
+
168
196
- name : Check sacct state survived reimage
169
197
run : |
170
198
. venv/bin/activate
@@ -182,7 +210,7 @@ jobs:
182
210
. venv/bin/activate
183
211
. environments/.stackhpc/activate
184
212
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
185
- terraform destroy -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
213
+ terraform destroy -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
186
214
if : ${{ success() || cancelled() }}
187
215
188
216
# - name: Delete images
0 commit comments