Skip to content

Commit

Permalink
chore(ci): combining kernel-cache and akmods (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsherman authored Feb 5, 2025
1 parent 433eddb commit 12f399b
Show file tree
Hide file tree
Showing 13 changed files with 599 additions and 160 deletions.
151 changes: 151 additions & 0 deletions .github/actions/get-kernel-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
name: Get Kernel Version
inputs:
fedora_version:
description: "The Fedora release version: 40, 41, etc"
required: true
type: string
kernel_flavor:
description: "The Kernel flavor: main, bazzite, coreos-stable, etc"
required: true
type: string
outputs:
kernel_build_tag:
description: "Optional (bazzite specific) tag"
value: ${{ steps.kernel.outputs.build_tag }}
kernel_major_minor_patch:
description: "Simple version eg, 6.12.9"
value: ${{ steps.kernel.outputs.major_minor_patch }}
kernel_release:
description: "Full kernel release eg, 6.12.9-200.fc41.x86_64"
value: ${{ steps.kernel.outputs.release }}
runs:
using: "composite"
steps:
- name: Get Kernel Version
id: kernel
shell: bash
run: |
if [[ ${{ inputs.kernel_flavor }} =~ asus|surface ]]; then
build_image="quay.io/fedora/fedora:${{ inputs.fedora_version }}"
podman pull "$build_image"
container_name="fq-$(uuidgen)"
dnf="podman exec $container_name dnf"
podman run --entrypoint /bin/bash --name "$container_name" -dt "$build_image"
$dnf install -y --setopt=install_weak_deps=False 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"]')
# Pin a kernel here, gross workaround TODO: Make this cleaner
# if [[ "${{ inputs.kernel_flavor }}" == "coreos-stable" ]]; then
# image_linux="6.11.3-300.fc41.x86_64"
# fi
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${{ inputs.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)
linux=""
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${{ inputs.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 ${{ inputs.kernel_flavor }} in
"asus")
$dnf copr enable -y lukenukem/asus-kernel
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:lukenukem:asus-kernel --whatprovides kernel | sort -V | tail -n1 | sed 's/.*://')
;;
"fsync")
$dnf copr enable -y sentry/kernel-fsync
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:sentry:kernel-fsync --whatprovides kernel | sort -V | tail -n1 | sed 's/.*://')
;;
"fsync-ba")
$dnf copr enable -y sentry/kernel-ba
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:sentry:kernel-ba --whatprovides kernel | sort -V | tail -n1 | sed 's/.*://')
;;
"bazzite")
latest="$(curl "https://api.github.com/repos/hhd-dev/kernel-bazzite/releases/latest" )"
linux=$(echo -E "$latest" | jq -r '.assets[].name' | grep -E 'kernel-.*.rpm' | grep "fc${{ inputs.fedora_version }}.x86_64" | head -1 | sed "s/kernel-//g" | sed "s/.rpm//g" )
build_tag=$(echo -E $latest | jq -r '.tag_name')
;;
"surface")
if [[ "${{ inputs.fedora_version }}" < 41 ]]; then
$dnf config-manager --add-repo=https://pkg.surfacelinux.com/fedora/linux-surface.repo
else
$dnf config-manager addrepo --from-repofile=https://pkg.surfacelinux.com/fedora/linux-surface.repo
fi
linux=$($dnf repoquery --repoid linux-surface --whatprovides kernel-surface | sort -V | tail -n1 | sed 's/.*://')
;;
"main")
base_image_name="base"
if [[ ${{ inputs.fedora_version }} > 40 ]]; then
base_image_name+="-atomic"
fi
linux=$(skopeo inspect docker://quay.io/fedora-ostree-desktops/$base_image_name:${{ inputs.fedora_version }} | jq -r '.Labels["ostree.linux"]' )
;;
"coreos-stable")
coreos_kernel stable
;;
"coreos-testing")
coreos_kernel testing
;;
*)
echo "unexpected kernel_flavor '${{ inputs.kernel_flavor }}' for query"
;;
esac
if [ -z "$linux" ] || [ "null" = "$linux" ]; then
echo "inspected image linux version must not be empty or null"
exit 1
fi
major=$(echo "$linux" | cut -d '.' -f 1)
minor=$(echo "$linux" | cut -d '.' -f 2)
patch=$(echo "$linux" | cut -d '.' -f 3)
kernel_major_minor_patch="${major}.${minor}.${patch}"
# Debug Output
echo "kernel_build_tag: ${build_tag}"
echo "kernel_flavor: ${{ inputs.kernel_flavor }}"
echo "kernel_major_minor_patch: ${kernel_major_minor_patch}"
echo "kernel_release: ${linux}"
# Action Output
echo "build_tag=${build_tag}" >> $GITHUB_OUTPUT
echo "major_minor_patch=${kernel_major_minor_patch}" >> $GITHUB_OUTPUT
echo "release=${linux}" >> $GITHUB_OUTPUT
19 changes: 0 additions & 19 deletions .github/workflows/build-39.yml

This file was deleted.

19 changes: 15 additions & 4 deletions .github/workflows/build-40.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@ on:
paths-ignore:
- '**.md'
schedule:
- cron: '15 0 * * *' # 10 minutes after kernel-cache
- cron: '25 0 * * *' # 0025 UTC everyday (20 minutes after 41)
workflow_dispatch:


jobs:
build:
name: build
kernel-akmods:
uses: ./.github/workflows/reusable-build.yml
secrets: inherit
strategy:
fail-fast: false
matrix:
fedora_version:
- 40
kernel_flavor:
- surface
- main
- coreos-stable
- coreos-testing
with:
fedora_version: 40
fedora_version: ${{ matrix.fedora_version }}
kernel_flavor: ${{ matrix.kernel_flavor }}
20 changes: 16 additions & 4 deletions .github/workflows/build-41.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@ on:
paths-ignore:
- '**.md'
schedule:
- cron: '15 0 * * *' # 10 minutes after kernel-cache
- cron: '5 0 * * *' # 0005 UTC everyday
workflow_dispatch:

jobs:
build:
name: build
kernel-akmods:
uses: ./.github/workflows/reusable-build.yml
secrets: inherit
strategy:
fail-fast: false
matrix:
fedora_version:
- 41
kernel_flavor:
- asus
- bazzite
- surface
- main
- coreos-stable
- coreos-testing
with:
fedora_version: 41
fedora_version: ${{ matrix.fedora_version }}
kernel_flavor: ${{ matrix.kernel_flavor }}
Loading

0 comments on commit 12f399b

Please sign in to comment.