-
-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add go_cross_test
rule for cross-compiling tests.
#3274
base: master
Are you sure you want to change the base?
Add go_cross_test
rule for cross-compiling tests.
#3274
Conversation
- 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 <jamesbartlett@newrelic.com>
Signed-off-by: James Bartlett <jamesbartlett@newrelic.com>
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 <jamesbartlett@newrelic.com>
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_test
rule which reuses the implementation of thego_cross_binary
rule from Addgo_cross_binary
rule for cross-compilation. #3261.go_cross_test
rule can be used to change the SDK version of ago_test
.go_cross_test
rules don't currently copy theenv
from thego_test
rule. This seems like it will be fixed in bazel5.3.0
but as far as I can tell there will be no way to fix it here until5.3.0
is 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