Skip to content

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

ci: stop superseded and bot-triggered runs from piling up in the queue

velixio384f0d09df1a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6bc3121e4..6c52d55d2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,6 +13,13 @@ on:
permissions:
contents: read
+# A new push to a PR cancels that PR's older run (a mass rebase of ~65 branches
+# once queued 360 runs, most of them for commits already replaced). Pushes to main
+# and manual runs are keyed by commit, so every main commit still gets its own CI.
+concurrency:
+ group: ci-${{ github.event.pull_request.number || github.sha }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
env:
# Run all JavaScript actions on Node 24 (GH deprecates Node 20 in Sep 2026).
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 99e908eee..5569a161f 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -69,6 +69,13 @@ permissions:
contents: read
packages: write
+# Only the newest main push needs to build the rolling :latest/:main images, so a
+# newer push cancels an older one. Releases and manual backfills never cancel
+# anything: each gets its own group.
+concurrency:
+ group: docker-${{ github.event_name == 'push' && 'main-push' || github.run_id }}
+ cancel-in-progress: ${{ github.event_name == 'push' }}
+
env:
REGISTRY: ghcr.io
# Keep registry coordinates explicit. VoiceStudio is the canonical GHCR
diff --git a/.github/workflows/scam-guard.yml b/.github/workflows/scam-guard.yml
index 50229a3b5..801af67ff 100644
--- a/.github/workflows/scam-guard.yml
+++ b/.github/workflows/scam-guard.yml
@@ -27,6 +27,10 @@ permissions:
jobs:
guard:
name: Scam guard
+ # Review bots comment on every PR event and each comment used to take a runner
+ # (171 queued at once). Bots cannot be the scammers this guards against; every
+ # human author, including repository members, is still checked.
+ if: ${{ github.event.sender.type != 'Bot' }}
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
diff --git a/tests/test_ci_queue_hygiene.py b/tests/test_ci_queue_hygiene.py
new file mode 100644
index 000000000..96ad87307
--- /dev/null
+++ b/tests/test_ci_queue_hygiene.py
@@ -0,0 +1,43 @@
+"""CI must not pile up runs: superseded PR runs cancel, and bots never take a runner.
+
+A contributor force-pushed ~65 PR branches at once (04:20 UTC) and 362 runs queued:
+one CI run per push, plus a scam-guard run per review-bot comment.
+"""
+from __future__ import annotations
+
+from pathlib import Path
+
+import yaml
+
+ROOT = Path(__file__).resolve().parents[1]
+
+
+def _load(name: str) -> dict:
+ return yaml.safe_load((ROOT / ".github/workflows" / name).read_text(encoding="utf-8"))
+
+
+def test_ci_cancels_superseded_pr_runs_but_never_main_commits():
+ concurrency = _load("ci.yml")["concurrency"]
+ assert "pull_request.number" in concurrency["group"]
+ assert concurrency["group"].endswith("github.sha }}"), "main pushes are keyed by commit"
+ assert concurrency["cancel-in-progress"] == "${{ github.event_name == 'pull_request' }}"
+
+
+def test_docker_cancels_only_older_main_pushes_never_releases_or_backfills():
+ concurrency = _load("docker.yml")["concurrency"]
+ assert "run_id" in concurrency["group"], "release/dispatch runs must get their own group"
+ assert "event_name == 'push'" in concurrency["cancel-in-progress"]
+
+
+def test_scam_guard_skips_bots_but_still_checks_every_human():
+ job = _load("scam-guard.yml")["jobs"]["guard"]
+ condition = job["if"]
+ assert "sender.type != 'Bot'" in condition
+ for human_roles in ("OWNER", "MEMBER", "COLLABORATOR", "author_association"):
+ assert human_roles not in condition, "members and collaborators stay checked"
+ assert set(_load("scam-guard.yml")[True]) == {"issues", "issue_comment"}
+
+
+def test_other_pr_workflows_already_cancel_superseded_runs():
+ for name in ("security.yml", "commit-identity.yml", "mobile.yml"):
+ assert _load(name)["concurrency"]["cancel-in-progress"], name