Skip to content

Add go.work and and a Terraform toolchain for Bazel - #18595

Open
SirGitsalot wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
SirGitsalot:bazel-foundation-setup
Open

Add go.work and and a Terraform toolchain for Bazel#18595
SirGitsalot wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
SirGitsalot:bazel-foundation-setup

Conversation

@SirGitsalot

Copy link
Copy Markdown
Member

This is PR 1/n (where n is like 5 or 6) to get to the point where acceptance tests can be run with a single command that doesn't have external dependencies, including checking out and building into the provider repo(s) or installing Terraform. The end goal is:

git clone git@github.com:YourGitHubId/magic-modules.git
cd magic-modules
bazel test //mmv1/products/alloydb:acc_tests

The main changes here are checking in go.work and go.work.sum and adding a toolchain that downloads and makes available a Terraform binary based on the platform you're running on and the Terraform version you want to test against.

This shouldn't have any noticeable effect on either the traditional build or the Bazel build. If it does it indicates a bug in this PR and I'll fix it.


@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 7b7f3db:

Diff report

Your PR hasn't generated any diffs, but I'll let you know if a future commit does.

@SirGitsalot

Copy link
Copy Markdown
Member Author

It turned out there was a problem: having go.work at the root broke all of the go binaries we have under tools/ and .ci/ because go looks for a go.work file in parent directories when it compiles from a go.mod file, and if the module being compiled isn't in the parent go.work the build fails.

It turns out that go_deps.from_file() will accept a file from a subdirectory, so putting it under build_defs/go.work makes both Bazel and the regular go build happy.

@SirGitsalot
SirGitsalot requested a review from melinath August 11, 2026 21:48
@SirGitsalot
SirGitsalot marked this pull request as ready for review August 11, 2026 21:48

@melinath melinath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

holding off on reviewing for now pending discussion.

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.

3 participants