Skip to content

eBPF-based security platform

ci: Use the CI packages from the kernel repo

Michi Mutsuzakia55a0ddf6c93
diff --git a/.github/scripts/tests.sh b/.github/scripts/tests.sh
index 0ebf9a10..dac3828b 100755
--- a/.github/scripts/tests.sh
+++ b/.github/scripts/tests.sh
@@ -189,6 +189,45 @@ stage_lvh_kernel() {
) || return 1
}
+stage_kernel_ci_artifact() {
+ artifact_dir="$1"
+ set -- "$artifact_dir"/*/linux-image-*_amd64.deb
+ [ "$#" -eq 1 ] && [ -s "$1" ] || {
+ echo "expected one x86-64 kernel image package in $artifact_dir" >&2
+ return 1
+ }
+ image_package="$1"
+ package_dir=${image_package%/*}
+ release=${image_package##*/linux-image-}
+ release=${release%%_*}
+ set -- "$package_dir"/linux-headers-"$release"_*_amd64.deb
+ [ "$#" -eq 1 ] && [ -s "$1" ] || {
+ echo "expected headers package for kernel $release in $package_dir" >&2
+ return 1
+ }
+ btf="$package_dir/vmlinux-$release.btf"
+ config="$package_dir/config-$release"
+ [ -s "$btf" ] && [ -s "$config" ] || {
+ echo "kernel CI artifact lacks BTF or config for $release" >&2
+ return 1
+ }
+ install_root="$PWD/build/kernel-ci-extract"
+ rm -rf "$install_root"
+ mkdir -p "$install_root" || return 1
+ dpkg-deb -x "$image_package" "$install_root" || return 1
+ dpkg-deb -x "$1" "$install_root" || return 1
+ image="$install_root/boot/vmlinuz-$release"
+ modules="$install_root/lib/modules/$release"
+ cp "$btf" "$install_root/boot/btf-$release" || return 1
+ cp "$config" "$install_root/boot/config-$release" || return 1
+ [ -s "$image" ] && [ -d "$modules" ] || {
+ echo "kernel packages did not contain image and modules for $release" >&2
+ return 1
+ }
+ validate_lvh_kernel "$install_root" || return 1
+ stage_lvh_kernel
+}
+
build_test_kernel() {
# A restored kernel is older than the checkout of the script that
# built it.
@@ -207,7 +246,9 @@ setup() {
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- if [ -n "${LVH_KERNEL_ARTIFACT_DIR:-}" ] &&
+ if [ -n "${KERNEL_CI_ARTIFACT_DIR:-}" ]; then
+ stage_kernel_ci_artifact "$KERNEL_CI_ARTIFACT_DIR" || exit 1
+ elif [ -n "${LVH_KERNEL_ARTIFACT_DIR:-}" ] &&
validate_lvh_kernel "$LVH_KERNEL_ARTIFACT_DIR"; then
stage_lvh_kernel || exit 1
else
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 39f2069a..45918e23 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -6,9 +6,15 @@ on:
- main
pull_request:
workflow_dispatch:
+ inputs:
+ kernel_run_id:
+ description: Optional run ID; defaults to the latest successful kernel main run
+ required: false
+ type: string
permissions:
contents: read
+ actions: read
# A newer run for the same branch or pull request supersedes this one.
concurrency:
@@ -25,18 +31,42 @@ jobs:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- # bpf-next moves daily; a week-old kernel still tests the tree, and
- # building one takes most of the run.
- - name: Name the kernel cache week
- id: week
- run: echo "week=$(date -u +%G-W%V)" >> "$GITHUB_OUTPUT"
-
- - name: Restore the bpf-next kernel
- id: kernel
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ - name: Resolve kernel package artifact
+ id: kernel-run
+ env:
+ GH_TOKEN: ${{ secrets.KERNEL_REPO_READ_TOKEN }}
+ REQUESTED_RUN_ID: ${{ inputs.kernel_run_id }}
+ run: |
+ if [ -n "$REQUESTED_RUN_ID" ]; then
+ case "$REQUESTED_RUN_ID" in
+ *[!0-9]*) echo "kernel_run_id must be numeric" >&2; exit 1 ;;
+ esac
+ run_id="$REQUESTED_RUN_ID"
+ else
+ run_id=$(gh api \
+ 'repos/shirudo-dev/kernel/actions/artifacts?name=kernel-packages-x86-64-ci&per_page=100' \
+ --jq '
+ [.artifacts[] | select(.expired == false and .workflow_run.head_branch == "main")]
+ | sort_by(.created_at)
+ | last
+ | .workflow_run.id
+ ')
+ if [ -z "$run_id" ] || [ "$run_id" = null ]; then
+ echo "no kernel CI package artifact found on main" >&2
+ exit 1
+ fi
+ fi
+ echo "Using kernel package run $run_id"
+ echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
+
+ - name: Download kernel CI artifact
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
- path: artifacts/bpf-next-kernel-debs
- key: test-vm-kernel-${{ steps.week.outputs.week }}-${{ hashFiles('testing/vm/build-kernel.sh', 'testing/vm/arch.sh', 'testing/Makefile', 'kernel/*.patch') }}
+ name: kernel-packages-x86-64-ci
+ repository: shirudo-dev/kernel
+ run-id: ${{ steps.kernel-run.outputs.run_id }}
+ github-token: ${{ secrets.KERNEL_REPO_READ_TOKEN }}
+ path: build/kernel-ci-artifact
- name: Restore the static target dependencies
id: target-deps
@@ -53,6 +83,9 @@ jobs:
key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh') }}
- name: Prepare the runner as the VM host
+ id: setup
+ env:
+ KERNEL_CI_ARTIFACT_DIR: ${{ format('{0}/build/kernel-ci-artifact', github.workspace) }}
run: .github/scripts/tests.sh setup
- name: Run unit tests
@@ -71,7 +104,7 @@ jobs:
- name: Run functional tests
id: functional
- if: ${{ !cancelled() }}
+ if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
run: .github/scripts/tests.sh run functional
- name: Upload functional guest logs
@@ -86,7 +119,7 @@ jobs:
- name: Run end-to-end tests
id: end2end
- if: ${{ !cancelled() }}
+ if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
run: .github/scripts/tests.sh run end2end
- name: Upload end-to-end guest logs
@@ -99,15 +132,8 @@ jobs:
build/test-vm/vms/*/console.log
if-no-files-found: ignore
- # Each part is saved once it is complete, even when a later step
- # fails, so that the next run does not build it again.
- - name: Save the bpf-next kernel
- if: always() && steps.kernel.outputs.cache-hit != 'true' && hashFiles('artifacts/bpf-next-kernel-debs/bzImage.sha256sum') != ''
- uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- with:
- path: artifacts/bpf-next-kernel-debs
- key: ${{ steps.kernel.outputs.cache-primary-key }}
-
+ # Save each expensive build once it is complete, even when a later
+ # step fails, so the next run does not rebuild it.
- name: Save the static target dependencies
if: always() && steps.target-deps.outputs.cache-hit != 'true' && hashFiles('build/target-deps/lib/libcrypto.a') != '' && hashFiles('build/target-deps/curl/lib/libcurl.a') != ''
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 8e1335e2..4ba4388c 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -37,6 +37,15 @@ Before you begin
it misses with an install command for ``apt-get`` or ``dnf``.
- For the end-to-end tests: Docker on the host.
+The ``CI suite`` workflow uses the x86-64 CI kernel package from
+``shirudo-dev/kernel`` for every trigger. By default, it selects the
+latest available ``kernel-packages-x86-64-ci`` artifact from ``main``.
+For a manual run, set ``kernel_run_id`` to select a specific run instead.
+The run must contain that artifact. The
+``KERNEL_REPO_READ_TOKEN`` secret needs Actions read access to the kernel
+repository. Setup extracts the image and headers packages, checks the
+kernel config and BTF, and stages the result for the test VM.
+
Test tiers
----------