8000 ci,test: auto-discover integration harnesses by name convention across every lane by norrietaylor · Pull Request #732 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
85 changes: 31 additions & 54 deletions .github/workflows/ci-linux-kvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: CI (Linux KVM)
# build) alongside the guest kernel + rootfs.
#
# x86_64 ONLY: GitHub-hosted arm64 runners (ubuntu-24.04-arm) do not expose
# /dev/kvm, so the Linux/KVM e2e can only run on x86_64. aarch64 + libkrun boot
# /dev/kvm, so the Linux/KVM tests can only run on x86_64. aarch64 + libkrun boot
# is already covered by the macOS lane (ci-macos.yml, Apple Silicon / HVF).
#
# GATE-READY: ALWAYS-TRIGGERED, path-scoped INSIDE the workflow — the
Expand Down Expand Up @@ -75,10 +75,6 @@ jobs:
# it post-merge.
- ".github/actions/setup-libkrun-linux/**"
- ".github/actions/materialize/**"
# The gvproxy pin: point-of-use verification (fetch-gvproxy.sh
# SHA-checks it in this lane) replaced the retired ci-gvproxy.yml
# workflow, so a pin bump must re-run this lane.
- "vendor/gvproxy/**"

build-linux:
# BUILD phase: compile everything the KVM tests need and ship it as one
Expand Down Expand Up @@ -167,7 +163,7 @@ jobs:
# CLI drives the unified session e2e in the test job.
run: cargo build -p minimal --bin minimal --locked

- name: Archive e2e harnesses + stage the testbed
- name: Archive integration harnesses + stage the testbed
# `cargo nextest archive` replaces the hand-rolled testbins.json
# manifest: the archive carries every minvmd test binary with exec
# bits intact, and the test job selects harnesses with filtersets.
Expand Down Expand Up @@ -232,7 +228,7 @@ jobs:
# fast with a clear message if this runner has no KVM at all.
run: |
if [ ! -e /dev/kvm ]; then
echo "::error::/dev/kvm not present on this runner; cannot run the Linux/KVM e2e." >&2
echo "::error::/dev/kvm not present on this runner; cannot run the Linux/KVM tests." >&2
exit 1
fi
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
Expand Down Expand Up @@ -276,14 +272,6 @@ jobs:
echo "MINVMD_INITRAMFS=$TESTBED/initramfs.cpio"
} >> "$GITHUB_ENV"

- name: Materialize gvproxy switch binary
# The gvproxy relay e2e (vsock_relay_e2e) spawns this per-host switch
# binary; pin-verified, no Go toolchain. Publish its path for the gated
# step below.
run: |
./scripts/fetch-gvproxy.sh "$RUNNER_TEMP/gvproxy"
echo "MINVMD_GVPROXY_BIN=$RUNNER_TEMP/gvproxy" >> "$GITHUB_ENV"

- name: Materialize guest kernel (raw Image)
uses: ./.github/actions/materialize
with:
Expand All @@ -300,63 +288,52 @@ jobs:
arch: x86_64
channel: unstable

- name: Boot E2E (READY round-trip)
- name: VM integration harnesses (auto-discovered)
# Convention over enumeration: run every harness the archive carries by
# the `_integration` suffix, so a new crates/minvmd/tests/*_integration.rs
# file is picked up here with zero workflow edit (the auto-discovery
# contract; a normal unit test in minvmd guards the suffix).
# `--run-ignored all` runs
# the `#[ignore]`-gated bodies; `--no-tests=fail` reds the job if the
# filterset ever matches nothing. MINVMD_E2E=1 is set job-wide; profile
# vm is serial with fail-fast, so a failure preserves its own boot.log.
# The `not binary(/_root_integration$/)` guard is defensive: minvmd has no root
# harness today (its host-side tap relay moved into the guest minimald),
# so if one is ever added it must get its own sudo-wrapped step rather
# than run unprivileged here.
env:
MINVMD_BOOT_LOG: ${{ runner.temp }}/boot.log
run: |
cargo-nextest nextest run --archive-file "$TESTBED/nextest-archive.tar.zst" \
--workspace-remap "$GITHUB_WORKSPACE" --profile vm \
--run-ignored all --no-tests=fail -E 'binary(boot_e2e)'

- name: Session E2E (full minimald session over the bridge)
run: |
cargo-nextest nextest run --archive-file "$TESTBED/nextest-archive.tar.zst" \
--workspace-remap "$GITHUB_WORKSPACE" --profile vm \
--run-ignored all --no-tests=fail \
-E 'binary(minimald_session_e2e) and test(=minimald_exec_over_bridge)'

