guard/.github/workflows/ci.yml
loki5512344 a4cf78e475
feat(v0.4): xdp_ci entry point, per-port bans, capability-based diagnostics, recovery check
- scripts/xdp_ci.sh with honest SKIP and RESULT lines, CI job xdp-kernel
- Blacklist::add_port/is_blocked_on, enforced by the gateway (userspace only)
- diagnostics read CapEff: root without CAP_BPF is not privileged
- smoke phase 9 verifies 'ip link set dev <if> xdp off' recovery
- module-size gate: lockout moved into a directory, detach_xdp into services
2026-11-21 15:34:21 +01:00

120 lines
4.4 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
rust-check:
name: Rust — check & clippy
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- run: sudo apt-get update && sudo apt-get install -y libelf-dev libbpf-dev clang linux-libc-dev
- run: cargo fmt --all --check
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo check --all-features
- run: cargo check --no-default-features --all-targets
- name: XDP — build binaries
run: cargo build --features xdp --bins
- name: XDP — smoke-check BPF compilation (clang)
run: |
mkdir -p target/xdp
# clang with `-target bpf` does not search the glibc multiarch directory,
# so the asm/types.h pulled in by linux/types.h needs an explicit -I.
clang -O2 -g -target bpf -I"/usr/include/$(gcc -print-multiarch)" \
-c xdp/core/universal_filter.c -o target/xdp/universal_filter.o
test -f target/xdp/universal_filter.o
rust-test:
name: Rust — test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# libbpf-sys builds a vendored libbpf (needs libelf/zlib), and build.rs
# compiles the XDP program with clang (needs libbpf-dev/linux-libc-dev).
- run: sudo apt-get update && sudo apt-get install -y libelf-dev zlib1g-dev libbpf-dev clang linux-libc-dev
- run: cargo test --all-features
rust-test-no-default-features:
name: Rust — test (no default features, protocol-http)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: sudo apt-get update && sudo apt-get install -y libelf-dev zlib1g-dev libbpf-dev clang linux-libc-dev
# Feature-gated code must actually run: without this job the
# `--no-default-features` combination is only type-checked, never tested.
- run: cargo test --no-default-features --features protocol-http
repo-gates:
name: Repo — module size & default secrets
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- name: Module size gate
run: bash scripts/check_module_size.sh
- name: Default secrets gate
run: bash scripts/check_default_secrets.sh
- name: Documentation links gate
run: bash scripts/check_docs_links.sh
rust-deny:
name: Rust — cargo-deny
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check
docker:
name: Docker — build edge image
runs-on: ubuntu-24.04
needs: [rust-test]
steps:
- uses: actions/checkout@v7
- uses: docker/setup-buildx-action@v4
- name: Build edge
uses: docker/build-push-action@v7
with:
context: .
file: deploy/docker/Dockerfile.edge
load: true
tags: rampart/edge:ci
xdp-kernel:
name: XDP — netns smoke on a real kernel
runs-on: ubuntu-24.04
needs: [rust-check]
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: sudo apt-get update && sudo apt-get install -y libelf-dev zlib1g-dev libbpf-dev clang linux-libc-dev hping3 iproute2 curl python3
# bpftool for the running (Azure) kernel may not be packaged; xdp_ci.sh also
# looks for any real binary under /usr/lib/linux-tools*.
- run: sudo apt-get install -y linux-tools-common linux-tools-generic || true
# Built as the normal user: `sudo` resets PATH, so the script must not build.
- run: cargo build --release --features xdp,protocol-http --bin rampart
- name: XDP — pkt + smoke (SKIP is reported, never counted as a pass)
run: |
set -o pipefail
BIN="$PWD/target/release/rampart" bash scripts/xdp_ci.sh --ci | tee xdp_ci.log
if grep -q '^RESULT xdp_ci SKIP' xdp_ci.log; then
echo "::warning title=XDP harness skipped::$(grep '^SKIP:' xdp_ci.log)"
fi