22name : Test deployment and reimage on OpenStack
33on :
44 workflow_dispatch :
5- inputs :
6- use_RL8 :
7- required : true
8- description : Include RL8 tests
9- type : boolean
10- default : false
115 push :
126 branches :
137 - main
8+ paths :
9+ - ' **'
10+ - ' !dev/**'
11+ - ' dev/setup-env.sh'
12+ - ' !docs/**'
13+ - ' !README.md'
14+ - ' !.gitignore'
1415 pull_request :
16+ paths :
17+ - ' **'
18+ - ' !dev/**'
19+ - ' dev/setup-env.sh'
20+ - ' !docs/**'
21+ - ' !README.md'
22+ - ' !.gitignore'
1523jobs :
1624 openstack :
1725 name : openstack-ci
18- concurrency : ${{ github.ref }}-{{ matrix.os_version }} # to branch/PR + OS
26+ concurrency :
27+ group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }} # to branch/PR + OS
28+ cancel-in-progress : true
1929 runs-on : ubuntu-22.04
2030 strategy :
31+ fail-fast : false # allow other matrix jobs to continue even if one fails
2132 matrix :
22- os_version : [RL8, RL9]
23- rl8_selected :
24- - ${{ inputs.use_RL8 == true }} # only potentially true for workflow_dispatch
25- rl8_branch :
26- - ${{ startsWith(github.head_ref, 'rl8') == true }} # only potentially for pull_request, always false on merge
27- rl8_label :
28- - ${{ contains(github.event.pull_request.labels.*.name, 'RL8') }} # NB: needs a new commit if added after PR created
29- exclude :
30- - os_version : RL8
31- rl8_selected : false
32- rl8_branch : false
33- rl8_label : false
33+ os_version :
34+ - RL8
35+ - RL9
3436 env :
3537 ANSIBLE_FORCE_COLOR : True
3638 OS_CLOUD : openstack
3739 TF_VAR_cluster_name : slurmci-${{ matrix.os_version }}-${{ github.run_number }}
38- CI_CLOUD : ${{ vars.CI_CLOUD }}
40+ CI_CLOUD : ${{ vars.CI_CLOUD }} # default from repo settings
41+ TF_VAR_os_version : ${{ matrix.os_version }}
3942 steps :
4043 - uses : actions/checkout@v2
4144
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+
4259 - name : Record settings for CI cloud
4360 run : |
44- echo CI_CLOUD: ${{ vars .CI_CLOUD }}
61+ echo CI_CLOUD: ${{ env .CI_CLOUD }}
4562
4663 - name : Setup ssh
4764 run : |
4865 set -x
4966 mkdir ~/.ssh
50- 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
5168 chmod 0600 ~/.ssh/id_rsa
5269 shell : bash
53-
70+
5471 - name : Add bastion's ssh key to known_hosts
5572 run : cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
5673 shell : bash
57-
74+
5875 - name : Install ansible etc
5976 run : dev/setup-env.sh
6077
6178 - name : Install OpenTofu
6279 uses : opentofu/setup-opentofu@v1
6380 with :
6481 tofu_version : 1.6.2
65-
82+
6683 - name : Initialise terraform
6784 run : terraform init
6885 working-directory : ${{ github.workspace }}/environments/.stackhpc/terraform
69-
86+
7087 - name : Write clouds.yaml
7188 run : |
7289 mkdir -p ~/.config/openstack/
73- 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
7491 shell : bash
7592
7693 - name : Setup environment-specific inventory/terraform inputs
@@ -88,19 +105,15 @@ jobs:
88105 . venv/bin/activate
89106 . environments/.stackhpc/activate
90107 cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
91- terraform apply -auto-approve -var-file="${{ vars.CI_CLOUD }}.tfvars"
92- env :
93- TF_VAR_os_version : ${{ matrix.os_version }}
108+ terraform apply -auto-approve -var-file="${{ env.CI_CLOUD }}.tfvars"
94109
95110 - name : Delete infrastructure if provisioning failed
96111 run : |
97112 . venv/bin/activate
98113 . environments/.stackhpc/activate
99114 cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
100- terraform destroy -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
115+ terraform destroy -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
101116 if : failure() && steps.provision_servers.outcome == 'failure'
102- env :
103- TF_VAR_os_version : ${{ matrix.os_version }}
104117
105118 - name : Configure cluster
106119 run : |
@@ -126,14 +139,14 @@ jobs:
126139 run : |
127140 . venv/bin/activate
128141 . environments/.stackhpc/activate
129-
142+
130143 # load ansible variables into shell:
131144 ansible-playbook ansible/ci/output_vars.yml \
132145 -e output_vars_hosts=openondemand \
133146 -e output_vars_path=$APPLIANCES_ENVIRONMENT_ROOT/vars.txt \
134147 -e output_vars_items=bastion_ip,bastion_user,openondemand_servername
135148 source $APPLIANCES_ENVIRONMENT_ROOT/vars.txt
136-
149+
137150 # setup ssh proxying:
138151 sudo apt-get --yes install proxychains
139152 echo proxychains installed
@@ -170,7 +183,7 @@ jobs:
170183 # 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]"
171184 # ansible compute -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
172185 # ansible-playbook -v ansible/ci/check_slurm.yml
173-
186+
174187 - name : Test reimage of login and control nodes (via rebuild adhoc)
175188 run : |
176189 . venv/bin/activate
@@ -179,7 +192,7 @@ jobs:
179192 ansible all -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
180193 ansible-playbook -v ansible/site.yml
181194 ansible-playbook -v ansible/ci/check_slurm.yml
182-
195+
183196 - name : Check sacct state survived reimage
184197 run : |
185198 . venv/bin/activate
@@ -197,10 +210,8 @@ jobs:
197210 . venv/bin/activate
198211 . environments/.stackhpc/activate
199212 cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
200- terraform destroy -auto-approve -var-file="${{ vars .CI_CLOUD }}.tfvars"
213+ terraform destroy -auto-approve -var-file="${{ env .CI_CLOUD }}.tfvars"
201214 if : ${{ success() || cancelled() }}
202- env :
203- TF_VAR_os_version : ${{ matrix.os_version }}
204215
205216 # - name: Delete images
206217 # run: |
0 commit comments