1
- name : Upload CI-tested images to Arcus S3 and sync clouds
1
+ name : Build fat image
2
2
on :
3
3
workflow_dispatch :
4
- push :
5
- branches :
6
- - main
7
- paths :
8
- - ' environments/.stackhpc/terraform/cluster_image.auto.tfvars.json'
9
- env :
10
- S3_BUCKET : openhpc-images-prerelease
11
- IMAGE_PATH : environments/.stackhpc/terraform/cluster_image.auto.tfvars.json
4
+ inputs :
5
+ ci_cloud :
6
+ description : ' Select the CI_CLOUD'
7
+ required : true
8
+ type : choice
9
+ options :
10
+ - LEAFCLOUD
11
+ - SMS
12
+ - ARCUS
12
13
13
14
jobs :
14
- s3_cleanup :
15
+ openstack :
16
+ name : openstack-imagebuild
17
+ concurrency :
18
+ group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }}-${{ matrix.build }} # to branch/PR + OS + build
19
+ cancel-in-progress : true
15
20
runs-on : ubuntu-22.04
16
- concurrency : ${{ github.workflow }}-${{ github.ref }}
17
21
strategy :
18
- fail-fast : false
19
- steps :
20
- - uses : actions/checkout@v2
21
-
22
- - name : Write s3cmd configuration
23
- run : |
24
- echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg
25
- shell : bash
26
-
27
- - name : Install s3cmd
28
- run : |
29
- sudo apt-get --yes install s3cmd
30
-
31
- - name : Cleanup S3 bucket
32
- run : |
33
- s3cmd rm s3://${{ env.S3_BUCKET }} --recursive --force
34
-
35
- image_upload :
36
- runs-on : ubuntu-22.04
37
- needs : s3_cleanup
38
- concurrency : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build }}
39
- strategy :
40
- fail-fast : false
41
- matrix :
42
- build :
22
+ fail-fast : false # allow other matrix jobs to continue even if one fails
23
+ matrix : # build RL8+OFED, RL9+OFED, RL9+OFED+CUDA versions
24
+ os_version :
43
25
- RL8
44
26
- RL9
45
- - RL9-cuda
27
+ build :
28
+ - openstack.openhpc
29
+ - openstack.openhpc-cuda
30
+ exclude :
31
+ - os_version : RL8
32
+ build : openstack.openhpc-cuda
46
33
env :
47
34
ANSIBLE_FORCE_COLOR : True
48
35
OS_CLOUD : openstack
49
- CI_CLOUD : ${{ vars.CI_CLOUD }}
36
+ CI_CLOUD : ${{ github.event.inputs.ci_cloud }}
37
+ SOURCE_IMAGES_MAP : |
38
+ {
39
+ "RL8": {
40
+ "openstack.openhpc": "rocky-latest-RL8",
41
+ "openstack.openhpc-cuda": "rocky-latest-cuda-RL8"
42
+ },
43
+ "RL9": {
44
+ "openstack.openhpc": "rocky-latest-RL9",
45
+ "openstack.openhpc-cuda": "rocky-latest-cuda-RL9"
46
+ }
47
+ }
48
+
50
49
steps :
51
50
- uses : actions/checkout@v2
52
51
53
- - name : Record which cloud CI is running on
52
+ - name : Record settings for CI cloud
54
53
run : |
55
54
echo CI_CLOUD: ${{ env.CI_CLOUD }}
56
55
57
- - name : setup environment
56
+ - name : Setup ssh
58
57
run : |
59
- python3 -m venv venv
60
- . venv/bin/activate
61
- pip install -U pip
62
- pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt)
63
- shell : bash
64
-
65
- - name : Write clouds.yaml
66
- run : |
67
- mkdir -p ~/.config/openstack/
68
- echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
58
+ set -x
59
+ mkdir ~/.ssh
60
+ echo "${{ secrets[format('{0}_SSH_KEY', env.CI_CLOUD)] }}" > ~/.ssh/id_rsa
61
+ chmod 0600 ~/.ssh/id_rsa
69
62
shell : bash
70
63
71
- - name : Write s3cmd configuration
72
- run : |
73
- echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg
64
+ - name : Add bastion's ssh key to known_hosts
65
+ run : cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
74
66
shell : bash
75
67
76
- - name : Install s3cmd
77
- run : |
78
- sudo apt-get --yes install s3cmd
79
-
80
- - name : Retrieve image name
81
- run : |
82
- TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}")
83
- echo "TARGET_IMAGE=${TARGET_IMAGE}" >> "$GITHUB_ENV"
84
- shell : bash
85
-
86
- - name : Download image to runner
87
- run : |
88
- . venv/bin/activate
89
- openstack image save --file ${{ env.TARGET_IMAGE }} ${{ env.TARGET_IMAGE }}
90
- shell : bash
91
-
92
- - name : Upload Image to S3
93
- run : |
94
- echo "Uploading Image: ${{ env.TARGET_IMAGE }} to S3..."
95
- s3cmd --multipart-chunk-size-mb=150 put ${{ env.TARGET_IMAGE }} s3://${{ env.S3_BUCKET }}
96
- shell : bash
97
-
98
- image_sync :
99
- needs : image_upload
100
- runs-on : ubuntu-22.04
101
- concurrency : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.cloud }}-${{ matrix.build }}
102
- strategy :
103
- fail-fast : false
104
- matrix :
105
- cloud :
106
- - LEAFCLOUD
107
- - SMS
108
- - ARCUS
109
- build :
110
- - RL8
111
- - RL9
112
- - RL9-cuda
113
- exclude :
114
- - cloud : LEAFCLOUD
115
-
116
- env :
117
- ANSIBLE_FORCE_COLOR : True
118
- OS_CLOUD : openstack
119
- CI_CLOUD : ${{ matrix.cloud }}
120
- steps :
121
- - uses : actions/checkout@v2
122
-
123
- - name : Record which cloud CI is running on
124
- run : |
125
- echo CI_CLOUD: ${{ env.CI_CLOUD }}
126
-
127
- - name : setup environment
128
- run : |
129
- python3 -m venv venv
130
- . venv/bin/activate
131
- pip install -U pip
132
- pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt)
133
- shell : bash
68
+ - name : Install ansible etc
69
+ run : dev/setup-env.sh
134
70
135
71
- name : Write clouds.yaml
136
72
run : |
137
73
mkdir -p ~/.config/openstack/
138
74
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
139
75
shell : bash
140
76
141
- - name : Retrieve image name
77
+ - name : Setup environment
142
78
run : |
143
- TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}")
144
- echo "TARGET_IMAGE=${TARGET_IMAGE}" >> "$GITHUB_ENV"
79
+ . venv/bin/activate
80
+ . environments/.stackhpc/activate
145
81
146
- - name : Download latest image if missing
82
+ - name : Build fat image with packer
83
+ id : packer_build
147
84
run : |
85
+ set -x
148
86
. venv/bin/activate
149
- bash .github/bin/get-s3-image.sh ${{ env.TARGET_IMAGE }} ${{ env.S3_BUCKET }}
150
-
151
- - name : Cleanup OpenStack Image (on error or cancellation)
152
- if : cancelled()
87
+ . environments/.stackhpc/activate
88
+ cd packer/
89
+ packer init .
90
+
91
+ PACKER_LOG=1 packer build \
92
+ -on-error=${{ vars.PACKER_ON_ERROR }} \
93
+ -only=${{ matrix.build }} \
94
+ -var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
95
+ -var "source_image_name=${{ env.SOURCE_IMAGE }}" \
96
+ openstack.pkr.hcl
97
+ env :
98
+ PKR_VAR_os_version : ${{ matrix.os_version }}
99
+ SOURCE_IMAGE : ${{ fromJSON(env.SOURCE_IMAGES_MAP)[matrix.os_version][matrix.build] }}
100
+
101
+ - name : Get created image names from manifest
102
+ id : manifest
153
103
run : |
154
104
. venv/bin/activate
155
- image_hanging=$(openstack image list --name ${{ env.TARGET_IMAGE }} -f value -c ID -c Status | grep -v ' active$' | awk '{print $1}')
156
- if [ -n "$image_hanging" ]; then
157
- echo "Cleaning up OpenStack image with ID: $image_hanging"
158
- openstack image delete $image_hanging
159
- else
160
- echo "No image ID found, skipping cleanup."
161
- fi
162
- shell : bash
105
+ IMAGE_ID=$(jq --raw-output '.builds[-1].artifact_id' packer/packer-manifest.json)
106
+ while ! openstack image show -f value -c name $IMAGE_ID; do
107
+ sleep 5
108
+ done
109
+ IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
110
+ echo $IMAGE_ID > image-id.txt
111
+ echo $IMAGE_NAME > image-name.txt
112
+
113
+ - name : Upload manifest artifact
114
+ uses : actions/upload-artifact@v4
115
+ with :
116
+ name : image-details-${{ matrix.build }}-${{ matrix.os_version }}
117
+ path : |
118
+ ./image-id.txt
119
+ ./image-name.txt
120
+ overwrite : true
0 commit comments