From 06e92a56262afead74ba6423b185a4a05c9b0922 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 20:23:07 -0600 Subject: [PATCH 01/14] Skip heavyweight Toolkit checks for documentation-only PRs --- .gitea/workflows/verify.yml | 32 ++++++++++++++++++ ci/pr-surface.py | 55 ++++++++++++++++++++++++++++++ ci/test-pr-surface.py | 67 +++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 ci/pr-surface.py create mode 100644 ci/test-pr-surface.py diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index 81104c0b..9ab99873 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -16,8 +16,31 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Detect changed surface + id: surface + run: python3 ci/pr-surface.py >> "$GITHUB_OUTPUT" + + - name: Check documentation change + if: steps.surface.outputs.surface == 'documentation' + run: | + base="$(git merge-base HEAD "origin/$GITHUB_BASE_REF")" + git diff --check "$base" HEAD + if git grep -nIE '^[[:space:]]*-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----[[:space:]]*$' --; then + echo "private key material found in tracked source" >&2 + exit 1 + else + status=$? + [ "$status" -eq 1 ] + + - name: Check CI change surface + if: steps.surface.outputs.surface != 'documentation' + run: python3 ci/test-pr-surface.py - name: Install build dependencies + if: steps.surface.outputs.surface != 'documentation' run: | apt-get update -qq apt-get install -y -qq --no-install-recommends \ @@ -25,15 +48,18 @@ jobs: - name: Compute wxWidgets cache key id: wx-key + if: steps.surface.outputs.surface != 'documentation' run: bash ci/wx-cache-key.sh - name: Cache vendored wxWidgets build + if: steps.surface.outputs.surface != 'documentation' uses: actions/cache@v4 with: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets (once, then cached) + if: steps.surface.outputs.surface != 'documentation' run: | if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then bash scripts/build-wx-linux.sh @@ -42,23 +68,28 @@ jobs: fi - name: Clippy (our crate, warnings are errors) + if: steps.surface.outputs.surface != 'documentation' run: | rustup component add clippy >/dev/null 2>&1 || true cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings cargo clippy -p alkane-artifacts -p alkane-flash -p alkane-cli --all-targets --offline -- -D warnings - name: Build + if: steps.surface.outputs.surface != 'documentation' run: cargo build --release -p alkane-gui --offline - name: Unit tests + if: steps.surface.outputs.surface != 'documentation' run: | cargo test -p alkane-gui --offline cargo test -p alkane-artifacts -p alkane-flash -p alkane-cli --offline - name: Microbenchmarks + if: steps.surface.outputs.surface != 'documentation' run: cargo test -p alkane-gui -p alkane-artifacts --release --offline -- --ignored --nocapture bench_ --test-threads=1 - name: Headless UI self-test + if: steps.surface.outputs.surface != 'documentation' run: | apt-get update -qq && apt-get install -y -qq --no-install-recommends \ xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null @@ -70,6 +101,7 @@ jobs: # runner must not fail the gate on it. Accepted advisories live in # .cargo/audit.toml. - name: Dependency audit (best-effort) + if: steps.surface.outputs.surface != 'documentation' continue-on-error: true run: | if command -v cargo-audit >/dev/null 2>&1; then diff --git a/ci/pr-surface.py b/ci/pr-surface.py new file mode 100644 index 00000000..f571cff5 --- /dev/null +++ b/ci/pr-surface.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Classify a pull request for the documentation-only CI shortcut.""" + +import os +from pathlib import Path +import subprocess +import sys + + +ROOT = Path(__file__).resolve().parents[1] +DOC_FILES = {"README.md", "CONTRIBUTING.md", "CHANGELOG.md"} + + +def documentation_only(paths: list[str]) -> bool: + return bool(paths) and all( + path in DOC_FILES or + (path.startswith("docs/") and Path(path).suffix in {".md", ".txt"}) + for path in paths + ) + + +def changed_paths() -> list[str]: + if os.environ.get("GITHUB_EVENT_NAME") != "pull_request": + raise ValueError("not a pull request") + if os.environ.get("GITHUB_BASE_REF") != "main": + raise ValueError("unknown base branch") + merge_base = subprocess.check_output( + ["git", "-C", str(ROOT), "merge-base", "HEAD", + "refs/remotes/origin/main"], + stderr=subprocess.DEVNULL, text=True, + ).strip() + if len(merge_base) != 40: + raise ValueError("missing merge base") + raw = subprocess.check_output( + ["git", "-C", str(ROOT), "diff", "--name-only", "-z", + merge_base, "HEAD"], stderr=subprocess.DEVNULL, + ) + return [path.decode("utf-8", "surrogateescape") + for path in raw.split(b"\0") if path] + + +def main() -> None: + try: + paths = changed_paths() + docs = documentation_only(paths) + except (OSError, subprocess.CalledProcessError, ValueError): + paths = [] + docs = False + print(f"surface={'documentation' if docs else 'full'}") + print(f"Changed paths: {len(paths)}", file=sys.stderr) + + +if __name__ == "__main__": + main() diff --git a/ci/test-pr-surface.py b/ci/test-pr-surface.py new file mode 100644 index 00000000..6f3b2c41 --- /dev/null +++ b/ci/test-pr-surface.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Check that unknown changes cannot take the documentation-only CI path.""" + +import os +from pathlib import Path +import subprocess +import tempfile + +import importlib.util + + +SCRIPT = Path(__file__).with_name("pr-surface.py") +spec = importlib.util.spec_from_file_location("pr_surface", SCRIPT) +assert spec and spec.loader +pr_surface = importlib.util.module_from_spec(spec) +spec.loader.exec_module(pr_surface) + + +def git(directory: Path, *args: str) -> str: + return subprocess.check_output( + ["git", "-C", str(directory), *args], text=True, + stderr=subprocess.DEVNULL, + ).strip() + + +def main() -> None: + assert pr_surface.documentation_only(["README.md", "docs/setup.md"]) + for paths in ([], ["docs/generated.json"], ["src/main.rs"], + ["README.md", "ci/pr-surface.py"]): + assert not pr_surface.documentation_only(paths), paths + + with tempfile.TemporaryDirectory(prefix="alkane-toolkit-pr-surface-") as directory: + repo = Path(directory) + git(repo, "init", "-q") + git(repo, "config", "user.name", "CI Test") + git(repo, "config", "user.email", "ci@example.invalid") + (repo / "README.md").write_text("initial\n") + git(repo, "add", "README.md") + git(repo, "commit", "-qm", "base") + base = git(repo, "rev-parse", "HEAD") + git(repo, "update-ref", "refs/remotes/origin/main", base) + (repo / "README.md").write_text("documentation change\n") + git(repo, "commit", "-qam", "docs") + saved_root = pr_surface.ROOT + saved_env = dict(os.environ) + try: + pr_surface.ROOT = repo + os.environ["GITHUB_EVENT_NAME"] = "pull_request" + os.environ["GITHUB_BASE_REF"] = "main" + assert pr_surface.changed_paths() == ["README.md"] + os.environ.pop("GITHUB_BASE_REF") + try: + pr_surface.changed_paths() + except ValueError: + pass + else: + raise AssertionError("missing base must fall back to full checks") + finally: + pr_surface.ROOT = saved_root + os.environ.clear() + os.environ.update(saved_env) + print("Toolkit PR change surface: documentation shortcut and fallback PASS") + + +if __name__ == "__main__": + main() -- 2.54.0 From e42dd6152c1617fa34ebf11212c03fe7ebeeb4d0 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 20:34:42 -0600 Subject: [PATCH 02/14] Skip redundant Toolkit package setup on prepared runners --- .gitea/workflows/bench-pages.yml | 4 +--- .gitea/workflows/next.yml | 4 +--- .gitea/workflows/release.yml | 6 +----- .gitea/workflows/verify.yml | 8 ++------ ci/ensure-build-deps.sh | 29 +++++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 ci/ensure-build-deps.sh diff --git a/.gitea/workflows/bench-pages.yml b/.gitea/workflows/bench-pages.yml index 48b89c40..b154c3c2 100644 --- a/.gitea/workflows/bench-pages.yml +++ b/.gitea/workflows/bench-pages.yml @@ -15,9 +15,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install SSH client - run: | - apt-get update -qq - apt-get install -y -qq --no-install-recommends openssh-client + run: bash ci/ensure-build-deps.sh ssh - name: Render measured benchmark history env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index e112ce13..223abea6 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -23,9 +23,7 @@ jobs: with: fetch-depth: 0 - name: Install build dependencies - run: | - apt-get update -qq - apt-get install -y -qq --no-install-recommends libssl-dev pkg-config ca-certificates + run: bash ci/ensure-build-deps.sh base - name: Compute wxWidgets cache key id: wx-key run: bash ci/wx-cache-key.sh diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 2fdb91d7..fb32997c 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -46,11 +46,7 @@ jobs: run: python3 ci/test-bench-badge.py - name: Install build dependencies - run: | - apt-get update -qq - apt-get install -y -qq --no-install-recommends \ - libssl-dev pkg-config ca-certificates openssh-client \ - xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null + run: bash ci/ensure-build-deps.sh all - name: Compute wxWidgets cache key id: wx-key diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index 9ab99873..7177cd4c 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -41,10 +41,7 @@ jobs: - name: Install build dependencies if: steps.surface.outputs.surface != 'documentation' - run: | - apt-get update -qq - apt-get install -y -qq --no-install-recommends \ - libssl-dev pkg-config ca-certificates >/dev/null + run: bash ci/ensure-build-deps.sh base - name: Compute wxWidgets cache key id: wx-key @@ -91,8 +88,7 @@ jobs: - name: Headless UI self-test if: steps.surface.outputs.surface != 'documentation' run: | - apt-get update -qq && apt-get install -y -qq --no-install-recommends \ - xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null + bash ci/ensure-build-deps.sh ui BIN=target/release/alkane-toolkit xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN" diff --git a/ci/ensure-build-deps.sh b/ci/ensure-build-deps.sh new file mode 100644 index 00000000..b6f85d35 --- /dev/null +++ b/ci/ensure-build-deps.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Use the preinstalled CI image or install missing packages on older runners. +set -euo pipefail + +mode="${1:?usage: ensure-build-deps.sh base|ui|all|ssh}" +case "$mode" in + base) packages=(libssl-dev pkg-config ca-certificates) ;; + ui) packages=(xvfb xauth dbus-x11 fonts-dejavu-core) ;; + ssh) packages=(openssh-client) ;; + all) packages=(libssl-dev pkg-config ca-certificates openssh-client + xvfb xauth dbus-x11 fonts-dejavu-core) ;; + *) echo "unknown dependency set: $mode" >&2; exit 2 ;; +esac + +installed="$(dpkg-query -W -f='${Package} ${Status}\n' "${packages[@]}" 2>/dev/null || true)" +missing=() +for package in "${packages[@]}"; do + if ! grep -Fxq "$package install ok installed" <<< "$installed"; then + missing+=("$package") + fi +done +if [ "${#missing[@]}" -eq 0 ]; then + printf 'Build packages already installed: %s\n' "$mode" + exit 0 +fi +printf 'Installing %s missing build packages\n' "${#missing[@]}" +apt-get update -qq +DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends "${packages[@]}" -- 2.54.0 From f2189371ed3916cd522e74ee194b51b22f3d7558 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 20:39:01 -0600 Subject: [PATCH 03/14] Key wxWidgets cache to available native packages --- ci/wx-cache-key.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/wx-cache-key.sh b/ci/wx-cache-key.sh index 65f37d68..43100bd6 100644 --- a/ci/wx-cache-key.sh +++ b/ci/wx-cache-key.sh @@ -10,6 +10,10 @@ material="$({ gcc -dumpmachine gcc -dumpfullversion pkg-config --modversion gtk+-3.0 + mapfile -t modules < <(pkg-config --list-all | awk '{print $1}' | LC_ALL=C sort -u) + for module in "${modules[@]}"; do + printf '%s=%s\n' "$module" "$(pkg-config --modversion "$module" 2>/dev/null || printf unavailable)" + done getconf GNU_LIBC_VERSION } )" digest="$(printf '%s\n' "$material" | sha256sum | cut -c1-24)" -- 2.54.0 From 1dbb8d990291a75adb4d038d3d819559a4566f45 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 20:52:44 -0600 Subject: [PATCH 04/14] Save wxWidgets cache before later quality checks --- .gitea/workflows/next.yml | 15 +++++++++++++-- .gitea/workflows/release.yml | 16 ++++++++++++++-- .gitea/workflows/verify.yml | 16 ++++++++++++++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index 223abea6..0abdb943 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -27,15 +27,26 @@ jobs: - name: Compute wxWidgets cache key id: wx-key run: bash ci/wx-cache-key.sh - - uses: actions/cache@v4 + - id: wx-cache + uses: actions/cache/restore@v4 + continue-on-error: true with: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then + if [ ! -x "$WX_PREFIX/bin/wx-config" ] || + [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then bash scripts/build-wx-linux.sh fi + [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + - name: Save vendored wxWidgets build + if: steps.wx-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + continue-on-error: true + with: + path: /root/.cache/wx-3.3.3-linux + key: ${{ steps.wx-key.outputs.key }} - name: Build release candidate run: cargo build --release -p alkane-gui -p alkane-artifacts -p alkane-flash -p alkane-cli --offline - name: Select candidate version diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index fb32997c..6c3cc36f 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -53,18 +53,30 @@ jobs: run: bash ci/wx-cache-key.sh - name: Cache vendored wxWidgets build - uses: actions/cache@v4 + id: wx-cache + uses: actions/cache/restore@v4 + continue-on-error: true with: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets (once, then cached) run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then + if [ ! -x "$WX_PREFIX/bin/wx-config" ] || + [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then bash scripts/build-wx-linux.sh else echo "wx prefix restored from cache" fi + [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + + - name: Save vendored wxWidgets build + if: steps.wx-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + continue-on-error: true + with: + path: /root/.cache/wx-3.3.3-linux + key: ${{ steps.wx-key.outputs.key }} - name: Clippy (our crate, warnings are errors) run: | diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index 7177cd4c..cf00b044 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -50,7 +50,9 @@ jobs: - name: Cache vendored wxWidgets build if: steps.surface.outputs.surface != 'documentation' - uses: actions/cache@v4 + id: wx-cache + uses: actions/cache/restore@v4 + continue-on-error: true with: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} @@ -58,11 +60,21 @@ jobs: - name: Build wxWidgets (once, then cached) if: steps.surface.outputs.surface != 'documentation' run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then + if [ ! -x "$WX_PREFIX/bin/wx-config" ] || + [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then bash scripts/build-wx-linux.sh else echo "wx prefix restored from cache" fi + [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + + - name: Save vendored wxWidgets build + if: steps.surface.outputs.surface != 'documentation' && steps.wx-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + continue-on-error: true + with: + path: /root/.cache/wx-3.3.3-linux + key: ${{ steps.wx-key.outputs.key }} - name: Clippy (our crate, warnings are errors) if: steps.surface.outputs.surface != 'documentation' -- 2.54.0 From 1cb8190e8904c35df4d54e24b4020331cefbf88c Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 20:58:33 -0600 Subject: [PATCH 05/14] Scope headless crate PR checks to reverse dependencies --- .gitea/workflows/verify.yml | 35 +++++++++++++++------ ci/pr-surface.py | 61 +++++++++++++++++++++++++++++++++++-- ci/test-pr-surface.py | 49 +++++++++++++++++++++++++++-- 3 files changed, 131 insertions(+), 14 deletions(-) diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index cf00b044..d8ba3679 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -45,11 +45,11 @@ jobs: - name: Compute wxWidgets cache key id: wx-key - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' run: bash ci/wx-cache-key.sh - name: Cache vendored wxWidgets build - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' id: wx-cache uses: actions/cache/restore@v4 continue-on-error: true @@ -58,7 +58,7 @@ jobs: key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets (once, then cached) - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' run: | if [ ! -x "$WX_PREFIX/bin/wx-config" ] || [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then @@ -69,7 +69,7 @@ jobs: [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] - name: Save vendored wxWidgets build - if: steps.surface.outputs.surface != 'documentation' && steps.wx-cache.outputs.cache-hit != 'true' + if: steps.surface.outputs.surface == 'full' && steps.wx-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v4 continue-on-error: true with: @@ -77,28 +77,45 @@ jobs: key: ${{ steps.wx-key.outputs.key }} - name: Clippy (our crate, warnings are errors) - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' run: | rustup component add clippy >/dev/null 2>&1 || true cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings cargo clippy -p alkane-artifacts -p alkane-flash -p alkane-cli --all-targets --offline -- -D warnings + - name: Headless crate checks + if: steps.surface.outputs.surface == 'headless' + env: + PACKAGES: ${{ steps.surface.outputs.packages }} + run: | + rustup component add clippy >/dev/null 2>&1 || true + args=() + for package in $PACKAGES; do + case "$package" in + alkane-access|alkane-artifacts|alkane-cli|alkane-flash) args+=(-p "$package") ;; + *) echo "unrecognized crate: $package" >&2; exit 1 ;; + esac + done + [ "${#args[@]}" -gt 0 ] + cargo clippy "${args[@]}" --all-targets --offline -- -D warnings + cargo test "${args[@]}" --offline + - name: Build - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' run: cargo build --release -p alkane-gui --offline - name: Unit tests - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' run: | cargo test -p alkane-gui --offline cargo test -p alkane-artifacts -p alkane-flash -p alkane-cli --offline - name: Microbenchmarks - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' run: cargo test -p alkane-gui -p alkane-artifacts --release --offline -- --ignored --nocapture bench_ --test-threads=1 - name: Headless UI self-test - if: steps.surface.outputs.surface != 'documentation' + if: steps.surface.outputs.surface == 'full' run: | bash ci/ensure-build-deps.sh ui BIN=target/release/alkane-toolkit diff --git a/ci/pr-surface.py b/ci/pr-surface.py index f571cff5..42c4ed1c 100644 --- a/ci/pr-surface.py +++ b/ci/pr-surface.py @@ -1,15 +1,17 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: MIT -"""Classify a pull request for the documentation-only CI shortcut.""" +"""Classify a pull request for scoped CI checks.""" import os from pathlib import Path import subprocess import sys +import tomllib ROOT = Path(__file__).resolve().parents[1] DOC_FILES = {"README.md", "CONTRIBUTING.md", "CHANGELOG.md"} +HEADLESS_CRATES = {"alkane-access", "alkane-artifacts", "alkane-cli", "alkane-flash"} def documentation_only(paths: list[str]) -> bool: @@ -20,6 +22,55 @@ def documentation_only(paths: list[str]) -> bool: ) +def headless_packages(paths: list[str]) -> list[str]: + """Return tested reverse dependents for code outside the GUI graph.""" + changed: set[str] = set() + if not paths: + return [] + for path in paths: + parts = Path(path).parts + if (len(parts) < 4 or parts[0] != "crates" or + parts[1] not in HEADLESS_CRATES or + parts[2] not in {"src", "tests"} or + Path(path).suffix != ".rs"): + return [] + changed.add(parts[1]) + + try: + manifests = {} + for path in (ROOT / "crates").glob("*/Cargo.toml"): + manifest = tomllib.loads(path.read_text()) + name = manifest["package"]["name"] + if name != path.parent.name: + return [] + manifests[name] = manifest + if not changed <= manifests.keys() or "alkane-gui" not in manifests: + return [] + + def dependencies(value: object) -> set[str]: + found: set[str] = set() + if isinstance(value, dict): + for key, nested in value.items(): + if key in {"dependencies", "dev-dependencies", "build-dependencies"}: + for dep_name, spec in nested.items(): + found.add(spec.get("package", dep_name) if isinstance(spec, dict) + else dep_name) + else: + found.update(dependencies(nested)) + return found & manifests.keys() + + graph = {name: dependencies(manifest) for name, manifest in manifests.items()} + affected = changed.copy() + while True: + added = {name for name, deps in graph.items() if deps & affected} - affected + if not added: + break + affected.update(added) + return [] if "alkane-gui" in affected else sorted(affected) + except (OSError, KeyError, TypeError, ValueError): + return [] + + def changed_paths() -> list[str]: if os.environ.get("GITHUB_EVENT_NAME") != "pull_request": raise ValueError("not a pull request") @@ -33,7 +84,7 @@ def changed_paths() -> list[str]: if len(merge_base) != 40: raise ValueError("missing merge base") raw = subprocess.check_output( - ["git", "-C", str(ROOT), "diff", "--name-only", "-z", + ["git", "-C", str(ROOT), "diff", "--no-renames", "--name-only", "-z", merge_base, "HEAD"], stderr=subprocess.DEVNULL, ) return [path.decode("utf-8", "surrogateescape") @@ -44,10 +95,14 @@ def main() -> None: try: paths = changed_paths() docs = documentation_only(paths) + packages = headless_packages(paths) if not docs else [] except (OSError, subprocess.CalledProcessError, ValueError): paths = [] docs = False - print(f"surface={'documentation' if docs else 'full'}") + packages = [] + surface = "documentation" if docs else "headless" if packages else "full" + print(f"surface={surface}") + print(f"packages={' '.join(packages)}") print(f"Changed paths: {len(paths)}", file=sys.stderr) diff --git a/ci/test-pr-surface.py b/ci/test-pr-surface.py index 6f3b2c41..324a9f30 100644 --- a/ci/test-pr-surface.py +++ b/ci/test-pr-surface.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: MIT -"""Check that unknown changes cannot take the documentation-only CI path.""" +"""Check that unknown changes cannot take a scoped CI path.""" import os from pathlib import Path @@ -29,6 +29,47 @@ def main() -> None: for paths in ([], ["docs/generated.json"], ["src/main.rs"], ["README.md", "ci/pr-surface.py"]): assert not pr_surface.documentation_only(paths), paths + assert pr_surface.headless_packages(["crates/alkane-cli/src/main.rs"]) == ["alkane-cli"] + assert pr_surface.headless_packages(["crates/alkane-artifacts/src/lib.rs"]) == [ + "alkane-artifacts", "alkane-cli", "alkane-flash", + ] + assert pr_surface.headless_packages([ + "crates/alkane-access/src/lib.rs", "crates/alkane-flash/tests/update.rs", + ]) == ["alkane-access", "alkane-flash"] + for paths in ([], ["crates/alkane-core/src/lib.rs"], + ["crates/alkane-discovery/src/lib.rs"], + ["crates/alkane-gui/src/main.rs"], + ["crates/alkane-artifacts/Cargo.toml"], + ["crates/alkane-cli/src/main.rs", "Cargo.lock"], + ["crates/alkane-cli/src/main.rs", "ci/pr-surface.py"], + ["crates/alkane-cli/README.md"]): + assert pr_surface.headless_packages(paths) == [], paths + + with tempfile.TemporaryDirectory(prefix="alkane-toolkit-graph-") as directory: + root = Path(directory) + for name, extra in ( + ("alkane-gui", ""), + ("alkane-artifacts", ""), + ("alkane-flash", 'alkane-artifacts = { path = "../alkane-artifacts" }\n'), + ): + crate = root / "crates" / name + crate.mkdir(parents=True) + (crate / "Cargo.toml").write_text( + f'[package]\nname = "{name}"\nversion = "0.1.0"\n' + f'[dependencies]\n{extra}' + ) + saved_root = pr_surface.ROOT + try: + pr_surface.ROOT = root + changed = ["crates/alkane-artifacts/src/lib.rs"] + assert pr_surface.headless_packages(changed) == [ + "alkane-artifacts", "alkane-flash", + ] + with (root / "crates/alkane-gui/Cargo.toml").open("a") as stream: + stream.write('alkane-flash = { path = "../alkane-flash" }\n') + assert pr_surface.headless_packages(changed) == [] + finally: + pr_surface.ROOT = saved_root with tempfile.TemporaryDirectory(prefix="alkane-toolkit-pr-surface-") as directory: repo = Path(directory) @@ -49,6 +90,10 @@ def main() -> None: os.environ["GITHUB_EVENT_NAME"] = "pull_request" os.environ["GITHUB_BASE_REF"] = "main" assert pr_surface.changed_paths() == ["README.md"] + git(repo, "checkout", "-q", "-b", "rename-check", base) + git(repo, "mv", "README.md", "code.rs") + git(repo, "commit", "-qm", "rename") + assert set(pr_surface.changed_paths()) == {"README.md", "code.rs"} os.environ.pop("GITHUB_BASE_REF") try: pr_surface.changed_paths() @@ -60,7 +105,7 @@ def main() -> None: pr_surface.ROOT = saved_root os.environ.clear() os.environ.update(saved_env) - print("Toolkit PR change surface: documentation shortcut and fallback PASS") + print("Toolkit PR change surface: documentation, headless, and fallback PASS") if __name__ == "__main__": -- 2.54.0 From 45e4e597bf9aeaf77edc0d69e03a68a44df88ddb Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 21:29:33 -0600 Subject: [PATCH 06/14] Cover all Toolkit crates and pin CI image --- .gitea/workflows/ci-badge.yml | 2 ++ .gitea/workflows/next.yml | 4 ++++ .gitea/workflows/release.yml | 9 +++++++-- .gitea/workflows/source.yml | 6 +++++- .gitea/workflows/verify.yml | 13 +++++++++++-- ci/check-runner-image.py | 35 +++++++++++++++++++++++++++++++++++ ci/runner-image.txt | 1 + 7 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 ci/check-runner-image.py create mode 100644 ci/runner-image.txt diff --git a/.gitea/workflows/ci-badge.yml b/.gitea/workflows/ci-badge.yml index 3a8e9c7b..85065fa3 100644 --- a/.gitea/workflows/ci-badge.yml +++ b/.gitea/workflows/ci-badge.yml @@ -8,6 +8,8 @@ on: jobs: publish: runs-on: alkane-fast + container: + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 permissions: actions: read contents: write diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index 0abdb943..ac8a7dae 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -14,6 +14,8 @@ permissions: jobs: candidate: runs-on: alkane-ci + container: + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 env: CARGO_TARGET_DIR: target WX_PREFIX: /root/.cache/wx-3.3.3-linux @@ -22,6 +24,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Check runner image pins + run: python3 ci/check-runner-image.py - name: Install build dependencies run: bash ci/ensure-build-deps.sh base - name: Compute wxWidgets cache key diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 6c3cc36f..d5924c3b 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -17,6 +17,8 @@ permissions: jobs: release: runs-on: alkane-ci + container: + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 env: CARGO_TARGET_DIR: target WX_PREFIX: /root/.cache/wx-3.3.3-linux @@ -29,6 +31,9 @@ jobs: with: fetch-depth: 0 + - name: Check runner image pins + run: python3 ci/check-runner-image.py + - name: Compute version id: ver run: bash ci/compute-version.sh | tee -a "$GITHUB_OUTPUT" @@ -82,7 +87,7 @@ jobs: run: | rustup component add clippy >/dev/null 2>&1 || true cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings - cargo clippy -p alkane-artifacts -p alkane-flash -p alkane-cli --all-targets --offline -- -D warnings + cargo clippy --workspace --exclude alkane-gui --exclude wx-rs --all-targets --offline -- -D warnings - name: Set crate version to ${{ steps.ver.outputs.version }} if: steps.ver.outputs.release == 'true' @@ -98,7 +103,7 @@ jobs: run: | set -o pipefail cargo test -p alkane-gui --offline 2>&1 | tee tests-gui.txt - cargo test -p alkane-artifacts -p alkane-flash -p alkane-cli --offline 2>&1 | tee tests-core.txt + cargo test --workspace --exclude alkane-gui --exclude wx-rs --offline 2>&1 | tee tests-core.txt cat tests-gui.txt tests-core.txt > tests-current.txt - name: Load previous main benchmark measurement diff --git a/.gitea/workflows/source.yml b/.gitea/workflows/source.yml index 104cae79..6cd3af40 100644 --- a/.gitea/workflows/source.yml +++ b/.gitea/workflows/source.yml @@ -13,12 +13,16 @@ concurrency: jobs: check: runs-on: alkane-fast + container: + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 env: CARGO_BUILD_JOBS: 2 steps: - uses: actions/checkout@v4 + - name: Check runner image pins + run: python3 ci/check-runner-image.py - name: Source checks - run: cargo test -p alkane-artifacts -p alkane-flash -p alkane-cli --offline + run: cargo test --workspace --exclude alkane-gui --exclude wx-rs --offline - name: Clean generated Toolkit build if: always() run: python3 ci/cleanup-generated.py diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index d8ba3679..b1001067 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -5,9 +5,15 @@ on: pull_request: branches: [main] +concurrency: + group: alkane-toolkit-verify-${{ github.ref }} + cancel-in-progress: true + jobs: verify: runs-on: alkane-verify + container: + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 env: CARGO_TARGET_DIR: target CARGO_BUILD_JOBS: 2 @@ -19,6 +25,9 @@ jobs: with: fetch-depth: 0 + - name: Check runner image pins + run: python3 ci/check-runner-image.py + - name: Detect changed surface id: surface run: python3 ci/pr-surface.py >> "$GITHUB_OUTPUT" @@ -81,7 +90,7 @@ jobs: run: | rustup component add clippy >/dev/null 2>&1 || true cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings - cargo clippy -p alkane-artifacts -p alkane-flash -p alkane-cli --all-targets --offline -- -D warnings + cargo clippy --workspace --exclude alkane-gui --exclude wx-rs --all-targets --offline -- -D warnings - name: Headless crate checks if: steps.surface.outputs.surface == 'headless' @@ -108,7 +117,7 @@ jobs: if: steps.surface.outputs.surface == 'full' run: | cargo test -p alkane-gui --offline - cargo test -p alkane-artifacts -p alkane-flash -p alkane-cli --offline + cargo test --workspace --exclude alkane-gui --exclude wx-rs --offline - name: Microbenchmarks if: steps.surface.outputs.surface == 'full' diff --git a/ci/check-runner-image.py b/ci/check-runner-image.py new file mode 100644 index 00000000..6f9d5fd6 --- /dev/null +++ b/ci/check-runner-image.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Keep Toolkit CI on the verified Alkane runner image.""" + +from pathlib import Path +import re +import sys + +import yaml + + +ROOT = Path(__file__).resolve().parents[1] +IMAGE = (ROOT / "ci/runner-image.txt").read_text().strip() + + +def main() -> int: + if not re.fullmatch( + r"gitea\.bluefla\.re/blueflare/alkane-ci@sha256:[0-9a-f]{64}", IMAGE + ): + print("Runner image must be pinned by Gitea registry digest", file=sys.stderr) + return 1 + for path in sorted((ROOT / ".gitea/workflows").glob("*.yml")): + workflow = yaml.load(path.read_text(), Loader=yaml.BaseLoader) + for name, job in workflow.get("jobs", {}).items(): + if job.get("runs-on") not in {"alkane-ci", "alkane-fast", "alkane-verify"}: + continue + if job.get("container", {}).get("image") != IMAGE: + print(f"{path.name}: {name} has a different runner image", file=sys.stderr) + return 1 + print("Toolkit runner image pins: PASS") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/ci/runner-image.txt b/ci/runner-image.txt new file mode 100644 index 00000000..21db8c24 --- /dev/null +++ b/ci/runner-image.txt @@ -0,0 +1 @@ +gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 -- 2.54.0 From d53665bce32270e117683358aa43ca4970a39b5f Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 21:31:36 -0600 Subject: [PATCH 07/14] Include every Toolkit crate in unit coverage --- ci/coverage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/coverage.sh b/ci/coverage.sh index b78d97fb..d78ff469 100644 --- a/ci/coverage.sh +++ b/ci/coverage.sh @@ -26,10 +26,10 @@ fi cargo llvm-cov clean --workspace -# 1. Unit tests for the GUI and the artifact/flash/CLI crates. +# 1. Unit tests for the GUI and all first-party headless crates. cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" -p alkane-gui --bin alkane-toolkit cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" \ - -p alkane-artifacts -p alkane-flash -p alkane-cli + --workspace --exclude alkane-gui --exclude wx-rs # 2. Headless UI self-test, under the same instrumentation, its coverage appended. xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 \ -- 2.54.0 From 7f07db567f6be30555492c37dd1cebffb2cd0dfb Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 21:50:25 -0600 Subject: [PATCH 08/14] Publish Toolkit benchmarks on Pages runner after main CI --- .gitea/workflows/bench-pages.yml | 3 +++ .gitea/workflows/release.yml | 6 ------ ci/check-runner-image.py | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/bench-pages.yml b/.gitea/workflows/bench-pages.yml index b154c3c2..e4339b83 100644 --- a/.gitea/workflows/bench-pages.yml +++ b/.gitea/workflows/bench-pages.yml @@ -1,6 +1,9 @@ name: public-benchmark-pages on: + workflow_run: + workflows: [build-test-release] + types: [completed] workflow_dispatch: concurrency: diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index d5924c3b..5f0aaed2 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -195,12 +195,6 @@ jobs: with: name: alkane-toolkit-benchmark-site-preview path: bench-site/index.html - - name: Publish public benchmark page - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - BENCH_PAGES_DEPLOY_KEY: ${{ secrets.BENCH_PAGES_DEPLOY_KEY }} - run: python3 ci/publish-bench-pages.py toolkit - - name: Package artifact if: steps.ver.outputs.release == 'true' id: pkg diff --git a/ci/check-runner-image.py b/ci/check-runner-image.py index 6f9d5fd6..af1e9090 100644 --- a/ci/check-runner-image.py +++ b/ci/check-runner-image.py @@ -27,6 +27,22 @@ def main() -> int: if job.get("container", {}).get("image") != IMAGE: print(f"{path.name}: {name} has a different runner image", file=sys.stderr) return 1 + pages = yaml.load( + (ROOT / ".gitea/workflows/bench-pages.yml").read_text(), + Loader=yaml.BaseLoader, + ) + if (pages["on"]["workflow_run"]["workflows"] != ["build-test-release"] + or pages["jobs"]["publish"].get("runs-on") != "alkane-pages"): + print("Benchmark Pages must follow main CI on the Pages runner", file=sys.stderr) + return 1 + release = yaml.load( + (ROOT / ".gitea/workflows/release.yml").read_text(), + Loader=yaml.BaseLoader, + ) + if any("ci/publish-bench-pages.py" in step.get("run", "") + for step in release["jobs"]["release"]["steps"]): + print("Main release must not publish Pages from GARM", file=sys.stderr) + return 1 print("Toolkit runner image pins: PASS") return 0 -- 2.54.0 From 1de566427ade7cba1ff868d1a54248a49e270714 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 21:56:00 -0600 Subject: [PATCH 09/14] Verify wx source provenance before reusing prefix --- .gitea/workflows/next.yml | 7 +------ .gitea/workflows/release.yml | 9 +-------- .gitea/workflows/verify.yml | 9 +-------- ci/ensure-wx-prefix.sh | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 ci/ensure-wx-prefix.sh diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index ac8a7dae..2003f78f 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -38,12 +38,7 @@ jobs: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets - run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ] || - [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then - bash scripts/build-wx-linux.sh - fi - [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build if: steps.wx-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v4 diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 5f0aaed2..f17cafc2 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -66,14 +66,7 @@ jobs: key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets (once, then cached) - run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ] || - [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then - bash scripts/build-wx-linux.sh - else - echo "wx prefix restored from cache" - fi - [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build if: steps.wx-cache.outputs.cache-hit != 'true' diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index b1001067..ea36a7bb 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -68,14 +68,7 @@ jobs: - name: Build wxWidgets (once, then cached) if: steps.surface.outputs.surface == 'full' - run: | - if [ ! -x "$WX_PREFIX/bin/wx-config" ] || - [ ! -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ]; then - bash scripts/build-wx-linux.sh - else - echo "wx prefix restored from cache" - fi - [ -s "$WX_PREFIX/lib/libwx_gtk3u-3.3.a" ] + run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build if: steps.surface.outputs.surface == 'full' && steps.wx-cache.outputs.cache-hit != 'true' diff --git a/ci/ensure-wx-prefix.sh b/ci/ensure-wx-prefix.sh new file mode 100644 index 00000000..62f0fa81 --- /dev/null +++ b/ci/ensure-wx-prefix.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Use the matching image or cache prefix; rebuild after a vendored source bump. +set -euo pipefail + +prefix="${WX_PREFIX:?WX_PREFIX is required}" +expected="$(awk '$1 == "sha256:" {print $2}' thirdparty/wxwidgets/VERSION)" +[[ "$expected" =~ ^[0-9a-f]{64}$ ]] || { + echo 'invalid pinned wxWidgets source digest' >&2 + exit 1 +} +marker="$prefix/.alkane-source-sha256" +if [ -e "$marker" ] && [ "$(cat "$marker")" != "$expected" ]; then + python3 - "$prefix" <<'PY' +from pathlib import Path +import shutil +import sys + +prefix = Path(sys.argv[1]) +allowed = Path('/root/.cache/wx-3.3.3-linux') +if prefix != allowed or prefix.is_symlink(): + raise SystemExit('refusing unsafe wxWidgets prefix reset') +if prefix.is_dir(): + shutil.rmtree(prefix) +PY +fi +if [ ! -x "$prefix/bin/wx-config" ] || + [ ! -s "$prefix/lib/libwx_gtk3u-3.3.a" ]; then + bash scripts/build-wx-linux.sh +else + echo 'wx prefix available from matching image or cache' +fi +[ -s "$prefix/lib/libwx_gtk3u-3.3.a" ] +printf '%s\n' "$expected" > "$marker" -- 2.54.0 From 950f920bb3ce98f551c873a67c2e80916e2c2ef8 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 22:02:48 -0600 Subject: [PATCH 10/14] Reject symlinked wx prefix markers --- ci/ensure-wx-prefix.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/ensure-wx-prefix.sh b/ci/ensure-wx-prefix.sh index 62f0fa81..7b25e9eb 100644 --- a/ci/ensure-wx-prefix.sh +++ b/ci/ensure-wx-prefix.sh @@ -4,6 +4,10 @@ set -euo pipefail prefix="${WX_PREFIX:?WX_PREFIX is required}" +if [ -L "$prefix" ] || [ -L "$prefix/.alkane-source-sha256" ]; then + echo 'refusing symlinked wxWidgets prefix or source marker' >&2 + exit 1 +fi expected="$(awk '$1 == "sha256:" {print $2}' thirdparty/wxwidgets/VERSION)" [[ "$expected" =~ ^[0-9a-f]{64}$ ]] || { echo 'invalid pinned wxWidgets source digest' >&2 -- 2.54.0 From 3c375ede5f86214116f9483662977cfa68a53619 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 22:15:27 -0600 Subject: [PATCH 11/14] Skip wx cache upload when image supplies the library --- .gitea/workflows/next.yml | 3 ++- .gitea/workflows/release.yml | 3 ++- .gitea/workflows/verify.yml | 3 ++- ci/ensure-wx-prefix.sh | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index 2003f78f..3c005692 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -38,9 +38,10 @@ jobs: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets + id: wx-build run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build - if: steps.wx-cache.outputs.cache-hit != 'true' + if: steps.wx-cache.outputs.cache-hit != 'true' && steps.wx-build.outputs.built == 'true' uses: actions/cache/save@v4 continue-on-error: true with: diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index f17cafc2..70461e8c 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -66,10 +66,11 @@ jobs: key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets (once, then cached) + id: wx-build run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build - if: steps.wx-cache.outputs.cache-hit != 'true' + if: steps.wx-cache.outputs.cache-hit != 'true' && steps.wx-build.outputs.built == 'true' uses: actions/cache/save@v4 continue-on-error: true with: diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index ea36a7bb..105095b3 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -68,10 +68,11 @@ jobs: - name: Build wxWidgets (once, then cached) if: steps.surface.outputs.surface == 'full' + id: wx-build run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build - if: steps.surface.outputs.surface == 'full' && steps.wx-cache.outputs.cache-hit != 'true' + if: steps.surface.outputs.surface == 'full' && steps.wx-cache.outputs.cache-hit != 'true' && steps.wx-build.outputs.built == 'true' uses: actions/cache/save@v4 continue-on-error: true with: diff --git a/ci/ensure-wx-prefix.sh b/ci/ensure-wx-prefix.sh index 7b25e9eb..b3a16dd3 100644 --- a/ci/ensure-wx-prefix.sh +++ b/ci/ensure-wx-prefix.sh @@ -28,11 +28,16 @@ if prefix.is_dir(): shutil.rmtree(prefix) PY fi +built=false if [ ! -x "$prefix/bin/wx-config" ] || [ ! -s "$prefix/lib/libwx_gtk3u-3.3.a" ]; then bash scripts/build-wx-linux.sh + built=true else echo 'wx prefix available from matching image or cache' fi [ -s "$prefix/lib/libwx_gtk3u-3.3.a" ] printf '%s\n' "$expected" > "$marker" +if [ -n "${GITHUB_OUTPUT:-}" ]; then + printf 'built=%s\n' "$built" >> "$GITHUB_OUTPUT" +fi -- 2.54.0 From 671b7beff502519e86f192e859f779da3e889ef6 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 22:28:35 -0600 Subject: [PATCH 12/14] Use prebuilt CI tools and skip redundant wx cache transfer --- .gitea/workflows/ci-badge.yml | 2 +- .gitea/workflows/next.yml | 2 +- .gitea/workflows/release.yml | 17 +++++++---------- .gitea/workflows/source.yml | 2 +- .gitea/workflows/verify.yml | 9 +++++++-- ci/check-wx-image-prefix.sh | 16 ++++++++++++++++ ci/runner-image.txt | 2 +- 7 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 ci/check-wx-image-prefix.sh diff --git a/.gitea/workflows/ci-badge.yml b/.gitea/workflows/ci-badge.yml index 85065fa3..6b8bbcac 100644 --- a/.gitea/workflows/ci-badge.yml +++ b/.gitea/workflows/ci-badge.yml @@ -9,7 +9,7 @@ jobs: publish: runs-on: alkane-fast container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 permissions: actions: read contents: write diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index 3c005692..a1cfa898 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -15,7 +15,7 @@ jobs: candidate: runs-on: alkane-ci container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 env: CARGO_TARGET_DIR: target WX_PREFIX: /root/.cache/wx-3.3.3-linux diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 70461e8c..7faa4a7e 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -18,7 +18,7 @@ jobs: release: runs-on: alkane-ci container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 env: CARGO_TARGET_DIR: target WX_PREFIX: /root/.cache/wx-3.3.3-linux @@ -57,7 +57,12 @@ jobs: id: wx-key run: bash ci/wx-cache-key.sh + - name: Check prebuilt wxWidgets + id: wx-image + run: bash ci/check-wx-image-prefix.sh + - name: Cache vendored wxWidgets build + if: steps.wx-image.outputs.available != 'true' id: wx-cache uses: actions/cache/restore@v4 continue-on-error: true @@ -135,15 +140,7 @@ jobs: run: | set -euo pipefail rustup component add llvm-tools-preview >/dev/null 2>&1 || true - if ! command -v cargo-llvm-cov >/dev/null 2>&1; then - V=0.8.7 - URL="https://github.com/taiki-e/cargo-llvm-cov/releases/download/v${V}/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz" - DEST="${CARGO_HOME:-$HOME/.cargo}/bin" - mkdir -p "$DEST" - curl -fsSL "$URL" | tar -xz -C "$DEST" - export PATH="$DEST:$PATH" - fi - command -v cargo-llvm-cov >/dev/null + [ "$(cargo llvm-cov --version)" = 'cargo-llvm-cov 0.8.7' ] PCT=$(bash ci/coverage.sh --summary-only \ | awk '/^TOTAL/{gsub(/%/,"",$10); print $10}') [ -n "$PCT" ] || { echo "coverage report produced no TOTAL line" >&2; exit 1; } diff --git a/.gitea/workflows/source.yml b/.gitea/workflows/source.yml index 6cd3af40..42b8cf07 100644 --- a/.gitea/workflows/source.yml +++ b/.gitea/workflows/source.yml @@ -14,7 +14,7 @@ jobs: check: runs-on: alkane-fast container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 env: CARGO_BUILD_JOBS: 2 steps: diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index 105095b3..e71c46c9 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -13,7 +13,7 @@ jobs: verify: runs-on: alkane-verify container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 env: CARGO_TARGET_DIR: target CARGO_BUILD_JOBS: 2 @@ -57,8 +57,13 @@ jobs: if: steps.surface.outputs.surface == 'full' run: bash ci/wx-cache-key.sh - - name: Cache vendored wxWidgets build + - name: Check prebuilt wxWidgets + id: wx-image if: steps.surface.outputs.surface == 'full' + run: bash ci/check-wx-image-prefix.sh + + - name: Cache vendored wxWidgets build + if: steps.surface.outputs.surface == 'full' && steps.wx-image.outputs.available != 'true' id: wx-cache uses: actions/cache/restore@v4 continue-on-error: true diff --git a/ci/check-wx-image-prefix.sh b/ci/check-wx-image-prefix.sh new file mode 100644 index 00000000..30f311b3 --- /dev/null +++ b/ci/check-wx-image-prefix.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Avoid a runner-local cache download when the pinned image has this source. +set -euo pipefail + +prefix="${WX_PREFIX:?WX_PREFIX is required}" +expected="$(awk '$1 == "sha256:" {print $2}' thirdparty/wxwidgets/VERSION)" +[[ "$expected" =~ ^[0-9a-f]{64}$ ]] +available=false +if [ ! -L "$prefix" ] && [ ! -L "$prefix/.alkane-source-sha256" ] && + [ -x "$prefix/bin/wx-config" ] && + [ -s "$prefix/lib/libwx_gtk3u-3.3.a" ] && + [ "$(cat "$prefix/.alkane-source-sha256" 2>/dev/null || true)" = "$expected" ]; then + available=true +fi +printf 'available=%s\n' "$available" >> "${GITHUB_OUTPUT:?GITHUB_OUTPUT is required}" diff --git a/ci/runner-image.txt b/ci/runner-image.txt index 21db8c24..6781c89d 100644 --- a/ci/runner-image.txt +++ b/ci/runner-image.txt @@ -1 +1 @@ -gitea.bluefla.re/blueflare/alkane-ci@sha256:43bd4048ac01dff914ffb02ce5f2a07be37b5b0512ada66423247aebc74f0732 +gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 -- 2.54.0 From 87ba049fc6397dd6e76c1ed37a03ead9f82942c2 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 22:35:04 -0600 Subject: [PATCH 13/14] Avoid duplicate source job for Toolkit main PRs --- .gitea/workflows/source.yml | 3 +-- ci/check-runner-image.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/source.yml b/.gitea/workflows/source.yml index 42b8cf07..e934fbe6 100644 --- a/.gitea/workflows/source.yml +++ b/.gitea/workflows/source.yml @@ -3,8 +3,7 @@ name: source on: pull_request: branches: [next] - push: - branches-ignore: [main, next] + workflow_dispatch: concurrency: group: alkane-toolkit-source-${{ github.ref }} diff --git a/ci/check-runner-image.py b/ci/check-runner-image.py index af1e9090..94995e91 100644 --- a/ci/check-runner-image.py +++ b/ci/check-runner-image.py @@ -43,6 +43,16 @@ def main() -> int: for step in release["jobs"]["release"]["steps"]): print("Main release must not publish Pages from GARM", file=sys.stderr) return 1 + source = yaml.load( + (ROOT / ".gitea/workflows/source.yml").read_text(), + Loader=yaml.BaseLoader, + ) + triggers = source["on"] + if (triggers.get("pull_request", {}).get("branches") != ["next"] + or "push" in triggers or "workflow_dispatch" not in triggers): + print("Source checks must not duplicate main pull request verification", + file=sys.stderr) + return 1 print("Toolkit runner image pins: PASS") return 0 -- 2.54.0 From cd8d40b50d92d9700506b5ec74f8c244a39e9c29 Mon Sep 17 00:00:00 2001 From: noah Date: Sun, 18 Oct 2026 22:54:48 -0600 Subject: [PATCH 14/14] Pilot bounded Rust compiler cache in Toolkit verification --- .gitea/workflows/ci-badge.yml | 2 +- .gitea/workflows/next.yml | 2 +- .gitea/workflows/release.yml | 2 +- .gitea/workflows/source.yml | 2 +- .gitea/workflows/verify.yml | 12 +++++++++++- ci/configure-rust-cache.sh | 37 +++++++++++++++++++++++++++++++++++ ci/runner-image.txt | 2 +- 7 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 ci/configure-rust-cache.sh diff --git a/.gitea/workflows/ci-badge.yml b/.gitea/workflows/ci-badge.yml index 6b8bbcac..46f65508 100644 --- a/.gitea/workflows/ci-badge.yml +++ b/.gitea/workflows/ci-badge.yml @@ -9,7 +9,7 @@ jobs: publish: runs-on: alkane-fast container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 permissions: actions: read contents: write diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index a1cfa898..e248c869 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -15,7 +15,7 @@ jobs: candidate: runs-on: alkane-ci container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 env: CARGO_TARGET_DIR: target WX_PREFIX: /root/.cache/wx-3.3.3-linux diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 7faa4a7e..c6a9a451 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -18,7 +18,7 @@ jobs: release: runs-on: alkane-ci container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 env: CARGO_TARGET_DIR: target WX_PREFIX: /root/.cache/wx-3.3.3-linux diff --git a/.gitea/workflows/source.yml b/.gitea/workflows/source.yml index e934fbe6..cec6e529 100644 --- a/.gitea/workflows/source.yml +++ b/.gitea/workflows/source.yml @@ -13,7 +13,7 @@ jobs: check: runs-on: alkane-fast container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 env: CARGO_BUILD_JOBS: 2 steps: diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml index e71c46c9..2686bff0 100644 --- a/.gitea/workflows/verify.yml +++ b/.gitea/workflows/verify.yml @@ -13,7 +13,7 @@ jobs: verify: runs-on: alkane-verify container: - image: gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 + image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 env: CARGO_TARGET_DIR: target CARGO_BUILD_JOBS: 2 @@ -52,6 +52,10 @@ jobs: if: steps.surface.outputs.surface != 'documentation' run: bash ci/ensure-build-deps.sh base + - name: Configure bounded Rust compiler cache + if: steps.surface.outputs.surface != 'documentation' + run: bash ci/configure-rust-cache.sh + - name: Compute wxWidgets cache key id: wx-key if: steps.surface.outputs.surface == 'full' @@ -142,6 +146,12 @@ jobs: else echo "cargo-audit not installed on this runner; skipping" fi + - name: Rust compiler cache statistics + if: always() && steps.surface.outputs.surface != 'documentation' + run: | + if [ -n "${SCCACHE_DIR:-}" ]; then + sccache --show-stats + fi - name: Clean generated Toolkit build if: always() run: python3 ci/cleanup-generated.py diff --git a/ci/configure-rust-cache.sh b/ci/configure-rust-cache.sh new file mode 100644 index 00000000..67747872 --- /dev/null +++ b/ci/configure-rust-cache.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Reuse Rust compiler results on the dedicated verification runner. +set -euo pipefail + +[ "$(sccache --version)" = 'sccache 0.18.0' ] || { + echo 'CI image has an unexpected sccache version' >&2 + exit 1 +} + +toolcache="${RUNNER_TOOL_CACHE:-}" +if [ -z "$toolcache" ] || [ -L "$toolcache" ] || + [ ! -d "$toolcache" ] || [ ! -w "$toolcache" ]; then + echo 'Persistent runner tool cache is unavailable; compiling without sccache' + exit 0 +fi + +cache_dir="$toolcache/alkane-toolkit-rust-sccache" +if [ -L "$cache_dir" ]; then + echo 'Rust cache path is a symlink' >&2 + exit 1 +fi +umask 077 +mkdir -p "$cache_dir" +if [ ! -d "$cache_dir" ] || [ ! -w "$cache_dir" ]; then + echo 'Rust cache directory is unavailable' >&2 + exit 1 +fi +chmod 0700 "$cache_dir" + +{ + printf 'RUSTC_WRAPPER=%s\n' "$(command -v sccache)" + printf 'SCCACHE_DIR=%s\n' "$cache_dir" + printf 'SCCACHE_CACHE_SIZE=2G\n' + printf 'CARGO_INCREMENTAL=0\n' +} >> "${GITHUB_ENV:?GITHUB_ENV is required}" +echo 'Bounded Rust compiler cache configured for Alkane Toolkit' diff --git a/ci/runner-image.txt b/ci/runner-image.txt index 6781c89d..4436eea6 100644 --- a/ci/runner-image.txt +++ b/ci/runner-image.txt @@ -1 +1 @@ -gitea.bluefla.re/blueflare/alkane-ci@sha256:ad56db2fc456a3f1c68c715ba44309751cb5c455376d9f797ac346833c011e15 +gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 -- 2.54.0