- name: Gvproxy relay E2E (OwnIp PTask gets a switch IP)
# Boots an OwnIp VM and asserts its netns receives a 100.64.0.0/16 switch
# IP via the async TAP↔gvproxy relay, with frames traversing the switch.
# Needs /dev/kvm, the gvproxy binary, and CAP_NET_ADMIN (tap + netns), so
# it is `#[ignore]`-gated and only runs here with the env gate set.
# `sudo -E` preserves the testbed env while granting the tap/netns
# capabilities the relay requires.
env:
MINVMD_INTEGRATION_TEST: "1"
run: |
sudo -E env "PATH=$PATH" "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" \
cargo-nextest nextest run --archive-file "$TESTBED/nextest-archive.tar.zst" \
--workspace-remap "$GITHUB_WORKSPACE" --profile vm \
--run-ignored all --no-tests=fail -E 'binary(vsock_relay_e2e)'
-E 'binary(/_integration$/) and not binary(/_root_integration$/)'

# NOTE: bridge_e2e is intentionally NOT run here. It targets the Stage-1
# guest "vsock stub" (a socat/cat echo on port 2222) that minimald-as-pid1
# replaced with a direct SSH session server, so it now reads back the SSH
# banner instead of its echo payload. The macOS lane likewise runs only
# minimald_session_e2e; session coverage of the bridge is provided by
# Session E2E above plus the daemon lifecycle step below.
# NOTE: there is no separate concurrent-bridge harness. The retired
# Stage-1 vsock stub (a socat/cat echo on port 2222) that one exercised was
# superseded by minimald's direct SSH session server; session coverage of
# the bridge is minimald_session_integration (in the harness step above)
# plus the daemon lifecycle step below.

- name: Reap leftover VM processes
# The harness runs above can leak __krun-vmm / gvproxy children on
# failure (Guest::drop kills only its own minvmd), and a leftover
# wedges the vsock bridge for the fresh daemons the next two steps
# spawn (lifecycle, then the CLI session e2e). Root-owned leftovers
# are possible here (the relay e2e runs under sudo), hence sudo.
# Ported from the macOS lane; the proper fix is for the harness to
# reap its own process group, tracked separately.
# The harness runs above can leak __krun-vmm children on failure
# (Guest::drop kills only its own minvmd), and a leftover wedges the
# vsock bridge for the fresh daemons the next two steps spawn
# (lifecycle, then the CLI session e2e). The harnesses run as the
# runner, so leftovers are runner-owned; sudo is kept as a defensive
# backstop. Ported from the macOS lane; the proper fix is for the
# harness to reap its own process group, tracked separately.
run: |
sudo pkill -x minvmd || true
sudo pkill -f __krun-vmm || true
sudo pkill -f gvproxy || true

- name: Daemon lifecycle (run --detach → status → stop)
# Exercises the supervised daemon path that manages the lifecycle
# state, which the harness e2e tests above do not cover. The script
# state, which the integration harnesses above do not cover. The script
# resolves minvmd from PATH (the testbed dir, added at unpack).
env:
MINVMD_BOOT_LOG: ${{ runner.temp }}/boot-daemon.log
run: ./scripts/lifecycle-e2e.sh
run: ./scripts/minvmd-lifecycle.sh

- name: Session e2e via the CLI (activate/exec/destroy; autospawns minvmd)
# The SAME unified proof every target lane runs (scripts/session-e2e.sh)
Expand Down
62 changes: 40 additions & 22 deletions .github/workflows/ci-linux-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ name: CI (Linux native)
# PR, while a skipped in-workflow job just reports `skipped`, which the
# aggregator treats as pass. Do NOT add trigger-level `paths:` here.
#
# The netns namespace proofs (UC1/UC4/UC6) run here in the `netns-integration`
# job (sudo + a userspace gvproxy switch, no KVM). The `networking-proxy` (mTLS)
# feature tests and the mesh UC7 / `networking-wg` proofs are deliberately NOT
# run in this lane — see the note on the tests job.
# minimald's root integration proofs (the network-namespace proofs — no-network
# egress isolation, static ingress port mapping, and task-to-task connectivity
# over the gvproxy switch) run here in the `minimald-root-integration` job (sudo + a
# userspace gvproxy switch, no KVM), auto-discovered by the `_root_integration`
# binary-name convention. The `networking-proxy` (mTLS reverse proxy) feature
# tests and the WireGuard mesh (`networking-wg`) proof are deliberately NOT run
# in this lane — see the note on the tests job.
on:
push:
branches: ["main"]
Expand Down Expand Up @@ -83,10 +86,10 @@ jobs:
#
# Deliberately absent (owner decision): the `--features networking-proxy`
# (mTLS reverse proxy) and `--features networking-wg` (WireGuard mesh) test
# steps that ci.yml's `test` job still carries, and the mesh UC7 namespace
# proof (crates/minimald/tests/mesh_uc7.rs). The netns UC1/UC4/UC6 proofs
# (crates/minimald/tests/netns.rs) run in the `netns-integration` job below.
# The rest stay in-tree and runnable locally, just not CI-covered.
# steps that ci.yml's `test` job still carries, and the WireGuard mesh
# proof (crates/minimald/tests/mesh_uc7.rs). The network-namespace proofs
# (crates/minimald/tests/netns_root_integration.rs) run in the `minimald-root-integration`
# job below. The rest stay in-tree and runnable locally, just not CI-covered.
needs: [changes]
if: github.event_name != 'pull_request' || needs.changes.outputs.native == 'true'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -141,14 +144,19 @@ jobs:
export PATH="$PWD/target/debug:$PATH"
./scripts/session-e2e.sh

