From bf65fe5bd6995ed9668132c63539170b7ba31ad3 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Fri, 25 Oct 2024 16:30:13 +0100 Subject: [PATCH] workflow: podvm_mkosi: Take arch as input 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 --- .github/workflows/e2e_run_all.yaml | 14 ++++++++- .github/workflows/podvm_mkosi.yaml | 49 +++++++++++++++--------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.github/workflows/e2e_run_all.yaml b/.github/workflows/e2e_run_all.yaml index ff43c8158..46c6aa0b9 100644 --- a/.github/workflows/e2e_run_all.yaml +++ b/.github/workflows/e2e_run_all.yaml @@ -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 diff --git a/.github/workflows/podvm_mkosi.yaml b/.github/workflows/podvm_mkosi.yaml index d35bd0eb9..a072b8a10 100644 --- a/.github/workflows/podvm_mkosi.yaml +++ b/.github/workflows/podvm_mkosi.yaml @@ -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: @@ -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: @@ -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 @@ -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() && ( @@ -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 @@ -212,32 +211,32 @@ 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 @@ -245,7 +244,7 @@ jobs: # 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 @@ -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 @@ -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 @@ -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"