Skip to content

Commit 0e85dae

Browse files
committed
Add GCP images for AlmaLinux 8, 9, and 10
1 parent 0c6942c commit 0e85dae

24 files changed

+2126
-162
lines changed

.github/actions/shared-steps/action.yml

Lines changed: 174 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ inputs:
4141
runs:
4242
using: "composite"
4343
steps:
44+
- uses: runs-on/action@v2
45+
# only in the AlmaLinux namespace where we are using runs-on
46+
if: github.repository_owner == 'AlmaLinux'
47+
with:
48+
metrics: cpu,network,memory,disk,io
4449

4550
- name: Runner OS, install extra packages
4651
shell: bash
@@ -73,14 +78,15 @@ runs:
7378
echo "version_major=${version_major}" >> $GITHUB_ENV
7479
echo "alma_arch=${alma_arch}" >> $GITHUB_ENV
7580
76-
- name: Prepare staff
81+
- name: Prepare stuff
7782
shell: bash
7883
run: |
79-
# Prepare staff
84+
# Prepare stuff
85+
packer_opts=
8086
case ${{ env.runner_os }} in
8187
ubuntu)
8288
# Packer options
83-
packer_opts="-var ovmf_code=/usr/share/OVMF/OVMF_CODE_4M.fd -var ovmf_vars=/usr/share/OVMF/OVMF_VARS_4M.fd"
89+
packer_opts="-var qemu_binary=/usr/bin/qemu-system-${{ inputs.arch }} -var ovmf_code=/usr/share/OVMF/OVMF_CODE_4M.fd -var ovmf_vars=/usr/share/OVMF/OVMF_VARS_4M.fd"
8490
;;
8591
rhel)
8692
# Packer options
@@ -114,6 +120,10 @@ runs:
114120
# AWS S3 path to store images
115121
aws_s3_path=images/${{ env.version_major }}/${release}/${{ inputs.type }}/${{ env.TIME_STAMP }}
116122
123+
# tell packer we can use more cpu/ram if we're in the almalinux namespace
124+
# which means we're using runs-on with metal instances
125+
[[ ${{ github.repository_owner }} == 'AlmaLinux' ]] && packer_opts="${packer_opts} -var cpus=$(($(nproc)-4)) -var memory_${{ env.alma_arch }}=32768"
126+
117127
# Overriding packer source, image mask and S3 path where necessary
118128
case "${{ inputs.type }}${{ env.version_major }}" in
119129
azure8|azure9)
@@ -228,6 +238,17 @@ runs:
228238
output_mask=output-${packer_source}/AlmaLinux-*.${{ env.alma_arch }}*.qcow2
229239
packer_source=qemu.${packer_source}
230240
;;
241+
gcp8|gcp9)
242+
output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
243+
packer_source=qemu.${packer_source}
244+
;;
245+
gcp10)
246+
packer_source=almalinux_${{ env.version_major }}_${{ inputs.type }}_${{ env.alma_arch }}
247+
[[ ${{ env.version_major }} == *"v2"* ]] && packer_source="${packer_source}_v2"
248+
[[ ${{ inputs.variant }} == *"64k"* ]] && packer_source="almalinux_${{ env.version_major }}_${{ inputs.type }}_64k_${{ env.alma_arch }}"
249+
output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
250+
packer_source=qemu.${packer_source}
251+
;;
231252
*)
232253
output_mask=output-${output_mask}
233254
packer_source=qemu.${packer_source}
@@ -260,8 +281,24 @@ runs:
260281
;;
261282
esac
262283
284+
- name: Remove KVM
285+
if: inputs.type == 'vagrant_virtualbox' || inputs.type == 'vagrant_vmware'
286+
shell: bash
287+
run: |
288+
# Remove KVM
289+
case ${{ env.runner_os }} in
290+
ubuntu)
291+
sudo apt-get -y remove qemu-kvm
292+
;;
293+
rhel)
294+
sudo dnf -y -q remove qemu-kvm
295+
;;
296+
esac
297+
sudo rmmod kvm_amd || sudo rmmod kvm_intel || true
298+
sudo rmmod kvm || true
299+
263300
- name: Check nested virtualization support
264-
if: inputs.arch == 'x86_64' && inputs.type != 'vagrant_virtualbox' && inputs.type != 'vagrant_vmware' && inputs.runner != 'aws-ec2'
301+
if: inputs.arch == 'x86_64' && env.RUNS_ON_VERSION == '' && inputs.type != 'vagrant_virtualbox' && inputs.type != 'vagrant_vmware'
265302
shell: bash
266303
run: |
267304
# Check nested virtualization support
@@ -365,12 +402,13 @@ runs:
365402
run: |
366403
# Build ${{ inputs.type }} image
367404
# PACKER_LOG=1
405+
sudo systemctl start libvirtd
368406
sudo sh -c "/usr/bin/packer build ${{ env.PACKER_OPTS }} -only=${{ env.packer_source }} ."
369407
370408
- name: Locate image file, generate checksum
371409
shell: bash
372410
run: |
373-
# Locate image file, generate checksum
411+
# Locate image file, generate checksum, rename repo metadata file
374412
ls -la $(dirname '${{ env.output_mask }}')
375413
image_file=$(ls -1 ${{ env.output_mask }} | head -n 1)
376414
[ "x${image_file}" = "x" ] && false
@@ -380,8 +418,127 @@ runs:
380418
echo "IMAGE_FILE=${image_file}" >> $GITHUB_ENV
381419
echo "IMAGE_NAME=$(basename ${image_file})" >> $GITHUB_ENV
382420
383-
# - name: Setup tmate session
384-
# uses: mxschmitt/action-tmate@v3
421+
# don't fail if this doesn't exist, we may not always generate it
422+
sudo mv repo-metadata-*.txt $(basename ${image_file}).repo-metadata.txt || true
423+
424+
- id: 'google-auth-dev-images'
425+
if: env.IMAGE_TYPE == 'gcp'
426+
uses: 'google-github-actions/auth@v2'
427+
with:
428+
workload_identity_provider: 'projects/443728870479/locations/global/workloadIdentityPools/github-actions/providers/github'
429+
service_account: 'github-actions-cloud-images@almalinux-dev-images-469421.iam.gserviceaccount.com'
430+
431+
- name: 'Set up Google Cloud SDK'
432+
if: env.IMAGE_TYPE == 'gcp'
433+
uses: 'google-github-actions/setup-gcloud@v3.0.0'
434+
435+
- name: 'Upload output to GCP storage bucket'
436+
if: env.IMAGE_TYPE == 'gcp'
437+
shell: bash
438+
run: gcloud storage cp ${{ env.IMAGE_FILE }} gs://almalinux-images-dev/almalinux-${version_major}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}-v$(date +'%Y%m%d')/root.tar.gz
439+
440+
# - name: Create image on GCP
441+
# if: env.IMAGE_TYPE == 'gcp'
442+
# shell: bash
443+
# run: |
444+
# # Create image on GCP
445+
# gcloud --project almalinux-dev-images-469421 compute images create \
446+
# almalinux-${{ env.version_major }}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}-v$(date +'%Y%m%d') \
447+
# --description="AlmaLinux, AlmaLinux, ${{ env.version_major }}, ${{ inputs.arch }} built on $(date +'%Y%m%d')" \
448+
# --source-uri gs://almalinux-images-dev/${{ env.IMAGE_NAME }} \
449+
# --guest-os-features=GVNIC,UEFI_COMPATIBLE,VIRTIO_SCSI_MULTIQUEUE,SEV_CAPABLE,SEV_LIVE_MIGRATABLE,IDPF \
450+
# --family almalinux-${{ env.version_major }}${{ inputs.arch == 'aarch64' && '-arm64' || '' }} \
451+
# --architecture=${{ inputs.arch == 'x86_64' && 'X86_64' || 'ARM64' }} \
452+
# --labels=public-image=true
453+
454+
- name: Clone gce_image_publish repo
455+
if: env.IMAGE_TYPE == 'gcp'
456+
uses: actions/checkout@v5
457+
with:
458+
path: compute-image-tools
459+
repository: GoogleCloudPlatform/compute-image-tools
460+
ref: "20250916.00"
461+
462+
- name: Build gce_image_publish tool
463+
if: env.IMAGE_TYPE == 'gcp'
464+
shell: bash
465+
run: |
466+
# we need golang
467+
case ${{ env.runner_os }} in
468+
ubuntu)
469+
sudo apt update
470+
sudo apt-get -y install golang-go
471+
;;
472+
rhel)
473+
sudo dnf -y -q install golang
474+
;;
475+
esac
476+
# print golang version for reference
477+
go version
478+
# Build gce_image_publish tool
479+
cd compute-image-tools/cli_tools/gce_image_publish
480+
go mod tidy
481+
go install
482+
483+
- name: Create test image on GCP
484+
if: env.IMAGE_TYPE == 'gcp'
485+
shell: bash
486+
run: |
487+
/home/$USER/go/bin/gce_image_publish \
488+
-var:environment=test \
489+
-skip_confirmation \
490+
-rollout_rate=0 \
491+
-publish_project="almalinux-dev-images-469421" \
492+
-work_project="almalinux-dev-images-469421" \
493+
-replace \
494+
-source_gcs_path="gs://almalinux-images-dev/" \
495+
vm-scripts/gcp/almalinux_${version_major}${{ inputs.arch == 'aarch64' && '_arm64' || '' }}.publish.json
496+
497+
- id: 'google-auth-image-testing'
498+
if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
499+
uses: 'google-github-actions/auth@v2'
500+
with:
501+
workload_identity_provider: 'projects/527193872801/locations/global/workloadIdentityPools/github-actions/providers/github'
502+
service_account: 'github-actions-image-testing@almalinux-image-testing-469421.iam.gserviceaccount.com'
503+
504+
- name: 'Set up Google Cloud SDK'
505+
if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
506+
uses: 'google-github-actions/setup-gcloud@v3.0.0'
507+
508+
- name: 'Clone Google cloud-image-testing repo'
509+
if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
510+
uses: actions/checkout@v5
511+
with:
512+
path: cloud-image-tests
513+
#repository: GoogleCloudPlatform/cloud-image-tests
514+
repository: jonathanspw/cloud-image-tests
515+
ref: "local_build_fixes"
516+
517+
# - name: 'Build Google cloud-image-testing docker image'
518+
# if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
519+
# shell: bash
520+
# run: |
521+
# cd cloud-image-tests
522+
# docker build -t cloud-image-tests -f Dockerfile .
523+
524+
- name: Build Google cloud-image-testing manager
525+
if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
526+
shell: bash
527+
run: |
528+
cd cloud-image-tests
529+
./local_build.sh -j $(nproc) -o bin
530+
531+
- name: 'Run Google cloud-image-testing tests (basic suite)'
532+
if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
533+
shell: bash
534+
run: |
535+
cd cloud-image-tests
536+
./bin/manager \
537+
-local_path bin \
538+
-project almalinux-image-testing-469421 \
539+
-filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|lssd|disk|packagevalidation|ssh|metadata|vmspec)$' \
540+
-images 'projects/almalinux-dev-images-469421/global/images/family/almalinux-${{ env.version_major }}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}' \
541+
-parallel_stagger 10s -parallel_count 20
385542
386543
- name: Test ${{ inputs.type }} ${{ inputs.variant }} image
387544
# Skip testing for vagrant_virtualbox on GH runner because 'vugrant up' fails to connect to the newly created VM via ssh:
@@ -474,6 +631,15 @@ runs:
474631
name: ${{ env.IMAGE_NAME }}
475632
path: ${{ env.IMAGE_FILE }}
476633

634+
- uses: actions/upload-artifact@v4
635+
name: Store repo metadata as artifact
636+
id: repo-meta-artifact
637+
if: inputs.store_as_artifact == 'true'
638+
with:
639+
compression-level: 9
640+
name: ${{ env.IMAGE_NAME }}.repo-metadata.txt
641+
path: ${{ env.IMAGE_FILE }}.repo-metadata.txt
642+
477643
- uses: actions/upload-artifact@v4
478644
name: Store checksum as artifact
479645
id: checksum-artifact
@@ -488,7 +654,7 @@ runs:
488654
id: pkglist-artifact
489655
if: inputs.store_as_artifact == 'true' && env.got_pkgs_list == 'true'
490656
with:
491-
compression-level: 1
657+
compression-level: 9
492658
name: ${{ env.IMAGE_NAME }}.txt
493659
path: ${{ env.IMAGE_FILE }}.txt
494660

0 commit comments

Comments
 (0)