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

sluongng/upgrade rules go #3699

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checkstyle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: go deps
# Keep Gazelle version in sync with WORKSPACE
run: |
go install github.com/bazelbuild/bazel-gazelle/cmd/gazelle@v0.29.0
go install github.com/bazelbuild/bazel-gazelle/cmd/gazelle@v0.30.0
GAZELLE_PATH="$(go env GOPATH)/bin/gazelle" tools/fix_go_deps.sh --diff &> go-deps-diff.txt || true
echo "go deps diff:"
cat go-deps-diff.txt
Expand Down
41 changes: 7 additions & 34 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ http_archive(

http_archive(
name = "io_bazel_rules_go",
sha256 = "dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
patch_args = ["-p1"],
patches = ["//buildpatches:gazelle.patch"],
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
],
)

Expand All @@ -50,36 +50,9 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchai

go_rules_dependencies()

Copy link
Member

@bduffany bduffany Apr 3, 2023

Choose a reason for hiding this comment

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

I think there was some reason we wanted to use go_download_sdk instead of go_register_toolchains, maybe related to cross-compilation. Maybe @siggisim remembers?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we want to make sure to be able to download both the linux and mac sdks regardless of host (the default rules only download the SDK from your host machine). This allows you to kick of linux remote execution builds from a mac host, i.e. https://www.buildbuddy.dev/debugging#run-buildbuddy-test-suite-on-linux-remote-ex-from-a-mac

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed a fix in bazelbuild/rules_go#3511 and patched our rules_go with it in the latest version.

Since the rules_go PR is merged, it should be a short-lived patch.

go_download_sdk(
name = "go_sdk_linux",
goarch = "amd64",
goos = "linux",
version = "1.19.3", # Keep in sync with .github/workflows/checkstyle.yaml
)

go_download_sdk(
name = "go_sdk_linux_arm64",
goarch = "arm64",
goos = "linux",
version = "1.19.3",
)

go_download_sdk(
name = "go_sdk_darwin",
goarch = "amd64",
goos = "darwin",
version = "1.19.3",
)

go_download_sdk(
name = "go_sdk_darwin_arm64",
goarch = "arm64",
goos = "darwin",
version = "1.19.3",
)

go_register_toolchains(
nogo = "@//:vet",
version = "1.19.3",
)

