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

bazel: bump Bazel repositories versions #3413

Merged
merged 3 commits into from Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .bazelrc
@@ -0,0 +1,3 @@
build --cxxopt=-std=c++14
build --host_cxxopt=-std=c++14
build --test_output=errors
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -70,13 +70,11 @@ jobs:
key: v1-bazel-cache-${{ hashFiles('repositories.bzl') }}
restore-keys: v1-bazel-cache-
- name: Configure bazel
run: |
cat > .bazelrc << EOF
startup --output_base /home/vscode/.cache/_grpc_gateway_bazel
build --test_output errors
build --features race
# Protobuf v3.22.0+ requires C++14
build --repo_env=BAZEL_CXXOPTS=-std=c++14
run:
| # put .bazelrc in $HOME so that it's read before project's .bazelrc
cat > /home/vscode/.bazelrc << EOF
startup --output_base=/home/vscode/.cache/_grpc_gateway_bazel
build --@io_bazel_rules_go//go/config:race
# Workaround https://github.com/bazelbuild/bazel/issues/3645
# See https://docs.bazel.build/versions/0.23.0/command-line-reference.html
build --local_ram_resources=7168 # Github runners have 7G of memory
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -7,7 +7,6 @@ bazel-genfiles
bazel-grpc-gateway
bazel-out
bazel-testlogs
/.bazelrc

