Add go_cross_test rule for cross-compiling tests.#3274
Add go_cross_test rule for cross-compiling tests.#3274JamesMBartlett wants to merge 3 commits intobazel-contrib:masterfrom
go_cross_test rule for cross-compiling tests.#3274Conversation
- Adds a `go_cross` rule that wraps a `go_binary` to generate a cross-compiled version of the binary. - Supports compiling for a different platform, and/or a different golang SDK version. - Adds docs for the new `go_cross` rule. - Adds testing in `tests/core/cross` for the new `go_cross` rule. Signed-off-by: James Bartlett <[email protected]>
Signed-off-by: James Bartlett <[email protected]>
Works the same as the `go_cross_binary` rule. Because of [this](bazelbuild/bazel#15224) bazel issue, there's no way to access the underlying `go_test` rule's `env` info provider. So until bazel 5.3.0 becomes the `rules_go` minimum bazel version, I see no way of passing through the `go_test` rule's `env` to the `go_cross_test`. This means any `env` set will not be used when the `go_cross_test` test is run, which is a little unfortunate. However, I think `go_cross_test` is still useful in the meantime despite this limitation. Signed-off-by: James Bartlett <[email protected]>
|
I'm going to hold off reviewing this one until the other one is merged and the diff gets a lot simpler. Please ping if you don't see a review shortly after the other one merges |
|
Thanks for the PR. I am also looking to adopt this functionality. As I am testing locally, I noticed that usage isn't supported. Here's an example of go_test where the arguments need to be passed into test_setup.sh upon invoking. With this diff, the arguments are not being passed in during runtime while I run |
|
@tingilee |
|
@JamesMBartlett Any updates to this diff? We would like to incorporate this as part of our monorepo. |
|
@tingilee I don't think the necessary changes have landed in bazel yet. And I think given the fact it will ignore |
|
@fmeum Are there updates on bazelbuild/bazel#16430 ? Would you suggest waiting for the upstream Bazel support before landing go_cross_test with limited functionalities? |
|
@tingilee Can you use a fork of rules_go or patch this PR in for now? After Bazel 6 has been released, we can probably raise our minimum version of Bazel again and implement |
|
@fmeum just wanted to check on this. I read the linked PR -- seems like there's quite a bit of discussion around whether or not they even want to support this. Do you think we might be able to convince the Bazel maintainers to accept that PR? |
What type of PR is this?
Feature
What does this PR do? Why is it needed?
go_cross_testrule which reuses the implementation of thego_cross_binaryrule from Addgo_cross_binaryrule for cross-compilation. #3261.go_cross_testrule can be used to change the SDK version of ago_test.go_cross_testrules don't currently copy theenvfrom thego_testrule. This seems like it will be fixed in bazel5.3.0but as far as I can tell there will be no way to fix it here until5.3.0is the minimum bazel version.Which issues(s) does this PR fix?
Continuation from [FR/Proposal] Support use of multiple SDK versions in the same bazel workspace #3202