Add branch existence check for generated-diagrams (EDUENG-614)#23137
Add branch existence check for generated-diagrams (EDUENG-614)#23137ebembi-crdb wants to merge 2 commits intomainfrom
Conversation
Adds a script and daily workflow that verify every crdb_branch_name entry in versions.csv exists as a branch in cockroachdb/generated-diagrams, and flags entries where a proper release-X.Y branch now exists but versions.csv still points to an older one (e.g. v26.2 -> release-26.1 after release-26.2 is created). Files added: - .github/scripts/validate_branch_existence.py - .github/workflows/validate-branch-existence.yml
Files changed:
|
✅ Deploy Preview for cockroachdb-interactivetutorials-docs canceled.
|
✅ Deploy Preview for cockroachdb-api-docs canceled.
|
✅ Deploy Preview for cockroachdb-docs canceled.
|
| @@ -0,0 +1,189 @@ | |||
| #!/usr/bin/env python3 | |||
| """ | |||
There was a problem hiding this comment.
Did we check the teamcity job ? How it's gonna affect if we have both the flows? As that teamcity job is still active?
There was a problem hiding this comment.
Checked it — no conflict. The TC job is a write path: it generates diagrams via Bazel and force-pushes them to generated-diagrams. This check is read-only; it just asks the API whether a branch exists. They're actually complementary — TC creates branches, this validates that versions.csv stays in sync with what TC has already pushed.
|
|
||
| def branch_exists(branch: str) -> bool: | ||
| if branch not in _cache: | ||
| result = _api_get(f"repos/{GENERATED_DIAGRAMS_REPO}/branches/{branch}") |
There was a problem hiding this comment.
The code calls the API path /repos/{repo}/branches/{branch} with branch interpolated directly. If a branch name ever contains characters that require URL-encoding it would be safer to encode the branch name
| # --------------------------------------------------------------------------- | ||
| # Output | ||
| # --------------------------------------------------------------------------- | ||
|
|
There was a problem hiding this comment.
The PR includes a manual test plan — consider adding a lightweight unit test (or an integration mode that runs against a small sample versions.csv) to make local iteration faster.
…xists_fn
- URL-encode branch name with urllib.parse.quote before interpolating
into the /repos/.../branches/{branch} API path
- Make run_checks accept an optional _exists_fn parameter so the core
logic can be tested without network access
- Add _run_self_tests() covering branch_missing, all-OK, branch_mismatch,
N/A skip, and empty-field skip; invoke with --self-test flag
Summary
Adds a script and daily GitHub Actions workflow to verify that every
crdb_branch_nameentry inversions.csvexists as a branch incockroachdb/generated-diagrams.Two failure modes caught:
branch_missing: the listed branch does not exist ingenerated-diagramsat allbranch_mismatch: a properrelease-X.Ybranch now exists ingenerated-diagramsbutversions.csvstill points to an older one (e.g.v26.2→release-26.1afterrelease-26.2is created)Files added:
.github/scripts/validate_branch_existence.py— stdlib-only Python script, no pip installs required.github/workflows/validate-branch-existence.yml— triggers onversions.csvchanges in PRs and runs daily at 07:00 UTCOn PR failure: posts/updates a bot comment with details and blocks merge.
On scheduled failure: opens a GitHub issue (or updates an existing open one) with label
sql-diagram-validation.Context
Addresses EDUENG-614, part of the follow-up to the production build outage on 2026-01-29 discussed in #docs-site-status.
The anchor integrity check (EDUENG-613) is in a separate PR.
Test plan
python .github/scripts/validate_branch_existence.pyfrom repo root and confirm it exits 0versions.csvchange in a test PR