Add regression test for #228 external go deps appear in bzlmod hashes#349
Merged
Merged
Conversation
The user asked: "Trying to understand if bazel-diff still works for go deps brought in via the new gazelle/rules_go bzlmod mechanism ... Our hashes file does not include any of the external go dependencies since migrating to the new mechanism." This is a separate signal from the propagation behaviour covered by testGoModUpdateImpactsGoTargets_regressionForIssue266: that one verifies a `go.mod` version bump changes the hash of the dependent //:lib target, but it does not assert the per-module external entry is itself in the hashes JSON. #228 is exactly that question. I reused the `go_mod_change` workspace and verified by hand with the locally built CLI: $ java -jar bazel-bin/cli/bazel-diff_deploy.jar generate-hashes \ -w <workspace> -b bazel /tmp/hashes.json $ jq '.hashes | keys' /tmp/hashes.json [ "//:BUILD", "//:lib", "//:lib.go", "//:lib_test", "//:lib_test.go", "//external:com_github_pkg_errors", "//external:gazelle", "//external:rules_go" ] The `//external:<apparent_name>` entries are the synthetic labels BazelClient produces by querying `bazel mod show_repo --output=streamed_proto` (the mechanism added for #255). They give a per-bzlmod-module hash that changes when the module's resolved version changes -- exactly the surface #228 was asking about. This regression-protection test (not @ignore'd) locks in that behaviour. It parses the hashes JSON, asserts //:lib is present (sanity), and asserts that an entry whose label contains `com_github_pkg_errors` exists and equals `//external:com_github_pkg_errors`. Skipped on Bazel < 8.6.0 and on 9.0.0 (which had a broken mod show_repo path), matching the existing convention. Verified on Bazel 9.1: //cli:E2ETest PASSED in 3.1s Refs #228 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5194a9d to
1c5fc8a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The user in #228 asked:
This is a different signal from the propagation check covered by
testGoModUpdateImpactsGoTargets_regressionForIssue266(#266). That existing test confirms ago.modversion bump changes the hash of the dependent//:libtarget, but it does not assert the per-module external entry is itself in the hashes JSON. #228 is exactly that question.I reused the existing
go_mod_changeworkspace fixture and verified by hand against the locally built CLI:The
//external:<apparent_name>entries are the synthetic labelsBazelClientproduces by queryingbazel mod show_repo --output=streamed_proto(the mechanism added for #255). They give a per-bzlmod-module hash that changes when the module's resolved version changes — exactly the surface #228 was asking about.This regression-protection test (not
@Ignore'd) locks in that behaviour. It parses the hashes JSON, asserts//:libis present (sanity), and asserts that an entry whose label containscom_github_pkg_errorsexists and equals//external:com_github_pkg_errors.Skipped on Bazel < 8.6.0 and on 9.0.0 (which had a broken
mod show_repopath), matching the existing convention.Test plan
bazel test //cli:E2ETest --test_filter=testExternalGoDepsAppearInHashes_regressionForIssue228passes on Bazel 9.1Refs #228
🤖 Generated with Claude Code