Skip to content
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

[go_sdk download] allow patches to standard library #3684

Merged
merged 1 commit into from
Sep 15, 2023

Conversation

tyler-french
Copy link
Contributor

@tyler-french tyler-french commented Sep 7, 2023

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Allows users to provide patches to the Go SDK when using the go_download_sdk rule or the go_sdk.download Bzlmod tag.

This is helpful when some modification is needed to a package in the go standard library, but the user does not want to manage a fork of the standard library itself.

Since we build the standard library from source, the patches should apply appropriately across multiple OS and Architectures. However, we should not expect patches to apply correctly across multiple versions of the Go toolchain. For that reason, we only allow patches if the version is specified.

Which issues(s) does this PR fix?

Fixes #3683

Testing
Added a test to the BCR which patches the os package and then runs a test to assert the patch properly applied.

Show that patches cannot apply when version is not specified:

% bazel-6.3.2 test //...
...
ERROR: An error occurred during the fetch of repository 'rules_go~override~go_sdk~rules_go_bcr_tests__download_0':
   Traceback (most recent call last):
        File "/home/user/.cache/bazel/_bazel_tfrench/565e6f63e863d6a7567b33b30501a80c/external/rules_go~override/go/private/sdk.bzl", line 93, column 21, in _go_download_sdk_impl
                fail("version must be specified when patches are specified")
Error in fail: version must be specified when patches are specified
...
ERROR: Couldn't start the build. Unable to run tests

@tyler-french tyler-french force-pushed the patch_download_sdk branch 10 times, most recently from 80bf115 to 43adf30 Compare September 14, 2023 14:23
@tyler-french tyler-french marked this pull request as ready for review September 14, 2023 14:23
@tyler-french tyler-french force-pushed the patch_download_sdk branch 9 times, most recently from d435a33 to 5e5b99d Compare September 15, 2023 00:48
go/private/sdk.bzl Outdated Show resolved Hide resolved
@tyler-french tyler-french force-pushed the patch_download_sdk branch 3 times, most recently from 0841eac to 9bd7288 Compare September 15, 2023 13:52
@fmeum fmeum force-pushed the patch_download_sdk branch from 9bd7288 to 8f2c054 Compare September 15, 2023 14:02
@fmeum fmeum enabled auto-merge (squash) September 15, 2023 14:02
@fmeum fmeum merged commit 9ebc93c into bazel-contrib:master Sep 15, 2023
@tyler-french tyler-french deleted the patch_download_sdk branch December 23, 2023 18:43
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.

the go_sdk.download tag does not support patches
2 participants