gazelle_dependencies()
Expand Down
17 changes: 14 additions & 3 deletions buildpatches/gazelle.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
diff --git a/cmd/gazelle/gazelle.go b/cmd/gazelle/gazelle.go
index 2ff57db..7d0c6be 100644
--- a/cmd/gazelle/gazelle.go
+++ b/cmd/gazelle/gazelle.go
@@ -56,6 +56,10 @@ func (cmd command) String() string {
Expand All @@ -14,7 +13,6 @@ index 2ff57db..7d0c6be 100644
log.SetFlags(0) // don't print timestamps

diff --git a/cmd/gazelle/BUILD.bazel b/cmd/gazelle/BUILD.bazel
index 1cbaea7..4f9a083 100644
--- a/cmd/gazelle/BUILD.bazel
+++ b/cmd/gazelle/BUILD.bazel
@@ -1,6 +1,8 @@
Expand All @@ -25,4 +23,17 @@ index 1cbaea7..4f9a083 100644
+
gazelle_binary(
name = "gazelle",
languages = DEFAULT_LANGUAGES,
languages = DEFAULT_LANGUAGES,

diff --git a/internal/module/BUILD.bazel b/internal/module/BUILD.bazel
--- a/internal/module/BUILD.bazel
+++ b/internal/module/BUILD.bazel
@@ -4,7 +4,7 @@ go_library(
name = "module",
srcs = ["module.go"],
importpath = "github.com/bazelbuild/bazel-gazelle/internal/module",
- visibility = ["//:__subpackages__"],
+ visibility = ["//visibility:public"],
deps = ["@com_github_bazelbuild_buildtools//build:go_default_library"],
)

1 change: 1 addition & 0 deletions cli/fix/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ go_library(
"//cli/fix/typescript",
"@bazel_gazelle//config",
"@bazel_gazelle//flag",
"@bazel_gazelle//internal/module",
"@bazel_gazelle//internal/wspace",
"@bazel_gazelle//label",
"@bazel_gazelle//language",
Expand Down
36 changes: 18 additions & 18 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
go_repository(
name = "com_github_bazelbuild_bazel_gazelle",
importpath = "github.com/bazelbuild/bazel-gazelle",
sum = "h1:uFYs0rkVtEwZ6PlVQAXkBrIvWtIljMG8YR67LGiopeY=",
version = "v0.29.0",
sum = "h1:q9XLWQSCA5NZPJ98WFqicHkq6fxrDPnfvMO1XycQBMg=",
version = "v0.30.0",
)

go_repository(
Expand All @@ -316,15 +316,15 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
go_repository(
name = "com_github_bazelbuild_buildtools",
importpath = "github.com/bazelbuild/buildtools",
sum = "h1:DraHsDqTYhf6w1369EEdFyA5hjJnGX88xNJRv1+20E0=",
version = "v0.0.0-20230111132423-06e8e2436a75",
sum = "h1:XmPu4mXICgdGnC5dXGjUGbwUD/kUmS0l5Aop3LaevBM=",
version = "v0.0.0-20230317132445-9c3c1fc0106e",
)

go_repository(
name = "com_github_bazelbuild_rules_go",
importpath = "github.com/bazelbuild/rules_go",
sum = "h1:vbnESGv/t2WgGEbXatwbXAS95dTx93Lv6Uh5QkVF13s=",
version = "v0.37.0",
sum = "h1:YWJ+hbwEOB/PtIFCRMDnvWVSpwPFFGEpdIB6E3bt8X4=",
version = "v0.39.0",
)
go_repository(
name = "com_github_bazelbuild_rules_webtesting",
Expand Down Expand Up @@ -5941,14 +5941,14 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
go_repository(
name = "org_golang_x_mod",
importpath = "golang.org/x/mod",
sum = "h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=",
version = "v0.7.0",
sum = "h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=",
version = "v0.9.0",
)
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=",
version = "v0.7.0",
sum = "h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=",
version = "v0.8.0",
)

go_repository(
Expand All @@ -5970,21 +5970,21 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
# build_file_generation = "off",
# patch_args = ["-p1"],
# patches = ["@io_bazel_rules_go//third_party:org_golang_x_sys-gazelle.patch"],
sum = "h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=",
version = "v0.5.0",
sum = "h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=",
version = "v0.6.0",
)
go_repository(
name = "org_golang_x_term",
importpath = "golang.org/x/term",
sum = "h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=",
version = "v0.5.0",
sum = "h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=",
version = "v0.6.0",
)

go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=",
version = "v0.7.0",
sum = "h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=",
version = "v0.8.0",
)

go_repository(
Expand All @@ -6000,8 +6000,8 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
importpath = "golang.org/x/tools",
patch_args = ["-p1"],
patches = ["@io_bazel_rules_go//third_party:org_golang_x_tools-gazelle.patch"],
sum = "h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4=",
version = "v0.5.0",
sum = "h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=",
version = "v0.7.0",
)

go_repository(
Expand Down
5 changes: 1 addition & 4 deletions enterprise/server/cmd/server/yaml_doc/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

# gazelle:default_visibility //enterprise:__subpackages__
package(default_visibility = [
"//enterprise:__subpackages__",
"@buildbuddy_internal//:__subpackages__",
])
package(default_visibility = ["//enterprise:__subpackages__"])

go_binary(
name = "yaml_doc",
Expand Down
5 changes: 1 addition & 4 deletions enterprise/server/remote_execution/runner/testworker/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

# gazelle:default_visibility //enterprise/server/remote_execution/runner:__subpackages__
package(default_visibility = [
"//enterprise:__subpackages__",
"//enterprise/server/remote_execution/runner:__subpackages__",
])
package(default_visibility = ["//enterprise/server/remote_execution/runner:__subpackages__"])

go_library(
name = "testworker_lib",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

# TODO(sluongng): ensure all //enterprise code are not dependency of FOSS code
# gazelle:default_visibility //enterprise/server/test/integration/remote_execution:__subpackages__
package(default_visibility = [
"//enterprise:__subpackages__",
"//enterprise/server/test/integration/remote_execution:__subpackages__",
])
package(default_visibility = ["//enterprise/server/test/integration/remote_execution:__subpackages__"])

proto_library(
name = "remoteexecutiontest_proto",
Expand Down
5 changes: 1 addition & 4 deletions enterprise/server/webhooks/bitbucket/test_data/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

# gazelle:default_visibility //enterprise/server/webhooks/bitbucket:__subpackages__
package(default_visibility = [
"//enterprise:__subpackages__",
"//enterprise/server/webhooks/bitbucket:__subpackages__",
])
package(default_visibility = ["//enterprise/server/webhooks/bitbucket:__subpackages__"])

go_library(
name = "test_data",
Expand Down
5 changes: 1 addition & 4 deletions enterprise/server/webhooks/github/test_data/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

# gazelle:default_visibility //enterprise/server/webhooks/github:__subpackages__
package(default_visibility = [
"//enterprise:__subpackages__",
"//enterprise/server/webhooks/github:__subpackages__",
])
package(default_visibility = ["//enterprise/server/webhooks/github:__subpackages__"])

go_library(
name = "test_data",
Expand Down
5 changes: 1 addition & 4 deletions enterprise/server/workflow/config/test_data/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

# gazelle:default_visibility //enterprise/server/workflow/config:__subpackages__
package(default_visibility = [
"//enterprise:__subpackages__",
"//enterprise/server/workflow/config:__subpackages__",
])
package(default_visibility = ["//enterprise/server/workflow/config:__subpackages__"])

go_library(
name = "test_data",
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ require (
github.com/GoogleCloudPlatform/cloudsql-proxy v1.33.0
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e
github.com/aws/aws-sdk-go v1.43.9
github.com/bazelbuild/bazel-gazelle v0.29.0
github.com/bazelbuild/bazel-gazelle v0.30.0
github.com/bazelbuild/bazelisk v1.11.0
github.com/bazelbuild/rules_go v0.37.0
github.com/bazelbuild/rules_go v0.39.0
github.com/bazelbuild/rules_webtesting v0.0.0-20210910170740-6b2ef24cfe95
github.com/bduffany/godemon v0.0.0-20221115232931-09721d48e30e
github.com/bojand/ghz v0.110.0
Expand Down Expand Up @@ -96,8 +96,8 @@ require (
golang.org/x/crypto v0.6.0
golang.org/x/oauth2 v0.1.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.5.0
golang.org/x/text v0.7.0
golang.org/x/sys v0.6.0
golang.org/x/text v0.8.0
golang.org/x/time v0.1.0
google.golang.org/api v0.102.0
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c
Expand Down Expand Up @@ -128,7 +128,7 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/bazelbuild/buildtools v0.0.0-20230111132423-06e8e2436a75 // indirect
github.com/bazelbuild/buildtools v0.0.0-20230317132445-9c3c1fc0106e // indirect
github.com/beevik/etree v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
Expand Down Expand Up @@ -262,10 +262,10 @@ require (
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/tools v0.5.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
Expand Down