Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

ci: give each push to main its own concurrency group

Nithilan Kumaran87cd69bcb8bf
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7a9cca5f..0026c5d1 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -9,10 +9,9 @@ permissions:
contents: read
concurrency:
- group: ci-${{ github.ref }}
- # Cancel outdated pull request runs. On main, let a started run finish: merges land minutes
- # apart, and cancelling there left whole bursts of merges without a result of their own. A
- # newer push still replaces a run that is queued and has not started.
+ group: ci-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
+ # Cancel outdated pull request runs. On main, use a per-commit group so each push
+ # gets its own run and started runs finish without cancelling or being cancelled by adjacent merges.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 419757d2..73db252b 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -5,9 +5,9 @@ on:
push:
branches: [main]
-# Cancel outdated pull request runs; let runs on main finish.
+# Cancel outdated pull request runs; on main, run per commit.
concurrency:
- group: docker-${{ github.ref }}
+ group: docker-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml
index a0d111b2..7dd34698 100644
--- a/.github/workflows/security.yml
+++ b/.github/workflows/security.yml
@@ -7,9 +7,9 @@ on:
schedule:
- cron: "17 6 * * 1" # Monday morning: catch CVEs disclosed since the last push
-# Cancel outdated pull request runs; let runs on main finish.
+# Cancel outdated pull request runs; on main, run per commit.
concurrency:
- group: security-${{ github.ref }}
+ group: security-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# Read-only by default. Jobs that need more ask for it explicitly.
diff --git a/tests/test_packaging.py b/tests/test_packaging.py
index 66971a35..fdf307ef 100644
--- a/tests/test_packaging.py
+++ b/tests/test_packaging.py
@@ -230,6 +230,45 @@ for _dirpath, _dirnames, _filenames in os.walk("."):
check("extras/every referenced extra is declared",
sorted(set(_referenced_extras) - _declared_extras), [])
+# ------------------------------------------------------- push concurrency (#399)
+# github.ref is refs/heads/main for every push, so a group of <workflow>-${{ github.ref }}
+# is one group for the whole branch. Rapid merges then cancel each other. Pull requests
+# stay on github.ref (a new commit still cancels the obsolete run); pushes use github.sha.
+# docs.yml has a concurrency group and is included once that group uses this expression.
+# It still deploys GitHub Pages on github.ref so an older build cannot publish over a
+# newer one (#493 left that group ref-scoped on purpose).
+_PER_COMMIT = "github.event_name == 'pull_request' && github.ref || github.sha"
+_BARE_REF_GROUP = re.compile(
+ r"(?m)^[ \t]*group:\s+\S+-\$\{\{\s*github\.ref\s*\}\}(?:\s+#.*)?\s*$"
+)
+
+
+def _concurrency_block(text):
+ match = re.search(r"(?m)^concurrency:\n(?:[ \t]+[^\n]*\n)*", text)
+ return match.group(0) if match else ""
+
+
+_concurrency_workflows = ["ci.yml", "docker.yml", "security.yml"]
+_docs_workflow = read(os.path.join(".github", "workflows", "docs.yml"))
+_docs_concurrency = _concurrency_block(_docs_workflow)
+if _docs_concurrency and _PER_COMMIT in _docs_concurrency:
+ _concurrency_workflows.append("docs.yml")
+
+for _wf in _concurrency_workflows:
+ _text = _docs_workflow if _wf == "docs.yml" else read(os.path.join(".github", "workflows", _wf))
+ _block = _docs_concurrency if _wf == "docs.yml" else _concurrency_block(_text)
+ _stem = _wf[:-4]
+ check_true(
+ "%s/per-commit concurrency for pushes to main" % _wf,
+ ("group: %s-${{ %s }}" % (_stem, _PER_COMMIT)) in _block,
+ "want group: %s-${{ %s }}" % (_stem, _PER_COMMIT),
+ )
+ check_true(
+ "%s/concurrency group is not github.ref alone" % _wf,
+ _block != "" and _BARE_REF_GROUP.search(_block) is None,
+ "a ref-only group collapses every push to main into one run",
+ )
+
print("\n%d passed, %d failed" % (len(PASS), len(FAIL)))
for f in FAIL:
print(" FAIL", f)