Skip to content

Commit

Permalink
workflow: podvm_mkosi: Take arch as input
Browse files Browse the repository at this point in the history
Rather than running the build a matrix for all archs, we
take in the arch to run via input, so we can decouple the flows.

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
  • Loading branch information
stevenhorsman committed Oct 28, 2024
1 parent 0543dd7 commit bf65fe5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/e2e_run_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,25 @@ jobs:
git_ref: ${{ inputs.git_ref }}
secrets: inherit

podvm-mkosi:
# TODO - switch to matrix for these steps with different archs
podvm-mkosi-amd64:
uses: ./.github/workflows/podvm_mkosi.yaml
with:
registry: ${{ inputs.registry }}
image_tag: ${{ inputs.podvm_image_tag }}
git_ref: ${{ inputs.git_ref }}
debug: true
arch: amd64
secrets: inherit

podvm-mkosi-s390x:
uses: ./.github/workflows/podvm_mkosi.yaml
with:
registry: ${{ inputs.registry }}
image_tag: ${{ inputs.podvm_image_tag }}
git_ref: ${{ inputs.git_ref }}
debug: true
arch: s390x
secrets: inherit

# Build and push the cloud-api-adaptor image
Expand Down
49 changes: 24 additions & 25 deletions .github/workflows/podvm_mkosi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ on:
default: false
required: false
type: boolean
arch:
description: Which arch we are building the mkosi image for
default: 'amd64'
required: false
type: string

workflow_call:
inputs:
Expand All @@ -47,6 +52,11 @@ on:
default: false
required: false
type: boolean
arch:
description: Which arch we are building the mkosi image for
default: 'amd64'
required: false
type: string

defaults:
run:
Expand All @@ -57,11 +67,7 @@ jobs:
name: Build binaries
# TODO - better to enable mechanism to check if the image of matching hash already exists and then just pull it locally
if: ${{ inputs.binaries-image == '' }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner: [S390X, ubuntu-24.04]
runs-on: ${{ inputs.arch == 's390x' && 's390x' || 'ubuntu-24.04' }}
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -130,14 +136,7 @@ jobs:

build-image:
name: Build mkosi image
runs-on: ${{ matrix.platforms.runner }}
strategy:
fail-fast: false
matrix:
platforms: [
{ arch: "amd64", runner: "ubuntu-24.04"},
{ arch: "s390x", runner: "S390X" },
]
runs-on: ${{ inputs.arch == 's390x' && 's390x' || 'ubuntu-24.04' }}
needs: [build-binaries]
if: |
always() && (
Expand Down Expand Up @@ -197,7 +196,7 @@ jobs:
sudo snap install yq
- name: Install mkosi
if: matrix.platforms.runner != 'ubuntu-24.04'
if: ${{ runner.arch }} != 'ubuntu-24.04'
run: |
git clone -b v22 https://github.com/systemd/mkosi
sudo rm -f /usr/local/bin/mkosi
Expand All @@ -212,40 +211,40 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install Nix
if: matrix.platforms.runner == 'ubuntu-24.04'
if: ${{ inputs.arch }} == 'amd64'
uses: cachix/install-nix-action@v30

- name: Build nix shell to cache dependencies
if: matrix.platforms.runner == 'ubuntu-24.04'
if: ${{ inputs.arch }} == 'amd64'
run: nix build .#devShells.x86_64-linux.podvm-mkosi

- name: Install crane with nix
if: matrix.platforms.runner == 'ubuntu-24.04'
if: ${{ inputs.arch }} == 'amd64'
run: nix profile install nixpkgs#crane

- name: Read properties from versions.yaml
if: matrix.platforms.runner != 'ubuntu-24.04'
if: ${{ inputs.arch }} == 's390x'
run: |
sudo snap install yq
go_version="$(yq '.tools.golang' versions.yaml)"
echo "GO_VERSION=${go_version}" >> "$GITHUB_ENV"
- name: Setup Golang version ${{ env.GO_VERSION }}
if: matrix.platforms.runner != 'ubuntu-24.04'
if: ${{ inputs.arch }} == 's390x'
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Install crane with go
if: matrix.platforms.runner != 'ubuntu-24.04'
if: ${{ inputs.arch }} == 's390x'
run: |
go install github.com/google/go-containerregistry/cmd/crane@latest
echo "PATH=${PATH}:`go env GOPATH`/bin" >> $GITHUB_ENV
# This removes the checkout and creates a btrfs volume with maximized
# build space.
- name: Maximize build space
if: matrix.platforms.runner == 'ubuntu-24.04'
if: ${{ inputs.arch }} == 'amd64'
uses: katexochen/maximize-build-space@btrfs
with:
swap-size-mb: 1024
Expand All @@ -256,7 +255,7 @@ jobs:
remove-docker-images: "true"

- name: Second checkout
if: matrix.platforms.runner == 'ubuntu-24.04'
if: ${{ inputs.arch }} == 'amd64'
uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -275,7 +274,7 @@ jobs:
id: binaries-image
run: |
if [ -z "${{ inputs.binaries-image }}" ]; then
echo "image=${{ inputs.registry }}/podvm-binaries-fedora-${{ matrix.platforms.arch }}:${{ steps.image_tag.outputs.image_tag }}" | tee -a "$GITHUB_OUTPUT"
echo "image=${{ inputs.registry }}/podvm-binaries-fedora-${{ inputs.arch }}:${{ steps.image_tag.outputs.image_tag }}" | tee -a "$GITHUB_OUTPUT"
else
echo "image=${{ inputs.binaries-image }}" | tee -a "$GITHUB_OUTPUT"
fi
Expand Down Expand Up @@ -316,12 +315,12 @@ jobs:
image=${image}-debug
fi
tag=${{ steps.image_tag.outputs.image_tag }}
arch_tag=${tag}_-${{ matrix.platforms.arch }}
arch_tag=${tag}_-${{ inputs.arch }}
oras push "${image}:${arch_tag}" podvm-*.qcow2
# We need to create the platform annotations with docker, since oras 1.2 doesn't support
# pushing with platform yet.
docker manifest create "${image}:${tag}" --amend "${image}:${arch_tag}"
docker manifest annotate --arch "${{ matrix.platforms.arch }}" --os linux "${image}:${tag}" "${image}:${arch_tag}"
docker manifest annotate --arch "${{ inputs.arch }}" --os linux "${image}:${tag}" "${image}:${arch_tag}"
docker manifest push "${image}:${tag}"
# add image and digest to output for attestation
echo "image=${image}" >> "$GITHUB_OUTPUT"
Expand Down

0 comments on commit bf65fe5

Please sign in to comment.