Preparing the repo to go public (ADR-0007): - CI: kernel-build moves from the self-hosted runner to ubuntu-latest (installs its own cross toolchain + qemu, caches the pristine tarball). On a public repo a registered self-hosted runner is reachable from approved fork-PR workflows — i.e. arbitrary code on private infrastructure — and the build never actually needed the SDK host. ADR-0004 marked superseded-in-part; docs/ci-cd.md rewritten (site specifics now live only in the private deployment log). - Licensing: LICENSE gains the GPL-2.0 carve-out for patches/ and the kernel source excerpts (Linux derivatives; per-driver provenance was already tracked in PROVENANCE.md); patches/README.md states it too. - Scrubbed from the tip: bench-unit dev credentials and its gadget IP (m2-boot notes), the site AP SSID+BSSID and a neighboring AP's BSSID and the device WLAN MAC (wifi bring-up evidence — BSSIDs are geolocatable), the runner mesh IP. NOTE: these remain in git history; decision on a pre-publication history rewrite is separate. - Emoji cleanup across 21 tracked files (kernel port docs, review report, enforce-mcdc.sh) per repo text conventions: status marks became [x]/[wip]/[ ]/OK plain text. - "[maintainer]-gated" process phrasing normalized to "maintainer-gated" (attributions in dated evidence docs kept). Verified: zero emojis tracked; scrub grep clean; patches carry no internal references; ci.yml parses; shellcheck unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018HUayid7W5w7jBdb9Rrj1K
269 lines
12 KiB
YAML
269 lines
12 KiB
YAML
# warden-sdk CI.
|
|
#
|
|
# Policy (mirrors flare-edge): only GitHub-owned actions get the repo token; the one
|
|
# third-party helper (taiki-e/install-action) is pinned and never handed a token.
|
|
# Every job runs on GitHub-hosted runners — no self-hosted runner may be reachable
|
|
# from this repo's workflows (ADR-0007: public-repo fork PRs would otherwise be
|
|
# able to run code on private infrastructure). kernel-build is dispatch-only.
|
|
name: ci
|
|
|
|
on:
|
|
push:
|
|
paths-ignore: ['.github/badges/**']
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
# Least privilege by default: every job gets a read-only token; only `badges`
|
|
# (which commits rendered SVGs) overrides this with contents: write below.
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
passed: ${{ steps.result.outputs.passed }}
|
|
coverage: ${{ steps.result.outputs.coverage }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: cargo test (all crates)
|
|
run: |
|
|
set -o pipefail
|
|
: > /tmp/test.log
|
|
for d in sim tools/config-lint qemu/rs485-bridge; do
|
|
echo "== cargo test in $d ==" | tee -a /tmp/test.log
|
|
( cd "$d" && cargo test --locked ) 2>&1 | tee -a /tmp/test.log
|
|
done
|
|
- name: coverage (cargo-llvm-cov on sim)
|
|
run: rustup component add llvm-tools-preview
|
|
- uses: taiki-e/install-action@b6ff580856c41316412a0b9b60540fbc6f8c82cc # v2.86.7
|
|
with:
|
|
tool: cargo-llvm-cov
|
|
- name: run coverage
|
|
working-directory: sim
|
|
run: cargo llvm-cov --locked --json --summary-only --output-path /tmp/cov.json
|
|
- name: parse results
|
|
id: result
|
|
run: |
|
|
passed=$(grep -oE '[0-9]+ passed' /tmp/test.log | awk '{s+=$1} END{print s+0}')
|
|
pct=$(python3 -c 'import json;print("%.0f"%json.load(open("/tmp/cov.json"))["data"][0]["totals"]["lines"]["percent"])')
|
|
echo "passed=$passed" >> "$GITHUB_OUTPUT"
|
|
echo "coverage=$pct" >> "$GITHUB_OUTPUT"
|
|
echo "tests passed: $passed | sim line coverage: ${pct}%"
|
|
|
|
mcdc:
|
|
# 100% MC/DC (condition coverage) enforced on every Tier-1 driver harness.
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: install gcc-14
|
|
run: sudo apt-get update -qq && sudo apt-get install -y -qq gcc-14
|
|
- name: enforce 100% MC/DC on drivers/*/test
|
|
run: |
|
|
fail=0; ran=0
|
|
for t in drivers/*/test; do
|
|
[ -f "$t/Makefile" ] || continue
|
|
ran=1
|
|
echo "== MC/DC: $t =="
|
|
make -C "$t" check CC=gcc-14 GCOV=gcov-14 || fail=1
|
|
done
|
|
[ "$ran" = 1 ] || { echo "no driver MC/DC harnesses found"; exit 1; }
|
|
exit $fail
|
|
|
|
bench:
|
|
# Smoke-run the sim micro-benchmarks and emit the ns/op trend JSON. Regression
|
|
# gating against stored history is future work (no flare-edge pattern to copy).
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: run sim benchmarks
|
|
working-directory: sim
|
|
run: |
|
|
cargo bench --locked --bench sim_bench 1> bench.txt 2> bench.json
|
|
echo "== timings =="; cat bench.txt
|
|
echo "== trend json =="; grep '"bench"' bench.json
|
|
- name: run rs485-bridge benchmarks
|
|
working-directory: qemu/rs485-bridge
|
|
run: |
|
|
cargo bench --locked --bench bridge_bench 1> bench.txt 2> bench.json
|
|
echo "== timings =="; cat bench.txt
|
|
echo "== trend json =="; grep '"bench"' bench.json
|
|
|
|
qemu-tools:
|
|
# The qemu/ device-sim build tooling must stay healthy on a plain hosted
|
|
# runner: shellcheck the scripts, build the initramfs (pinned busybox,
|
|
# fail-closed sha), and build the A/B disk image (unprivileged mkfs -d).
|
|
# Booting needs a zImage and therefore lives in kernel-build's smoke step.
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: shellcheck qemu scripts
|
|
run: |
|
|
sudo apt-get update -qq && sudo apt-get install -y -qq shellcheck
|
|
shellcheck -x qemu/*.sh qemu/tests/*.sh
|
|
- name: cache pinned busybox
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: qemu/out/busybox-armv7l
|
|
key: busybox-armv7l-${{ hashFiles('qemu/busybox.sha256') }}
|
|
- name: build initramfs
|
|
run: bash qemu/mkinitramfs.sh
|
|
- name: build A/B disk image
|
|
run: bash qemu/mkimage.sh
|
|
|
|
patches-apply:
|
|
# The RV1106 series must apply cleanly onto pristine linux-6.18.46.
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: cache pristine kernel tarball
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/linux-6.18.46.tar.xz
|
|
key: linux-6.18.46-tarball
|
|
- name: fetch + verify pristine
|
|
run: |
|
|
[ -f ~/linux-6.18.46.tar.xz ] || \
|
|
curl -fSL https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.18.46.tar.xz -o ~/linux-6.18.46.tar.xz
|
|
echo "$(cat build/linux-6.18.46.tar.xz.sha256) $HOME/linux-6.18.46.tar.xz" | sha256sum -c -
|
|
- name: apply the series in order
|
|
run: |
|
|
tar -C /tmp -xf ~/linux-6.18.46.tar.xz
|
|
for p in patches/*.patch; do
|
|
git -C /tmp/linux-6.18.46 apply --whitespace=nowarn "$GITHUB_WORKSPACE/$p" \
|
|
&& echo "applied $p" || { echo "FAILED to apply $p"; exit 1; }
|
|
done
|
|
echo "full series applied cleanly onto pristine 6.18.46"
|
|
|
|
# Automatic artifact GC (mirrors flare-edge). An exceeded account-wide Actions
|
|
# storage quota blocks ALL new runs (startup_failure), not just uploads, so
|
|
# before a new kernel artifact is uploaded, drop older kernel-rv1106 artifacts
|
|
# beyond the newest few — storage stays bounded across dispatches. gh + the
|
|
# built-in token (no third-party action); needs actions:write to delete.
|
|
# Best-effort: it never fails the run, so it can't block the build that needs it.
|
|
prune-artifacts:
|
|
if: github.event_name == 'workflow_dispatch'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: write
|
|
steps:
|
|
- name: Keep only the newest few kernel artifacts
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
REPO: ${{ github.repository }}
|
|
KEEP: "3"
|
|
run: |
|
|
ids=$(gh api --paginate "repos/$REPO/actions/artifacts?per_page=100" \
|
|
--jq "[.artifacts[] | select(.name==\"kernel-rv1106\")]
|
|
| sort_by(.created_at) | reverse | .[$KEEP:] | .[].id" \
|
|
2>/dev/null) || { echo "list failed; skipping"; exit 0; }
|
|
n=0
|
|
for id in $ids; do
|
|
if gh api -X DELETE "repos/$REPO/actions/artifacts/$id" 2>/dev/null; then
|
|
n=$((n + 1)); echo "pruned artifact $id"
|
|
fi
|
|
done
|
|
echo "pruned $n old kernel artifact(s); kept newest $KEEP"
|
|
exit 0
|
|
|
|
kernel-build:
|
|
# Full hermetic build on a GitHub-hosted runner (ADR-0007; supersedes the
|
|
# self-hosted half of ADR-0004 — a self-hosted runner must never be reachable
|
|
# from a public repo's workflows). Manual-dispatch by design — a full kernel
|
|
# build is heavy; trigger via `gh workflow run ci.yml` / the Actions UI.
|
|
if: github.event_name == 'workflow_dispatch'
|
|
needs: [prune-artifacts]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: install cross toolchain + kernel build deps + qemu
|
|
run: |
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y -qq gcc-arm-linux-gnueabihf qemu-system-arm \
|
|
cpio bc bison flex libssl-dev
|
|
- name: provision `python` (SDK quirk — build calls bare python)
|
|
run: |
|
|
mkdir -p "$RUNNER_TEMP/bin"
|
|
ln -sf "$(command -v python3)" "$RUNNER_TEMP/bin/python"
|
|
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
|
|
- name: cache pristine kernel tarball
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/linux-6.18.46.tar.xz
|
|
key: linux-6.18.46-tarball
|
|
- name: build zImage + rv1106-warden.dtb
|
|
env:
|
|
# WORK must be OUTSIDE the repo checkout: build-kernel.sh applies the patch
|
|
# series with `git apply`, which silently ignores out-of-subdir paths when
|
|
# run inside another git repo (issue #1). $RUNNER_TEMP is outside the checkout.
|
|
WORK: ${{ runner.temp }}/kbuild-out
|
|
# Reuse the cached tarball when present (build-kernel.sh still verifies
|
|
# the sha256 pin fail-closed either way; it downloads if the file is absent).
|
|
KERNEL_TARBALL: ~/linux-6.18.46.tar.xz
|
|
# The kernel is freestanding; the generic arm cross toolchain links it.
|
|
CROSS_COMPILE: arm-linux-gnueabihf-
|
|
run: |
|
|
[ -f ~/linux-6.18.46.tar.xz ] || \
|
|
curl -fSL https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.18.46.tar.xz \
|
|
-o ~/linux-6.18.46.tar.xz
|
|
bash build/build-kernel.sh
|
|
# Boot smoke under QEMU: the zImage this job just built must reach the
|
|
# initramfs sentinel on -M virt (verified 2026-08-29: the canonical
|
|
# config boots virt as-is). FAIL-CLOSED on a missing qemu-system-arm.
|
|
- name: boot smoke (qemu-system-arm -M virt)
|
|
run: |
|
|
bash qemu/mkinitramfs.sh
|
|
bash qemu/tests/boot-smoke.sh \
|
|
"$RUNNER_TEMP/kbuild-out/linux-6.18.46/arch/arm/boot/zImage"
|
|
# Best-effort: the build IS the gate. Uploading the zImage/dtb to GitHub
|
|
# artifact storage can fail on an account-wide storage-quota hit (recalculated
|
|
# every 6-12h) that has nothing to do with this build — don't red-X a good
|
|
# kernel build over it.
|
|
- uses: actions/upload-artifact@v4
|
|
continue-on-error: true
|
|
with:
|
|
name: kernel-rv1106
|
|
path: |
|
|
${{ runner.temp }}/kbuild-out/linux-6.18.46/arch/arm/boot/zImage
|
|
${{ runner.temp }}/kbuild-out/linux-6.18.46/arch/arm/boot/dts/rockchip/rv1106-warden.dtb
|
|
# Short so kernel images self-expire instead of piling into the
|
|
# account-wide storage quota; the prune-artifacts job above is the
|
|
# active bound, this is the backstop.
|
|
retention-days: 5
|
|
|
|
badges:
|
|
needs: [test]
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: install cloc
|
|
run: sudo apt-get update -qq && sudo apt-get install -y -qq cloc
|
|
- name: render badges
|
|
env:
|
|
PASSED: ${{ needs.test.outputs.passed }}
|
|
COVERAGE: ${{ needs.test.outputs.coverage }}
|
|
run: |
|
|
mkdir -p .github/badges
|
|
loc=$(cloc --quiet --json --exclude-dir=target,build,build-target,patches,data,docs . \
|
|
| python3 -c 'import sys,json; print(json.load(sys.stdin)["SUM"]["code"])')
|
|
col=orange; [ "${COVERAGE:-0}" -ge 60 ] && col=yellow; [ "${COVERAGE:-0}" -ge 80 ] && col=brightgreen
|
|
curl -fsSL "https://img.shields.io/badge/lines%20of%20code-${loc}-blue" -o .github/badges/loc.svg
|
|
curl -fsSL "https://img.shields.io/badge/tests-${PASSED}%20passing-brightgreen" -o .github/badges/tests.svg
|
|
curl -fsSL "https://img.shields.io/badge/coverage-${COVERAGE}%25-${col}" -o .github/badges/coverage.svg
|
|
- name: commit badges
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add .github/badges/loc.svg .github/badges/tests.svg .github/badges/coverage.svg
|
|
if ! git diff --cached --quiet; then
|
|
git commit -m "ci: update loc/tests/coverage badges [skip ci]"
|
|
git push
|
|
fi
|