From 83501016d8b3bfbadf8917f2ccbb9e9d9af25c48 Mon Sep 17 00:00:00 2001 From: noah Date: Sat, 17 Oct 2026 01:21:21 -0600 Subject: [PATCH] Publish Toolkit benchmarks on the standing Alkane runner --- .gitea/workflows/bench-pages.yml | 34 ++++++++++++++++++++++++++++++++ .gitea/workflows/release.yml | 8 +------- ci/bench_history.py | 9 ++++++++- ci/cleanup-generated.py | 2 +- ci/publish-bench-pages.py | 6 +++--- 5 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 .gitea/workflows/bench-pages.yml diff --git a/.gitea/workflows/bench-pages.yml b/.gitea/workflows/bench-pages.yml new file mode 100644 index 00000000..3523f64d --- /dev/null +++ b/.gitea/workflows/bench-pages.yml @@ -0,0 +1,34 @@ +name: public-benchmark-pages + +on: + schedule: + - cron: '*/15 * * * *' + workflow_dispatch: + +concurrency: + group: alkane-toolkit-public-benchmark-pages + cancel-in-progress: false + +jobs: + publish: + runs-on: alkane-pages + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - name: Install SSH client + run: | + apt-get update -qq + apt-get install -y -qq --no-install-recommends openssh-client + - name: Render measured benchmark history + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: python3 ci/bench_history.py render + - 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: Clean generated page + if: always() + run: python3 ci/cleanup-generated.py diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 0ef06c4f..3991d695 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -49,7 +49,7 @@ jobs: run: | apt-get update -qq apt-get install -y -qq --no-install-recommends \ - libssl-dev pkg-config ca-certificates openssh-client >/dev/null + libssl-dev pkg-config ca-certificates >/dev/null echo "libssl-dev + pkg-config installed (openssl-sys needs them)" - name: Cache vendored wxWidgets build @@ -112,12 +112,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: Headless UI self-test run: | apt-get update -qq && apt-get install -y -qq --no-install-recommends \ diff --git a/ci/bench_history.py b/ci/bench_history.py index 85ba6af4..0f4a93b6 100644 --- a/ci/bench_history.py +++ b/ci/bench_history.py @@ -126,7 +126,7 @@ def render_html(index: dict) -> str: def main() -> None: parser = argparse.ArgumentParser() - parser.add_argument("action", choices=("prepare", "publish")) + parser.add_argument("action", choices=("prepare", "publish", "render")) args = parser.parse_args() api = os.environ["GITHUB_API_URL"].rstrip("/") repo = os.environ["GITHUB_REPOSITORY"] @@ -141,6 +141,13 @@ def main() -> None: Path("badges/bench-baseline.json").write_text(json.dumps(baseline) + "\n") print(f"Loaded {len(baseline)} prior benchmark measurements") return + if args.action == "render": + if not index["entries"]: + raise ValueError("no measured benchmark history to publish") + Path("bench-site").mkdir(exist_ok=True) + Path("bench-site/index.html").write_text(render_html(index)) + print(f"Rendered {len(index['entries'])} measured benchmark commits") + return metrics = {"bench_ns_per_op": bench_badge.require_suite(bench_badge.parse_bench( Path("bench-current.txt").read_text())), "bench_host": benchmark_host()} timestamp = datetime.now(timezone.utc).isoformat(timespec="seconds") diff --git a/ci/cleanup-generated.py b/ci/cleanup-generated.py index fa398729..1bb5e212 100644 --- a/ci/cleanup-generated.py +++ b/ci/cleanup-generated.py @@ -9,7 +9,7 @@ import sys ROOT = Path(__file__).resolve().parents[1] -DIRECTORIES = ("target", "dist", "coverage") +DIRECTORIES = ("target", "dist", "coverage", "bench-site") FILES = ("bench-current.txt",) diff --git a/ci/publish-bench-pages.py b/ci/publish-bench-pages.py index 5e3e9303..5adff3bd 100644 --- a/ci/publish-bench-pages.py +++ b/ci/publish-bench-pages.py @@ -16,6 +16,7 @@ GUARD_REPO = "https://gitea.bluefla.re/blueflare/alkane-benchmarks.git" GUARD_COMMIT = "ea160545c49bc419a245692deda8dd7db7a611eb" PAGES_HOST = "gitea.bluefla.re" PAGES_HOST_FINGERPRINT = "SHA256:lqB5cmC9E5HNeg/lkzdOwQ++I8A70Wx7lnNs6liN24g" +PAGES_HOST_KEY = "[gitea.bluefla.re]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO1II6NkmRW+QAd+Wj+7qbNrA8Oo+/N/WRog4hELskn/" def run(*args: str, env: dict[str, str] | None = None, @@ -62,16 +63,15 @@ def publish(site: str) -> None: key_path = temporary / "deploy_key" key_path.write_text(key.rstrip("\n") + "\n") key_path.chmod(0o600) - scanned = run("ssh-keyscan", "-p", "2222", "-t", "ed25519", PAGES_HOST) known_hosts = temporary / "known_hosts" - known_hosts.write_text(scanned.stdout) + known_hosts.write_text(PAGES_HOST_KEY + "\n") fingerprint = run("ssh-keygen", "-lf", str(known_hosts)).stdout.split()[1] if fingerprint != PAGES_HOST_FINGERPRINT: raise ValueError("benchmark Pages SSH host key changed") git_env = os.environ.copy() ssh_command = (f"ssh -i {shlex.quote(str(key_path))} -o IdentitiesOnly=yes " f"-o UserKnownHostsFile={shlex.quote(str(known_hosts))} " - "-o StrictHostKeyChecking=yes") + "-o StrictHostKeyChecking=yes -o ConnectTimeout=10") git_env["GIT_SSH_COMMAND"] = ssh_command git_env["GIT_TERMINAL_PROMPT"] = "0" checkout = temporary / "site"