Skip to content

Commit 06ce20b

Browse files
committed
ci: add multi-kernel build matrix (6.8, 6.11, 6.12, 6.14)
- Add .github/scripts/fetch-kernel-headers.sh to download mainline kernel headers from kernel.ubuntu.com PPA - Rewrite ci.yml into three jobs: - build: matrix across 4 kernel versions (headers-only compilation) - lint: checkpatch + sparse on native kernel - test: insmod + test suite on runner's native kernel - Build matrix uses fail-fast: false so all versions are tested even if one fails
1 parent 8fc9e1a commit 06ce20b

2 files changed

Lines changed: 87 additions & 6 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0-only
3+
#
4+
# fetch-kernel-headers.sh - Download mainline kernel headers from Ubuntu PPA
5+
#
6+
# Downloads and extracts the linux-headers .deb packages for a given
7+
# mainline kernel version from kernel.ubuntu.com. Used by CI to build
8+
# the module against multiple kernel versions.
9+
#
10+
# Usage: ./fetch-kernel-headers.sh <version> <outdir>
11+
# version - kernel version, e.g. "6.8" or "6.12"
12+
# outdir - directory to extract headers into
13+
#
14+
# Prints the KDIR path on success, exits non-zero on failure.
15+
16+
set -euo pipefail
17+
18+
VERSION="${1:?Usage: $0 <version> <outdir>}"
19+
OUTDIR="${2:?Usage: $0 <version> <outdir>}"
20+
BASE_URL="https://kernel.ubuntu.com/mainline/v${VERSION}/amd64"
21+
22+
mkdir -p "${OUTDIR}/debs"
23+
24+
echo "Fetching package list from ${BASE_URL}/ ..." >&2
25+
26+
# Get the directory listing and extract header .deb filenames
27+
INDEX=$(curl -sL "${BASE_URL}/")
28+
if [ -z "$INDEX" ]; then
29+
echo "ERROR: Failed to fetch index from ${BASE_URL}/" >&2
30+
exit 1
31+
fi
32+
33+
# Extract header .deb filenames (portable grep -oE, no -P)
34+
HEADER_DEBS=$(echo "$INDEX" | grep -oE 'linux-headers[^"<>]*\.deb' | sort -u)
35+
36+
if [ -z "$HEADER_DEBS" ]; then
37+
echo "ERROR: No linux-headers .deb files found at ${BASE_URL}/" >&2
38+
exit 1
39+
fi
40+
41+
echo " Found $(echo "$HEADER_DEBS" | wc -l) header packages" >&2
42+
43+
# Download each header .deb
44+
for deb in $HEADER_DEBS; do
45+
echo " Downloading ${deb} ..." >&2
46+
curl -sL "${BASE_URL}/${deb}" -o "${OUTDIR}/debs/${deb}"
47+
done
48+
49+
# Extract all .debs into the output directory
50+
for deb in "${OUTDIR}/debs/"*.deb; do
51+
dpkg -x "$deb" "${OUTDIR}"
52+
done
53+
54+
# Find the arch-specific headers directory (the one with Makefile)
55+
KDIR=$(find "${OUTDIR}/usr/src" -maxdepth 1 -name "linux-headers-*-generic" -type d | head -1)
56+
57+
if [ -z "$KDIR" ] || [ ! -f "${KDIR}/Makefile" ]; then
58+
echo "ERROR: Could not find extracted kernel headers directory" >&2
59+
echo " Contents of ${OUTDIR}/usr/src/:" >&2
60+
ls -la "${OUTDIR}/usr/src/" >&2 || true
61+
exit 1
62+
fi
63+
64+
echo " Headers extracted to ${KDIR}" >&2
65+
echo "$KDIR"

.github/workflows/ci.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,34 @@ on:
88

99
jobs:
1010
build:
11-
name: Build & Lint
11+
name: Build (kernel ${{ matrix.kernel }})
1212
runs-on: ubuntu-24.04
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
kernel: ["6.8", "6.11", "6.12", "6.14"]
1317
steps:
1418
- uses: actions/checkout@v4
1519

16-
- name: Install build dependencies
20+
- name: Fetch kernel ${{ matrix.kernel }} headers
1721
run: |
18-
sudo apt-get update
19-
sudo apt-get install -y linux-headers-$(uname -r) sparse
22+
KDIR=$(bash .github/scripts/fetch-kernel-headers.sh \
23+
"${{ matrix.kernel }}" "/tmp/kernel-${{ matrix.kernel }}")
24+
echo "KDIR=${KDIR}" >> "$GITHUB_ENV"
2025
2126
- name: Compile module
22-
run: make
27+
run: make KDIR="${KDIR}"
28+
29+
lint:
30+
name: Lint & Static Analysis
31+
runs-on: ubuntu-24.04
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Install dependencies
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y linux-headers-$(uname -r) sparse
2339
2440
- name: Run checkpatch.pl
2541
run: make checkpatch
@@ -30,7 +46,7 @@ jobs:
3046
test:
3147
name: Module Tests
3248
runs-on: ubuntu-24.04
33-
needs: build
49+
needs: [build, lint]
3450
steps:
3551
- uses: actions/checkout@v4
3652

0 commit comments

Comments
 (0)