# Go vendor directory
vendor
Expand Down
12 changes: 12 additions & 0 deletions BUILD.bazel
Expand Up @@ -19,6 +19,18 @@ buildifier(
# gazelle:go_proto_compilers //:go_apiv2
# gazelle:go_grpc_compilers //:go_apiv2, //:go_grpc
# gazelle:go_naming_convention import_alias
# gazelle:resolve proto proto google/api/annotations.proto @googleapis//google/api:annotations_proto
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure if this is the best place for these directives.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I will defer to @achew22 on this

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is the correct place for them

# gazelle:resolve proto go google/api/annotations.proto @org_golang_google_genproto_googleapis_api//annotations
# gazelle:resolve proto proto google/api/http.proto @googleapis//google/api:http_proto
# gazelle:resolve proto go google/api/http.proto @org_golang_google_genproto_googleapis_api//annotations
# gazelle:resolve proto proto google/api/field_behavior.proto @googleapis//google/api:field_behavior_proto
# gazelle:resolve proto go google/api/field_behavior.proto @org_golang_google_genproto_googleapis_api//annotations
# gazelle:resolve proto proto google/api/httpbody.proto @googleapis//google/api:httpbody_proto
# gazelle:resolve proto go google/api/httpbody.proto @org_golang_google_genproto_googleapis_api//httpbody
# gazelle:resolve proto proto google/api/visibility.proto @googleapis//google/api:visibility_proto
# gazelle:resolve proto go google/api/visibility.proto @org_golang_google_genproto_googleapis_api//visibility
# gazelle:resolve proto proto google/rpc/status.proto @googleapis//google/rpc:status_proto
# gazelle:resolve proto go google/rpc/status.proto @org_golang_google_genproto_googleapis_rpc//status

gazelle(name = "gazelle")

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -19,7 +19,7 @@ docker run -itv $(pwd):/grpc-gateway -w /grpc-gateway --entrypoint /bin/bash --r
ghcr.io/grpc-ecosystem/grpc-gateway/build-env:1.19 -c '\
bazel run :gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories && \
bazel run :gazelle && \
bazel run :buildifier'
BAZEL_CXXOPTS="-std=c++14" bazel run :buildifier'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alternatively, we could put .bazelrc in the project root. I found that in ci.yml we are setting exactly the same env.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have various environment specific options like the CPU and memory limiters that shouldn't go in .bazelrc, but this option does seem like a reasonable thing to put in a repo wide .bazelrc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably drop it in the .bazelrc,

build --cxxopt='-std=c++14'

but I have a pathological aversion to environment variables.

```

You may need to authenticate with GitHub to pull `docker.pkg.github.com/grpc-ecosystem/grpc-gateway/build-env`.
Expand Down
46 changes: 31 additions & 15 deletions WORKSPACE
Expand Up @@ -18,6 +18,21 @@ http_archive(
urls = ["https://github.com/protocolbuffers/protobuf/archive/v23.4.tar.gz"],
)

http_archive(
name = "googleapis",
sha256 = "9d1a930e767c93c825398b8f8692eca3fe353b9aaadedfbcf1fca2282c85df88",
strip_prefix = "googleapis-64926d52febbf298cb82a8f472ade4a3969ba922",
urls = [
"https://github.com/googleapis/googleapis/archive/64926d52febbf298cb82a8f472ade4a3969ba922.zip",
],
)

load("@googleapis//:repository_rules.bzl", "switched_rules_by_language")

switched_rules_by_language(
name = "com_google_googleapis_imports",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@adambabik adambabik Jul 24, 2023

Choose a reason for hiding this comment

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

It seems we don't need this, because we use @googleapis only in proto_library. Go deps are resolved to @org_golang_google_genproto_googleapis_api.

I suppose that I could change:

# gazelle:resolve proto go google/api/annotations.proto  @org_golang_google_genproto_googleapis_api//annotations

to

# gazelle:resolve proto go google/api/annotations.proto  @googleapis//google/api:annotations_go_proto

then go = True would be necessary. But I am not sure if it gives us any benefits. @org_golang_google_genproto_googleapis_api was recommended in go_rules and gazelle.

)

http_archive(
name = "bazel_skylib",
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
Expand All @@ -33,11 +48,10 @@ bazel_skylib_workspace()

http_archive(
name = "rules_proto",
sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1",
strip_prefix = "rules_proto-4.0.0",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)

Expand All @@ -49,25 +63,27 @@ rules_proto_toolchains()

http_archive(
name = "io_bazel_rules_go",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
urls = [
"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.41.0/rules_go-v0.39.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
],
)

git_repository(
name = "bazel_gazelle",
commit = "f377e6eff8e24508feb1a34b1e5e681982482a9f",
remote = "https://github.com/bazelbuild/bazel-gazelle",
shallow_since = "1648046534 -0400",
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.19.4")
go_register_toolchains(version = "1.20.6")

http_archive(
name = "bazel_gazelle",
sha256 = "29218f8e0cebe583643cbf93cae6f971be8a2484cdcfa1e45057658df8d54002",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz",
],
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

Expand Down
2 changes: 1 addition & 1 deletion examples/internal/gateway/BUILD.bazel
Expand Up @@ -15,7 +15,7 @@ go_library(
"//examples/internal/proto/standalone",
"//runtime",
"@com_github_golang_glog//:glog",
"@go_googleapis//google/rpc:errdetails_go_proto",
"@org_golang_google_genproto_googleapis_rpc//errdetails",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//connectivity",
"@org_golang_google_grpc//credentials/insecure",
Expand Down
5 changes: 2 additions & 3 deletions examples/internal/helloworld/BUILD.bazel
Expand Up @@ -12,7 +12,7 @@ proto_library(
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//:wrappers_proto",
"@go_googleapis//google/api:annotations_proto",
"@googleapis//google/api:annotations_proto",
],
)

Expand All @@ -27,8 +27,7 @@ go_proto_library(
proto = ":helloworld_proto",
visibility = ["//visibility:public"],
deps = [
"@go_googleapis//google/api:annotations_go_proto",
"@org_golang_google_protobuf//proto:go_default_library", #keep
"@org_golang_google_genproto_googleapis_api//annotations",
],
)

Expand Down
2 changes: 1 addition & 1 deletion examples/internal/integration/BUILD.bazel
Expand Up @@ -20,7 +20,7 @@ go_test(
"@com_github_golang_glog//:glog",
"@com_github_google_go_cmp//cmp",
"@com_github_rogpeppe_fastuuid//:fastuuid",
"@go_googleapis//google/rpc:status_go_proto",
"@org_golang_google_genproto_googleapis_rpc//status",
"@org_golang_google_grpc//codes",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//proto",
Expand Down
26 changes: 14 additions & 12 deletions examples/internal/proto/examplepb/BUILD.bazel
Expand Up @@ -72,10 +72,11 @@ proto_library(
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@go_googleapis//google/api:annotations_proto",
"@go_googleapis//google/api:httpbody_proto",
"@go_googleapis//google/api:visibility_proto",
"@go_googleapis//google/rpc:status_proto",
"@googleapis//google/api:annotations_proto",
"@googleapis//google/api:field_behavior_proto",
"@googleapis//google/api:httpbody_proto",
"@googleapis//google/api:visibility_proto",
"@googleapis//google/rpc:status_proto",
],
)

Expand All @@ -87,8 +88,10 @@ proto_library(
"openapi_merge_b.proto",
],
deps = [
"@go_googleapis//google/api:annotations_proto",
"@go_googleapis//google/api:httpbody_proto",
"@com_google_protobuf//:api_proto",
"@googleapis//google/api:annotations_proto",
"@googleapis//google/api:field_behavior_proto",
"@googleapis//google/rpc:status_proto",
],
)

Expand All @@ -108,11 +111,10 @@ go_proto_library(
"//examples/internal/proto/sub2",
"//protoc-gen-openapiv2/options",
"@com_github_golang_protobuf//descriptor:go_default_library_gen", # keep
"@go_googleapis//google/api:annotations_go_proto",
"@go_googleapis//google/api:httpbody_go_proto",
"@go_googleapis//google/api:visibility_go_proto",
"@go_googleapis//google/rpc:status_go_proto",
"@org_golang_google_protobuf//proto:go_default_library", # keep
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_genproto_googleapis_api//httpbody",
"@org_golang_google_genproto_googleapis_api//visibility",
"@org_golang_google_genproto_googleapis_rpc//status",
],
)

Expand All @@ -131,7 +133,7 @@ go_library(
deps = [
"//runtime",
"//utilities",
"@go_googleapis//google/api:annotations_go_proto",
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//grpclog",
Expand Down
6 changes: 3 additions & 3 deletions examples/internal/server/BUILD.bazel
Expand Up @@ -25,9 +25,9 @@ go_library(
"//runtime",
"@com_github_golang_glog//:glog",
"@com_github_rogpeppe_fastuuid//:fastuuid",
"@go_googleapis//google/api:httpbody_go_proto",
"@go_googleapis//google/rpc:errdetails_go_proto",
"@go_googleapis//google/rpc:status_go_proto",
"@org_golang_google_genproto_googleapis_api//httpbody",
"@org_golang_google_genproto_googleapis_rpc//errdetails",
"@org_golang_google_genproto_googleapis_rpc//status",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//metadata",
Expand Down
2 changes: 1 addition & 1 deletion internal/descriptor/BUILD.bazel
Expand Up @@ -20,8 +20,8 @@ go_library(
"//internal/httprule",
"//protoc-gen-openapiv2/options",
"@com_github_golang_glog//:glog",
"@go_googleapis//google/api:annotations_go_proto",
"@in_gopkg_yaml_v3//:yaml_v3",
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_protobuf//compiler/protogen",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//proto",
Expand Down
6 changes: 2 additions & 4 deletions internal/descriptor/apiconfig/BUILD.bazel
Expand Up @@ -9,17 +9,15 @@ proto_library(
srcs = [
"apiconfig.proto",
],
deps = [
"@go_googleapis//google/api:annotations_proto",
],
deps = ["@googleapis//google/api:http_proto"],
)

go_proto_library(
name = "apiconfig_go_proto",
compilers = ["//:go_apiv2"],
importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig",
proto = ":apiconfig_proto",
deps = ["@go_googleapis//google/api:annotations_go_proto"],
deps = ["@org_golang_google_genproto_googleapis_api//annotations"],
)

go_library(
Expand Down
4 changes: 0 additions & 4 deletions protoc-gen-grpc-gateway/BUILD.bazel
Expand Up @@ -31,11 +31,7 @@ go_proto_compiler(
deps = [
"//runtime:go_default_library",
"//utilities:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//grpclog:go_default_library",
"@org_golang_google_grpc//metadata:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
],
)
12 changes: 6 additions & 6 deletions protoc-gen-openapiv2/internal/genopenapi/BUILD.bazel
Expand Up @@ -21,11 +21,11 @@ go_library(
"//internal/generator",
"//protoc-gen-openapiv2/options",
"@com_github_golang_protobuf//descriptor:go_default_library_gen",
"@go_googleapis//google/api:annotations_go_proto",
"@go_googleapis//google/api:visibility_go_proto",
"@go_googleapis//google/rpc:status_go_proto",
"@com_github_golang_protobuf//ptypes/any",
"@in_gopkg_yaml_v3//:yaml_v3",
"@io_bazel_rules_go//proto/wkt:any_go_proto",
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_genproto_googleapis_api//visibility",
"@org_golang_google_genproto_googleapis_rpc//status",
"@org_golang_google_grpc//grpclog",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//proto",
Expand Down Expand Up @@ -57,9 +57,9 @@ go_test(
"//protoc-gen-openapiv2/options",
"//runtime",
"@com_github_google_go_cmp//cmp",
"@go_googleapis//google/api:annotations_go_proto",
"@go_googleapis//google/api:visibility_go_proto",
"@in_gopkg_yaml_v3//:yaml_v3",
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_genproto_googleapis_api//visibility",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//encoding/prototext",
"@org_golang_google_protobuf//proto",
Expand Down
8 changes: 4 additions & 4 deletions runtime/BUILD.bazel
Expand Up @@ -26,7 +26,7 @@ go_library(
deps = [
"//internal/httprule",
"//utilities",
"@go_googleapis//google/api:httpbody_go_proto",
"@org_golang_google_genproto_googleapis_api//httpbody",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//grpclog",
"@org_golang_google_grpc//health/grpc_health_v1",
Expand Down Expand Up @@ -70,9 +70,9 @@ go_test(
"//utilities",
"@com_github_google_go_cmp//cmp",
"@com_github_google_go_cmp//cmp/cmpopts",
"@go_googleapis//google/api:httpbody_go_proto",
"@go_googleapis//google/rpc:errdetails_go_proto",
"@go_googleapis//google/rpc:status_go_proto",
"@org_golang_google_genproto_googleapis_api//httpbody",
"@org_golang_google_genproto_googleapis_rpc//errdetails",
"@org_golang_google_genproto_googleapis_rpc//status",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//health/grpc_health_v1",
Expand Down
6 changes: 4 additions & 2 deletions runtime/internal/examplepb/BUILD.bazel
Expand Up @@ -22,7 +22,7 @@ proto_library(
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@go_googleapis//google/api:annotations_proto",
"@googleapis//google/api:annotations_proto",
],
)

Expand All @@ -34,7 +34,9 @@ go_proto_library(
],
importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb",
proto = ":examplepb_proto",
deps = ["@go_googleapis//google/api:annotations_go_proto"],
deps = [
"@org_golang_google_genproto_googleapis_api//annotations",
],
)

go_library(
Expand Down