Skip to content

Commit a694dab

Browse files
committed
add workflow to test doca build
1 parent 6e650af commit a694dab

File tree

2 files changed

+144
-42
lines changed

2 files changed

+144
-42
lines changed

.github/workflows/doca.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Test DOCA extra build
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**'
9+
- '!dev/**'
10+
- 'dev/setup-env.sh'
11+
- '!docs/**'
12+
- '!README.md'
13+
- '!.gitignore'
14+
- '!.github/workflows/'
15+
- '.github/workflows/doca'
16+
pull_request:
17+
paths:
18+
- '**'
19+
- '!dev/**'
20+
- 'dev/setup-env.sh'
21+
- '!docs/**'
22+
- '!README.md'
23+
- '!.gitignore'
24+
- '!.github/workflows/'
25+
- '.github/workflows/doca'
26+
27+
jobs:
28+
openstack:
29+
name: openstack-docabuild
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build.label }} # to branch/PR + OS
32+
cancel-in-progress: true
33+
runs-on: ubuntu-22.04
34+
strategy:
35+
fail-fast: false # allow other matrix jobs to continue even if one fails
36+
matrix: # build RL8, RL9
37+
build:
38+
- label: RL8
39+
source_image_name: rocky-latest-RL8
40+
- label: RL9
41+
source_image_name: rocky-latest-RL9
42+
env:
43+
ANSIBLE_FORCE_COLOR: True
44+
OS_CLOUD: openstack
45+
CI_CLOUD: ${{ github.event.inputs.ci_cloud }}
46+
ARK_PASSWORD: ${{ secrets.ARK_PASSWORD }}
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Record settings for CI cloud
52+
run: |
53+
echo CI_CLOUD: ${{ env.CI_CLOUD }}
54+
55+
- name: Setup ssh
56+
run: |
57+
set -x
58+
mkdir ~/.ssh
59+
echo "${{ secrets[format('{0}_SSH_KEY', env.CI_CLOUD)] }}" > ~/.ssh/id_rsa
60+
chmod 0600 ~/.ssh/id_rsa
61+
shell: bash
62+
63+
- name: Add bastion's ssh key to known_hosts
64+
run: cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
65+
shell: bash
66+
67+
- name: Install ansible etc
68+
run: dev/setup-env.sh
69+
70+
- name: Write clouds.yaml
71+
run: |
72+
mkdir -p ~/.config/openstack/
73+
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
74+
shell: bash
75+
76+
- name: Setup environment
77+
run: |
78+
. venv/bin/activate
79+
. environments/.stackhpc/activate
80+
81+
- name: Build fat image with packer
82+
id: packer_build
83+
run: |
84+
set -x
85+
. venv/bin/activate
86+
. environments/.stackhpc/activate
87+
cd packer/
88+
packer init .
89+
90+
PACKER_LOG=1 packer build \
91+
-on-error=${{ vars.PACKER_ON_ERROR }} \
92+
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
93+
-var "source_image_name=${{ matrix.build.source_image_name }}" \
94+
-var "image_name=openhpc-doca" \
95+
openstack.pkr.hcl
96+
97+
- name: Get created image names from manifest
98+
id: manifest
99+
run: |
100+
. venv/bin/activate
101+
IMAGE_ID=$(jq --raw-output '.builds[-1].artifact_id' packer/packer-manifest.json)
102+
while ! openstack image show -f value -c name $IMAGE_ID; do
103+
sleep 5
104+
done
105+
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
106+
echo $IMAGE_ID > image-id.txt
107+
echo $IMAGE_NAME > image-name.txt
108+
109+
- name: Upload manifest artifact
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: image-details-openhpc-${{ matrix.label }}
113+
path: |
114+
./image-id.txt
115+
./image-name.txt
116+
overwrite: true

packer/openstack.pkr.hcl

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ data "git-commit" "cwd-head" { }
2323
locals {
2424
git_commit = data.git-commit.cwd-head.hash
2525
timestamp = formatdate("YYMMDD-hhmm", timestamp())
26+
image_name_version = var.image_name_version == "auto" ? "-${local.timestamp}-${substr(local.git_commit, 0, 8)}" : var.image_name_version
2627
}
2728