netns-integration:
# The UC1 (no-net) / UC4 (static ingress) / UC6 (PTask<->PTask over the
# gvproxy switch) network-namespace proofs (crates/minimald/tests/netns.rs):
# two own-ip PTasks on a real gvproxy switch, driving the PRODUCTION
# switch-attach wiring. #[ignore] + gated on MINIMALD_NETNS_TEST so they run
# only here. Needs unprivileged userns + sudo (tap/netns) and a userspace
# gvproxy — no KVM. The mesh UC7 proof (networking-wg) is intentionally
# absent (feature disabled).
minimald-root-integration:
# minimald's root integration proofs, auto-discovered by the `_root_integration`
# binary-name convention — a new crates/minimald/tests/*_root_integration.rs runs
# here with no workflow edit. Today that is netns_root_integration: the
# network-namespace proofs — a no-network task can't reach the internet, a
# static ingress mapping exposes then removes a task's port, and two own-IP
# tasks reach each other — on a real gvproxy switch, driving the PRODUCTION
# switch-attach wiring. They create tap devices and configure network
# namespaces, which needs CAP_NET_ADMIN, so they run under sudo; #[ignore] +
# gated on MINIMALD_NETNS_TEST so they run only here. Needs unprivileged
# userns + sudo (tap/netns) and a userspace gvproxy — no KVM. The WireGuard
# mesh proof (networking-wg) stays out: its feature is off, so it compiles to
# nothing and its file name does not match the convention.
needs: [changes]
if: github.event_name != 'pull_request' || needs.changes.outputs.native == 'true'
runs-on: ubuntu-latest
Expand All @@ -159,8 +167,14 @@ jobs:
persist-credentials: false
- uses: ./.github/actions/setup-rust
with:
# Builds the `netns` integration target, not the workspace suite.
# Builds minimald's integration targets, not the workspace suite.
shared-key: netns
- name: Install nextest
# Convention selection is a nextest filterset (binary(/_root_integration$/));
# cargo test cannot select test targets by pattern.
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Enable unprivileged user namespaces
# The PTask namespaces (hakoniwa/unshare) need userns; Ubuntu 24.04
# restricts them via AppArmor by default.
Expand All @@ -177,20 +191,24 @@ jobs:
fi
sudo ip netns del _ci_probe 2>/dev/null || true
echo "netns capability: OK"
- name: Run netns proofs (UC1 no-net, UC4 ingress, UC6 PTask-to-PTask)
- name: Run minimald root integration proofs (auto-discovered)
env:
MINIMALD_NETNS_TEST: "1"
GVPROXY_BIN: ${{ runner.temp }}/gvproxy
# --include-ignored exercises the #[ignore] proofs; the env gate flips
# them from early-return to run. The tap/netns commands sudo themselves.
run: cargo test -p minimald --test netns -- --include-ignored --nocapture
# `binary(/_root_integration$/)` selects every root harness by suffi 8251 x;
# `--run-ignored all` flips the #[ignore] proofs from early-return to
# run; `--no-tests=fail` reds the job if the convention ever matches
# nothing. The tap/netns commands sudo themselves.
run: |
cargo nextest run -p minimald --profile ci \
--run-ignored all --no-tests=fail -E 'binary(/_root_integration$/)'

# Single required status check for this lane (branch-protection context:
# ci-linux-native-success). Green when every gating job succeeded OR was
# path-skipped; red only on failure/cancellation.
ci-linux-native-success:
if: always()
needs: [changes, tests, native-daemon-e2e, netns-integration]
needs: [changes, tests, native-daemon-e2e, minimald-root-integration]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand Down
Loading
Loading
0