diff --git a/.gitea/workflows/bench-pages.yml b/.gitea/workflows/bench-pages.yml index f68fefa..7fb608e 100644 --- a/.gitea/workflows/bench-pages.yml +++ b/.gitea/workflows/bench-pages.yml @@ -1,8 +1,9 @@ name: public-benchmark-pages on: - schedule: - - cron: '*/15 * * * *' + workflow_run: + workflows: [main-release-gate] + types: [completed] workflow_dispatch: concurrency: diff --git a/.gitea/workflows/ci-badge.yml b/.gitea/workflows/ci-badge.yml index d8680fb..497da04 100644 --- a/.gitea/workflows/ci-badge.yml +++ b/.gitea/workflows/ci-badge.yml @@ -1,8 +1,9 @@ name: completed-ci-badge on: - schedule: - - cron: '*/15 * * * *' + workflow_run: + workflows: [main-release-gate, next-build] + types: [completed] workflow_dispatch: concurrency: @@ -11,7 +12,7 @@ concurrency: jobs: publish: - runs-on: alkane-ci + runs-on: alkane-fast permissions: actions: read contents: write diff --git a/.gitea/workflows/fast-pr.yml b/.gitea/workflows/fast-pr.yml new file mode 100644 index 0000000..ed5c9af --- /dev/null +++ b/.gitea/workflows/fast-pr.yml @@ -0,0 +1,27 @@ +name: source-pr + +on: + pull_request: + branches: [main, next] + workflow_dispatch: + +concurrency: + group: alkane-os-source-pr-${{ github.ref }} + cancel-in-progress: true + +jobs: + source: + runs-on: alkane-fast + env: + CARGO_TARGET_DIR: target + CARGO_BUILD_JOBS: 2 + steps: + - uses: actions/checkout@v4 + - name: Check source + run: | + rustup component add rustfmt + cargo fmt --check + cargo test --locked + - name: Clean generated source check + if: always() + run: python3 ci/cleanup-generated.py diff --git a/.gitea/workflows/next.yml b/.gitea/workflows/next.yml index 1309859..1b7b789 100644 --- a/.gitea/workflows/next.yml +++ b/.gitea/workflows/next.yml @@ -10,9 +10,10 @@ concurrency: jobs: build: - runs-on: alkane-ci + runs-on: alkane-fast env: CARGO_TARGET_DIR: target + CARGO_BUILD_JOBS: 2 steps: - uses: actions/checkout@v4 with: diff --git a/ci/last-attempt-badge.py b/ci/last-attempt-badge.py index 118d610..94b2e5b 100644 --- a/ci/last-attempt-badge.py +++ b/ci/last-attempt-badge.py @@ -55,8 +55,8 @@ def publish(api: str, repo: str, branch: str, data: bytes, token: str) -> None: def main() -> None: - if os.environ["GITHUB_EVENT_NAME"] not in ("schedule", "workflow_dispatch"): - raise RuntimeError("badge publisher must run on a timer or manual dispatch") + if os.environ["GITHUB_EVENT_NAME"] not in ("workflow_run", "workflow_dispatch"): + raise RuntimeError("badge publisher must follow CI completion or manual dispatch") if os.environ["GITHUB_REF"] != "refs/heads/main": raise RuntimeError("badge publisher must use the main branch") repo = os.environ["GITHUB_REPOSITORY"] diff --git a/ci/test-last-attempt-badge.py b/ci/test-last-attempt-badge.py index c051984..120be81 100644 --- a/ci/test-last-attempt-badge.py +++ b/ci/test-last-attempt-badge.py @@ -36,7 +36,7 @@ assert b">fail" in svg assert b"#d1242f" in svg assert b">pass" in module.badge("next", "success", 108) environment = { - "GITHUB_EVENT_NAME": "schedule", + "GITHUB_EVENT_NAME": "workflow_run", "GITHUB_REF": "refs/heads/main", "GITHUB_REPOSITORY": "owner/repo", "GITHUB_API_URL": "https://example.invalid/api/v1", @@ -49,13 +49,19 @@ with patch.dict(os.environ, environment), \ module.main() assert latest.call_count == 2 assert [call.args[2] for call in published.call_args_list] == ["main", "next"] -with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "workflow_run"}): +with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "workflow_dispatch"}), \ + patch.object(module, "latest_completed", side_effect=[(201, "success"), + (202, "failure")]), \ + patch.object(module, "publish") as published: + module.main() + assert published.call_count == 2 +with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "schedule"}): try: module.main() except RuntimeError as error: - assert "timer or manual dispatch" in str(error) + assert "CI completion or manual dispatch" in str(error) else: - raise AssertionError("workflow_run event entered badge publisher") + raise AssertionError("scheduled event entered badge publisher") for invalid in ("", "/main.svg", "../main.svg", "badges//main.svg"): try: publish_file("https://example.invalid/api/v1", "owner/repo", invalid,