2829
# Path pointing to root of repository - automatically set by environment variable PKR_VAR_repo_root
@@ -39,12 +40,6 @@ variable "networks" {
3940
type = list(string)
4041
}
4142

42-
variable "os_version" {
43-
type = string
44-
description = "'RL8' or 'RL9' with default source_image_* mappings"
45-
default = "RL9"
46-
}
47-
4843
# Must supply either source_image_name or source_image_id
4944
variable "source_image_name" {
5045
type = string
@@ -123,15 +118,6 @@ variable "volume_type" {
123118
}
124119

125120
variable "volume_size" {
126-
type = map(number)
127-
default = {
128-
# fat image builds, GB:
129-
rocky-latest = 15
130-
openhpc = 15
131-
}
132-
}
133-
134-
variable "extra_build_volume_size" {
135121
type = number
136122
default = 15
137123
}
@@ -147,34 +133,35 @@ variable "metadata" {
147133
}
148134

149135
variable "groups" {
150-
type = map(list(string))
151-
description = "Additional inventory groups (other than 'builder') to add build VM to, keyed by source name"
152-
default = {
153-
# fat image builds:
154-
rocky-latest = ["update"]
155-
openhpc = ["control", "compute", "login"]
156-
}
136+
type = string
137+
description = "Comma-separated list of additional inventory groups (other than 'builder') to add build VM to"
138+
default = "" # this is
139+
# rocky-latest = ["update"]
140+
# openhpc = ["control", "compute", "login"]
157141
}
158142

159-
variable "extra_build_groups" {
160-
type = list(string)
161-
default = []
143+
variable "image_name" {
144+
type = string
145+
description = "Name of image"
146+
default = "openhpc"
162147
}
163148

164-
variable "extra_build_image_name" {
149+
variable "image_name_version" {
165150
type = string
166-
description = "Infix for 'extra' build image name"
167-
default = "extra"
151+
description = "Suffix for image name giving version. Default of 'auto' appends timestamp + short commit"
152+
default = "auto"
168153
}
169154

170155
source "openstack" "openhpc" {
171156
# Build VM:
172157
flavor = var.flavor
173158
use_blockstorage_volume = var.use_blockstorage_volume
174159
volume_type = var.volume_type
175-
volume_size = lookup(var.volume_size, source.name, var.extra_build_volume_size)
160+
volume_size = var.volume_size
176161
metadata = var.metadata
177-
instance_metadata = {ansible_init_disable = "true"}
162+
instance_metadata = {
163+
ansible_init_disable = "true"
164+
}
178165
networks = var.networks
179166
floating_ip_network = var.floating_ip_network
180167
security_groups = var.security_groups
@@ -201,26 +188,25 @@ source "openstack" "openhpc" {
201188
build {
202189

203190
# latest nightly image:
204-
source "source.openstack.openhpc" {
205-
name = "rocky-latest"
206-
image_name = "${source.name}-${var.os_version}"
207-
}
191+
# source "source.openstack.openhpc" {
192+
# name = "rocky-latest"
193+
# image_name = "${source.name}-${var.os_version}"
194+
# }
208195

209196
# fat image:
210197
source "source.openstack.openhpc" {
211-
name = "openhpc"
212-
image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}"
198+
image_name = "${var.image_name}${local.image_name_version}"
213199
}
214200

215-
# Extended site-specific image, built on fat image:
216-
source "source.openstack.openhpc" {
217-
name = "openhpc-extra"
218-
image_name = "openhpc-${var.extra_build_image_name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}"
219-
}
201+
# # Extended site-specific image, built on fat image:
202+
# source "source.openstack.openhpc" {
203+
# name = "openhpc-extra"
204+
# image_name = "openhpc-${var.extra_build_image_name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}"
205+
# }
220206

221207
provisioner "ansible" {
222208
playbook_file = "${var.repo_root}/ansible/fatimage.yml"
223-
groups = concat(["builder"], lookup(var.groups, source.name, var.extra_build_groups))
209+
groups = concat(["builder"], split(",", var.groups))
224210
keep_inventory_file = true # for debugging
225211
use_proxy = false # see https://www.packer.io/docs/provisioners/ansible#troubleshooting
226212
extra_arguments = [

0 commit comments

Comments
 (0)