feat(ci): Add support for parallel kernel module builds
Some checks failed
Build kernel module / build (1:6.12.93-1+rpt1) (push) Failing after 5m23s
Build kernel module / release (push) Has been skipped

Enable parallel builds for kernel modules targeting multiple kernel
headers. This optimization reduces build times and improves CI
efficiency. Adjusted workflow steps to ensure compatibility with all
supported environments.
This commit is contained in:
Christian Werner 2026-06-19 03:25:53 +02:00
parent 5476a5db28
commit 1c5fe33927

View File

@ -12,54 +12,55 @@ on:
- master - master
jobs: jobs:
# Build (and thereby compile-check) the module for each header package. Runs on # Build (and thereby compile-check) the module for each pinned kernel version.
# both triggers — on a PR this is the whole story; on a tag the `release` job # Runs on both triggers — on a PR this is the whole story; on a tag the
# below consumes the artifacts. All packages build against the latest archive # `release` job below consumes the artifacts.
# kernel; the exact version is auto-resolved from the image at build time. #
# HEADERS_PKG is fixed to linux-headers-rpi-v8 (64-bit, Pi Zero 2 W): the -v6/-v7
# headers are 32-bit (armhf) and aren't carried by the arm64 raspberrypi archive
# this arm64 builder uses.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
HEADERS_PKG: linux-headers-rpi-v8
strategy: strategy:
# Don't cancel the other targets if one package fails to build. # Don't cancel the other versions if one fails to build.
fail-fast: false fail-fast: false
matrix: matrix:
headers_pkg: kernel_version:
- linux-headers-rpi-v8 # 64-bit (Pi Zero 2 W) - "1:6.12.93-1+rpt1"
- linux-headers-rpi-v7 # 32-bit
- linux-headers-rpi-v6 # 32-bit (older Pis)
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Build module (${{ matrix.headers_pkg }}) - name: Build module (${{ matrix.kernel_version }})
working-directory: kernel working-directory: kernel
env: env:
HEADERS_PKG: ${{ matrix.headers_pkg }} HEADERS_PKG: ${{ env.HEADERS_PKG }}
KERNEL_VERSION: ${{ matrix.kernel_version }}
run: ./build-in-docker.sh run: ./build-in-docker.sh
- name: Stage build output (<kernel_version>/<headers_pkg>.ko) - name: Stage build output (modules/iec_listener_<kernel_version>.ko)
working-directory: kernel working-directory: kernel
run: | run: |
# Ask the just-built image which kernel tree it installed, then drop the ver="${{ matrix.kernel_version }}"
# -rpi-vN arch suffix so every package shares one version folder. safe="${ver//[:\/]/-}" # path-friendly: 1:6.12.93-1+rpt1 -> 1-6.12.93-1+rpt1
kver=$(docker run --rm --platform linux/arm64 --entrypoint sh \ echo "kernel version $ver -> file modules/iec_listener_${safe}.ko"
"${IMAGE:-iec-kbuild}" -c 'ls -1 /lib/modules | sort -V | tail -n1') mkdir -p out/modules
ver="${kver%-rpi-*}" mv iec_listener.ko "out/modules/iec_listener_${safe}.ko"
echo "resolved kernel: $kver -> version folder: $ver"
mkdir -p "out/$ver"
mv iec_listener.ko "out/$ver/${{ matrix.headers_pkg }}.ko"
- name: Upload build output - name: Upload build output
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
# Name by headers_pkg so artifact names stay unique; the shared # Name by the path-friendly version so artifact names stay unique; all
# <kernel_version>/ folder is reassembled at download via merge-multiple. # of them merge back into the single modules/ folder at download time.
name: ${{ matrix.headers_pkg }} name: ${{ matrix.kernel_version }}
path: kernel/out path: kernel/out
if-no-files-found: error if-no-files-found: error
# Release flow only: reassembles the <kernel_version>/ folders, wraps them in a # Release flow only: merges all built modules into one modules/ folder, wraps it
# single repo-named top folder alongside selftest.sh, zips it and attaches it to # in a single repo-named top folder alongside selftest.sh, zips it and attaches
# the Gitea release for the pushed tag. Skipped entirely on pull requests. # it to the Gitea release for the pushed tag. Skipped entirely on pull requests.
release: release:
needs: build needs: build
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
@ -71,8 +72,8 @@ jobs:
- name: Download all build output - name: Download all build output
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
path: modules path: dist
# Merge every artifact back into the shared <kernel_version>/ tree. # Merge every artifact back into the shared modules/ folder.
merge-multiple: true merge-multiple: true
- name: Assemble release package - name: Assemble release package
@ -80,7 +81,7 @@ jobs:
repo="${{ github.event.repository.name }}" repo="${{ github.event.repository.name }}"
root="package/$repo" root="package/$repo"
mkdir -p "$root" mkdir -p "$root"
cp -r modules/. "$root"/ # <kernel_version>/<headers_pkg>.ko cp -r dist/modules "$root"/ # modules/iec_listener_<kernel_version>.ko
cp kernel/selftest.sh "$root"/ # selftest.sh only at the package root cp kernel/selftest.sh "$root"/ # selftest.sh only at the package root
(cd package && zip -r "../${repo}-${{ github.ref_name }}.zip" "$repo") (cd package && zip -r "../${repo}-${{ github.ref_name }}.zip" "$repo")