Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/scripts/kernel-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,29 @@
# what Claude checks and what the workflow checks cannot drift apart.
#
# Usage:
# kernel-build.sh <x86_64|arm64> <objdir> [jobs]
# kernel-build.sh [--config-only] <x86_64|arm64> <objdir> [jobs]
#
# Run from the top of a kernel tree. <objdir> is created if missing and may be
# reused between runs. For arm64 it uses CROSS_COMPILE (default
# aarch64-linux-gnu-) unless LLVM is set, in which case it builds with clang.
#
# --config-only stops once the options are checked, without compiling. That is
# far quicker and still catches a Kconfig dependency the series no longer
# satisfies, but not a compile or link error.
#
# Exit status: make's on a build failure; 3 if an option it asked for did not
# survive olddefconfig (a Kconfig dependency the series no longer satisfies);
# git's if the host config cannot be fetched.

set -euo pipefail

config_only=false
if [ "${1:-}" = --config-only ]; then
config_only=true
shift
fi
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "usage: $0 <x86_64|arm64> <objdir> [jobs]" >&2
echo "usage: $0 [--config-only] <x86_64|arm64> <objdir> [jobs]" >&2
exit 2
fi
arch=$1
Expand Down Expand Up @@ -111,5 +120,10 @@ if [ "${#lost[@]}" -ne 0 ]; then
exit 3
fi

if $config_only; then
echo "kernel-build: $arch options enabled in $objdir"
exit 0
fi

mk -j"$jobs" vmlinux
echo "kernel-build: $arch vmlinux built in $objdir"
82 changes: 82 additions & 0 deletions .github/scripts/zone-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
# Builds the zone kernel the way Edera ships it, less debug info.
#
# Every zone boots the zone kernel. Its config is a fragment against the
# architecture's defconfig, kept in edera-dev/linux-kernel-oci. This merges
# the fragment from the tip of that repository's main branch over defconfig,
# as linux-kernel-oci does, and builds the boot image and the modules it
# publishes. A change that breaks the shipped zone kernel fails here, and not
# in the next image build.
#
# BTF and DWARF debug info are left out. They are most of the cost of a
# build, and not what a change to the sources breaks.
#
# Usage:
# zone-build.sh <x86_64|arm64> <objdir> [jobs]
#
# Run from the top of a kernel tree. <objdir> is created if missing and may be
# reused between runs. For arm64 it uses CROSS_COMPILE (default
# aarch64-linux-gnu-) unless LLVM is set, in which case it builds with clang.
#
# Exit status: make's on a build failure; git's if the zone config cannot be
# fetched.

set -euo pipefail

if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "usage: $0 <x86_64|arm64> <objdir> [jobs]" >&2
exit 2
fi
arch=$1
objdir=$2
jobs=${3:-$(nproc)}

# linux-kernel-oci keeps its configs in a directory named for the machine
# architecture, and publishes the image that architecture boots from.
case $arch in
x86_64)
karch=x86
ocidir=x86_64
image=bzImage
# make reads LLVM from the environment; x86 is always the gcc build.
unset LLVM
cross=()
;;
arm64)
karch=arm64
ocidir=aarch64
image=Image.gz
if [ -n "${LLVM:-}" ]; then
cross=(LLVM=1)
else
cross=(CROSS_COMPILE="${CROSS_COMPILE:-aarch64-linux-gnu-}")
fi
;;
*)
echo "unknown arch: $arch" >&2
exit 2
;;
esac

mkdir -p "$objdir"
mk() { make -s ARCH="$karch" "${cross[@]}" O="$objdir" "$@"; }

mk defconfig

oci=https://github.com/edera-dev/linux-kernel-oci
cfgrepo=$(mktemp -d)
trap 'rm -rf "$cfgrepo"' EXIT
git init -q --bare "$cfgrepo"
git -C "$cfgrepo" fetch -q --depth 1 "$oci" main
git -C "$cfgrepo" show "FETCH_HEAD:configs/$ocidir/zone.config" >"$cfgrepo/zone.config"
echo "zone-build: merging zone.config from $oci@$(git -C "$cfgrepo" rev-parse FETCH_HEAD)"
scripts/kconfig/merge_config.sh -m -O "$objdir" "$objdir/.config" "$cfgrepo/zone.config" >/dev/null

scripts/config --file "$objdir/.config" \
--enable DEBUG_INFO_NONE \
--disable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT \
--disable DEBUG_INFO_BTF --disable DEBUG_INFO_BTF_MODULES
mk olddefconfig

mk -j"$jobs" "$image" modules
echo "zone-build: $arch $image and modules built in $objdir"
100 changes: 100 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Build

# Builds the kernel on every pull request and push to an edera/** branch, so a
# change that breaks it is found when it is proposed and not by the nightly
# rebase.
#
# - kconfig resolves the config that the nightly judges a branch with, and
# fails if a Kconfig dependency the series no longer satisfies drops an
# option it needs. It does not compile, so it answers quickly. x86_64 is
# judged on Edera's host config and arm64 on defconfig;
# - zone builds the zone kernel that every zone boots, for x86_64 and
# arm64, from the config in edera-dev/linux-kernel-oci. It leaves out
# debug info.
#
# Both take their config from the tip of edera-dev/linux-kernel-oci's main
# branch, so a change there can turn them red without a change here.
#
# It has no path filter, so it can be made a required check.

on:
pull_request:
types: [opened, synchronize, ready_for_review]
branches: ['edera/**']
push:
branches: ['edera/**']

permissions:
contents: read

# A newer push to a pull request replaces its older build, but every commit
# pushed to a branch gets its own: sharing a group would let a third merge
# cancel the second one's pending build.
concurrency:
group: build-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
kconfig:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64]
name: kconfig (${{ matrix.arch }})
steps:
- name: Harden runner
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false

- name: Install toolchains
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential bc bison flex libelf-dev libssl-dev python3 \
gcc-aarch64-linux-gnu

- name: Check the config
env:
ARCH: ${{ matrix.arch }}
run: bash .github/scripts/kernel-build.sh --config-only "$ARCH" "$RUNNER_TEMP/obj"

zone:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64]
name: zone (${{ matrix.arch }})
steps:
- name: Harden runner
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false

- name: Install toolchains
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential bc bison flex libelf-dev libssl-dev python3 \
gcc-aarch64-linux-gnu

- name: Build
env:
ARCH: ${{ matrix.arch }}
run: bash .github/scripts/zone-build.sh "$ARCH" "$RUNNER_TEMP/obj"
Loading