From 7bba87c10823506b8ff3d15985b0bd527464a58c Mon Sep 17 00:00:00 2001 From: Benjamin Sherman Date: Sat, 3 Aug 2024 14:14:18 -0500 Subject: [PATCH] chore(ci): handle varied kernel releases for coreos (#23) * chore(ci): handle varied kernel releases for coreos This changes the workflow to check coreos kernel package expectaions against koji before deciding the selected kernel version is valid. * fix variable usage, add some more logs * fix final assigned coreos kernel, tweak logs --- .github/workflows/reusable-build.yml | 52 ++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 98f6f30..16e1e3a 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -73,6 +73,49 @@ jobs: $dnf install -y dnf-plugins-core fi + coreos_kernel () { + coreos_version=${1} + image_linux=$(skopeo inspect docker://quay.io/fedora/fedora-coreos:${coreos_version} | jq -r '.Labels["ostree.linux"]') + major_minor_patch=$(echo $image_linux | grep -oP '^\d+\.\d+\.\d+') + kernel_rel_part=$(echo $image_linux | grep -oP '^\d+\.\d+\.\d+\-\K([123][0]{2})') + arch=$(echo $image_linux | grep -oP 'fc\d+\.\K.*$') + + kernel_rel="$kernel_rel_part.fc${{ matrix.fedora_version }}" + kernel_version="$major_minor_patch-$kernel_rel.$arch" + URL="https://kojipkgs.fedoraproject.org/packages/kernel/"$major_minor_patch"/"$kernel_rel"/"$arch"/kernel-"$kernel_version".rpm" + echo "Querying koji for ${coreos_version} kernel: $kernel_version" + echo "$URL" + HTTP_RESP=$(curl -sI "$URL" | grep ^HTTP) + if grep -qv "200 OK" <<< "${HTTP_RESP}"; then + echo "Koji failed to find $coreos_version kernel: $kernel_version" + case "$kernel_rel_part" in + "300") + kernel_rel_part="200" + ;; + "200") + kernel_rel_part="100" + ;; + "100") + ;; + *) + echo "unexpected kernel_rel_part ${kernel_rel_part}" + ;; + esac + kernel_rel="$kernel_rel_part.fc${{ matrix.fedora_version }}" + kernel_version="$major_minor_patch-$kernel_rel.$arch" + URL="https://kojipkgs.fedoraproject.org/packages/kernel/"$major_minor_patch"/"$kernel_rel"/"$arch"/kernel-"$kernel_version".rpm" + echo "Re-querying koji for ${coreos_version} kernel: $kernel_version" + echo "$URL" + HTTP_RESP=$(curl -sI "$URL" | grep ^HTTP) + if grep -qv "200 OK" <<< "${HTTP_RESP}"; then + echo "Koji failed to find $coreos_version kernel: $kernel_version" + fi + fi + if grep -q "200 OK" <<< "${HTTP_RESP}"; then + linux=$kernel_version + fi + } + case ${{ matrix.kernel_flavor }} in "asus") $dnf copr enable -y lukenukem/asus-kernel @@ -90,15 +133,10 @@ jobs: linux=$(skopeo inspect docker://quay.io/fedora-ostree-desktops/base:${{ matrix.fedora_version }} | jq -r '.Labels["ostree.linux"]' ) ;; "coreos-stable") - linux=$(skopeo inspect docker://quay.io/fedora/fedora-coreos:stable | jq -r '.Labels["ostree.linux"]' ) - coreos_fedora_version=$(echo $linux | grep -oP 'fc\K[0-9]+') - if [[ "${{ matrix.fedora_version }}" != "$coreos_fedora_version" ]]; then - major_minor_patch=$(echo $linux | cut -d - -f 1) - linux="${major_minor_patch}-200.fc${{ matrix.fedora_version }}.$(uname -m)" - fi + coreos_kernel stable ;; "coreos-testing") - linux=$(skopeo inspect docker://quay.io/fedora/fedora-coreos:testing | jq -r '.Labels["ostree.linux"]' ) + coreos_kernel testing ;; *) echo "unexpected kernel_flavor '${{ matrix.kernel_flavor }}' for query"