Skip to content

Commit 55bc142

Browse files
authored
[hud] Match sole viable/strict blockers on full workflow name (#8577)
The sole-blocker query prefix-matched gating workflows, so unrelated workflows that merely share a prefix (sandbox/experiment workflows, linters) counted as viable/strict blockers. #8438 made the gate itself re.fullmatch; mirror that here so /reliability agrees with the gate (and with #8439 on the HUD grid).
1 parent 4d22a9a commit 55bc142

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

torchci/clickhouse_queries/viable_strict_sole_blocker/query.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
-- Approximates the viable/strict gate for FAILURE ATTRIBUTION -- it is not a
55
-- full reimplementation. It uses the same job-level red definition as
66
-- pytorch/.github/scripts/fetch_latest_green_commit.py (via commit_jobs_batch_query):
7-
-- * gating workflows are prefix-matched against ^(pull|trunk|lint|docs-build)
7+
-- * gating workflows are matched in FULL against ^(pull|trunk|lint|docs-build)$
88
-- (case-insensitive), same as the `requires` list in update-viablestrict.yml
9+
-- and the gate's re.fullmatch
910
-- * a job blocks if its latest run attempt (per workflow run) has a
1011
-- conclusion_kg other than success/skipped
1112
-- * jobs marked unstable (name contains "unstable", or the shard-folded name
@@ -84,10 +85,14 @@ raw_jobs AS (
8485
SELECT id FROM materialized_views.workflow_run_by_head_sha
8586
WHERE head_sha IN (SELECT sha FROM commits)
8687
)
87-
-- Gating workflow prefixes; keep in sync with the `requires` list in
88+
-- Gating workflows; keep in sync with the `requires` list in
8889
-- pytorch/pytorch .github/workflows/update-viablestrict.yml
8990
-- (["pull", "trunk", "lint", "docs-build"] as of 2026-07-27).
90-
AND match(lower(j.workflow_name), '^(pull|trunk|lint|docs-build)')
91+
-- Anchored at both ends to mirror the gate's re.fullmatch (test-infra
92+
-- #8438): a prefix match would also pull in unrelated workflows that
93+
-- merely share the prefix -- e.g. a `trunk-ci-sandbox` experiment or a
94+
-- `Linter` -- and make them look like viable/strict blockers.
95+
AND match(lower(j.workflow_name), '^(pull|trunk|lint|docs-build)$')
9196
-- Match the gate's job-level filtering (commit_jobs_batch_query), which
9297
-- only drops ciflow_should_run and generate-test-matrix. We additionally
9398
-- drop unstable and rerun_disabled_tests jobs: the gate ignores unstable

torchci/test/viableStrictSoleBlocker.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,36 @@ describe("viable/strict sole blocker query.sql stays in sync with the fold + fil
8888
expect(sql).not.toContain("splitByString(' / ', j.name), 2)");
8989
});
9090

91+
test("matches gating workflows in full, mirroring the gate's re.fullmatch", () => {
92+
// Anchored at both ends (test-infra #8438). A bare prefix would also match
93+
// sandbox/experiment workflows and linters that share the prefix but do
94+
// not gate. Assert the whole predicate, not just the pattern: the pattern
95+
// is all-lowercase only because lower() runs first, so dropping lower() as
96+
// redundant-looking would silently un-gate the "Lint" workflow.
97+
expect(sql).toContain(
98+
"match(lower(j.workflow_name), '^(pull|trunk|lint|docs-build)$')"
99+
);
100+
101+
// Mirrors match(lower(j.workflow_name), ...): case-fold, then full-match.
102+
const gates = (workflowName: string) =>
103+
/^(pull|trunk|lint|docs-build)$/.test(workflowName.toLowerCase());
104+
105+
// Workflow names as they are actually spelled on main -- note "Lint",
106+
// which a case-sensitive mirror would wrongly reject.
107+
for (const wf of ["pull", "trunk", "Lint", "docs-build"]) {
108+
expect(gates(wf)).toBe(true);
109+
}
110+
for (const wf of [
111+
"trunk-ci-sandbox",
112+
"trunk-tagging",
113+
"pull-test-sandbox",
114+
"Linter",
115+
"Lintrunner",
116+
]) {
117+
expect(gates(wf)).toBe(false);
118+
}
119+
});
120+
91121
test("keeps the gate's job filters + the fold-collision filters, drops the over-filters", () => {
92122
// gate parity
93123
expect(sql).toContain("j.name != 'ciflow_should_run'");

0 commit comments

Comments
 (0)