Skip to content

Rewrite dependency version check as Go tool, extend to main branch#9816

Open
chaptersix wants to merge 8 commits intomainfrom
validate-api-version
Open

Rewrite dependency version check as Go tool, extend to main branch#9816
chaptersix wants to merge 8 commits intomainfrom
validate-api-version

Conversation

@chaptersix
Copy link
Copy Markdown
Contributor

@chaptersix chaptersix commented Apr 3, 2026

Rewrites the release dependency check as a Go tool and extends it to cover the main branch.

The original check was a shell script using grep/awk to extract versions from go.mod. Moving to Go lets us use golang.org/x/mod/modfile (proper AST parsing), module.IsPseudoVersion/PseudoVersionRev (pseudo-version decomposition), and semver.IsValid — none of which are feasible to replicate reliably in shell. Using a Go tool is also consistent with the pattern in cmd/tools/.

The rewrite also extends validation: the original script only enforced tagged releases on release/* and cloud/* branches. The new tool adds a main branch policy: pseudo-versions are allowed on main, but the referenced commit must be on the dependency's default branch (not a feature branch or a fork).

Policies enforced

  • release/* and cloud/*: must be tagged semver releases
  • main: tagged releases accepted; pseudo-versions must reference a commit on the dependency's default branch
  • other branches: skipped

Why

If an API or SDK references a commit that's not on the main branch or a tag, it creates problems when bumping the version later on. There was a recent occurrence of this.

Running locally

go run ./cmd/tools/check-dependencies --base-branch main

Pass the branch you're targeting as --base-branch. For example, to simulate a PR against a release branch:

go run ./cmd/tools/check-dependencies --base-branch release/v1.31

Comment thread cmd/tools/validate-api-go-version/main.go Outdated
@chaptersix chaptersix force-pushed the validate-api-version branch 4 times, most recently from 8859280 to 56fdf07 Compare April 3, 2026 19:23
Replace the inline bash script in check-release-dependencies.yml with a
Go tool that validates go.mod dependency versions using go tooling and
git directly, removing the need for GitHub API calls.

Release/cloud branches require stable semver tags (vX.Y.Z) verified via
go list. Main branch allows tagged releases or pseudo-versions, with
pseudo-version branch validation using go mod download (GOPROXY=direct)
and git ls-remote to confirm the commit is on the module's default branch.
@chaptersix chaptersix force-pushed the validate-api-version branch from 1558a44 to fdafcf2 Compare April 3, 2026 20:51
@chaptersix chaptersix marked this pull request as ready for review April 3, 2026 20:51
@chaptersix chaptersix requested review from a team as code owners April 3, 2026 20:51
@chaptersix chaptersix marked this pull request as draft April 3, 2026 22:03
@chaptersix chaptersix force-pushed the validate-api-version branch from fd8d10d to e1cb26d Compare April 3, 2026 22:08
- Rename validate-api-go-version to check-dependencies
- Remove verifyVersion and go list subprocess call
- Remove redundant cat-file pre-check and dead code
- Fix broken retraction check logic
- Add package doc comment
@chaptersix chaptersix marked this pull request as ready for review April 4, 2026 20:21
@chaptersix chaptersix changed the title Replace shell-based dependency validation with Go tool Add check-dependencies CI tool Apr 4, 2026
@chaptersix chaptersix requested review from spkane31 and stephanos April 6, 2026 19:30
Comment thread cmd/tools/check-dependencies/main.go Outdated
Comment thread cmd/tools/check-dependencies/main.go Outdated
@chaptersix chaptersix changed the title Add check-dependencies CI tool Rewrite dependency version check as Go tool, extend to main branch Apr 10, 2026
@chaptersix chaptersix marked this pull request as draft April 13, 2026 18:13
@chaptersix
Copy link
Copy Markdown
Contributor Author

need to add some integration tests.

@chaptersix chaptersix marked this pull request as ready for review April 15, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants