Skip to content

Commit bf31d60

Browse files
roychyingchenghan.ying
andauthored
(fix)build: disable proto rule generation, rely on checked-in .pb.go for go-code compatibility (#293)
<!-- Provide a summary in the Title above. Example: "Feature: add user authentication" --> ## Why? We want the smoothest DX for consuming the OSS submitqueue repo in go-code. Today go-code's `go_repository` uses `build_file_generation = "on"`, so its Gazelle regenerates BUILD files for the vendored repo. This causes conflicts and mismatches, and every version bump risks new patching. The root issue is that OSS carries proto types twice: as checked-in `.pb.go` in `protopb/`, and as Bazel-generated code via `go_proto_library` in `proto/`. Removing the Bazel proto rules in favor of the checked-in `.pb.go` fixes several things at once: - Eliminates duplicate proto definitions. The two generation paths share the same importpath, which caused the duplicate-importpath ambiguity and forced the `gazelle:resolve` workarounds. Collapsing to a single source removes that whole class of conflict. - Serves non-Bazel consumers. The Bazel-generated code only exists inside a Bazel build graph. Anyone consuming submitqueue via plain `go build/go get` (including OSS users) can only use the checked-in .pb.go, so that path must work regardless. The Bazel proto rules are a redundant second path that serves no one the checked-in files don't already serve. ## What? Disable Gazelle proto rule generation and remove all proto compilation rules, relying solely on checked-in `.pb.go` files. - Add `# gazelle:proto disable_global` to prevent Gazelle from regenerating proto rules on future make gazelle runs - Remove the `gazelle:resolve directives` that are no longer needed - Remove `proto_library`, `go_proto_library`, and alias `go_library` rules - Keep `exports_files` for `make proto` codegen (`tool/proto/BUILD.bazel`) ## Test Plan - `make build` - pass - `make test` - 65/65 unit tests pass (integration/e2e tests fail due to Docker dependency, pre-existing) - `bazel build //tool/proto:generated` - proto codegen still works - `make gazelle` - zero warnings, no duplicate-importpath ambiguity - Validated in go-code with `--override_repository` pointing at this branch: all 71 targets build, all 20 tests pass across stovepipe, submitqueue/gateway, and submitqueue/orchestrator ## Issue <!-- Link the issue here. - Use 'Closes #123' if this is the final fix. - Use 'Part of #123' or just '#123' if the feature is still in progress. --> --------- Co-authored-by: chenghan.ying <chenghan.ying@uber.com>
1 parent 6c01f91 commit bf31d60

10 files changed

Lines changed: 14 additions & 360 deletions

File tree

BUILD.bazel

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ load("@gazelle//:def.bzl", "gazelle")
66
# index them as duplicate rule definitions and corrupt the canonical BUILD files.
77
# gazelle:exclude .claude
88

9-
# Resolve protobuf import ambiguities - use the actual protopb packages, not the proto aliases
10-
# gazelle:resolve go github.com/uber/submitqueue/api/base/change/protopb //api/base/change/protopb
11-
# gazelle:resolve go github.com/uber/submitqueue/api/base/mergestrategy/protopb //api/base/mergestrategy/protopb
12-
# gazelle:resolve go github.com/uber/submitqueue/api/runway/messagequeue/protopb //api/runway/messagequeue/protopb
13-
# gazelle:resolve go github.com/uber/submitqueue/api/runway/protopb //api/runway/protopb
14-
# gazelle:resolve go github.com/uber/submitqueue/api/submitqueue/gateway/protopb //api/submitqueue/gateway/protopb
15-
# gazelle:resolve go github.com/uber/submitqueue/api/submitqueue/orchestrator/protopb //api/submitqueue/orchestrator/protopb
16-
# gazelle:resolve go github.com/uber/submitqueue/api/stovepipe/protopb //api/stovepipe/protopb
9+
# Disable Gazelle proto rule generation globally. We rely on the checked-in
10+
# .pb.go files in protopb/ dirs (plain go_library) rather than Bazel proto
11+
# compilation. Rationale:
12+
# - The checked-in .pb.go is the single source of truth. Generating proto
13+
# via Bazel duplicates the same types under the same importpath, causing
14+
# duplicate-importpath ambiguity that required gazelle:resolve workarounds.
15+
# - Non-Bazel consumers (plain go build/go get, including OSS users) can only
16+
# use the checked-in .pb.go, so that path must work regardless. The Bazel
17+
# proto rules are a redundant second path that serves no one the checked-in
18+
# files don't already serve.
19+
# - proto_library forces a transitive load of @protobuf//, which breaks in
20+
# consumers on newer Bazel versions (e.g. go-code's Bazel 8.5.1 removed
21+
# native.java_proto_library).
22+
# gazelle:proto disable_global
1723

1824
# Export marker files for test data dependencies (used by FindRepoRoot in tests)
1925
exports_files(

api/base/change/proto/BUILD.bazel

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["change.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "changepb_proto",
12-
srcs = ["change.proto"],
13-
visibility = ["//visibility:public"],
14-
)
15-
16-
# keep
17-
go_proto_library(
18-
name = "changepb_go_proto",
19-
compilers = [
20-
"@rules_go//proto:go_proto",
21-
"@rules_go//proto:go_grpc_v2",
22-
],
23-
importpath = "github.com/uber/submitqueue/api/base/change/proto",
24-
proto = ":changepb_proto",
25-
visibility = ["//visibility:public"],
26-
)
27-
28-
go_library(
29-
name = "proto",
30-
embed = [":changepb_go_proto"],
31-
importpath = "github.com/uber/submitqueue/api/base/change/proto",
32-
visibility = ["//visibility:public"],
33-
)
34-
35-
go_library(
36-
name = "protopb",
37-
embed = [":changepb_go_proto"],
38-
importpath = "github.com/uber/submitqueue/api/base/change/protopb",
39-
visibility = ["//visibility:public"],
40-
)
Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["mergestrategy.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "mergestrategypb_proto",
12-
srcs = ["mergestrategy.proto"],
13-
visibility = ["//visibility:public"],
14-
)
15-
16-
# keep
17-
go_proto_library(
18-
name = "mergestrategypb_go_proto",
19-
compilers = [
20-
"@rules_go//proto:go_proto",
21-
"@rules_go//proto:go_grpc_v2",
22-
],
23-
importpath = "github.com/uber/submitqueue/api/base/mergestrategy/proto",
24-
proto = ":mergestrategypb_proto",
25-
visibility = ["//visibility:public"],
26-
)
27-
28-
go_library(
29-
name = "proto",
30-
embed = [":mergestrategypb_go_proto"],
31-
importpath = "github.com/uber/submitqueue/api/base/mergestrategy/proto",
32-
visibility = ["//visibility:public"],
33-
)
34-
35-
go_library(
36-
name = "protopb",
37-
embed = [":mergestrategypb_go_proto"],
38-
importpath = "github.com/uber/submitqueue/api/base/mergestrategy/protopb",
39-
visibility = ["//visibility:public"],
40-
)
Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["messagequeue.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "messagequeuepb_proto",
12-
srcs = ["messagequeue.proto"],
13-
visibility = ["//visibility:public"],
14-
deps = ["@protobuf//:descriptor_proto"],
15-
)
16-
17-
# keep
18-
go_proto_library(
19-
name = "messagequeuepb_go_proto",
20-
compilers = [
21-
"@rules_go//proto:go_proto",
22-
"@rules_go//proto:go_grpc_v2",
23-
],
24-
importpath = "github.com/uber/submitqueue/api/base/messagequeue/proto",
25-
proto = ":messagequeuepb_proto",
26-
visibility = ["//visibility:public"],
27-
)
28-
29-
go_library(
30-
name = "proto",
31-
embed = [":messagequeuepb_go_proto"],
32-
importpath = "github.com/uber/submitqueue/api/base/messagequeue/proto",
33-
visibility = ["//visibility:public"],
34-
)
35-
36-
go_library(
37-
name = "protopb",
38-
embed = [":messagequeuepb_go_proto"],
39-
importpath = "github.com/uber/submitqueue/api/base/messagequeue/protopb",
40-
visibility = ["//visibility:public"],
41-
)
Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["merge.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "mergepb_proto",
12-
srcs = ["merge.proto"],
13-
visibility = ["//visibility:public"],
14-
deps = [
15-
"//api/base/change/proto:changepb_proto",
16-
"//api/base/mergestrategy/proto:mergestrategypb_proto",
17-
"//api/base/messagequeue/proto:messagequeuepb_proto",
18-
],
19-
)
20-
21-
# keep
22-
go_proto_library(
23-
name = "mergepb_go_proto",
24-
compilers = [
25-
"@rules_go//proto:go_proto",
26-
"@rules_go//proto:go_grpc_v2",
27-
],
28-
importpath = "github.com/uber/submitqueue/api/runway/messagequeue/proto",
29-
proto = ":mergepb_proto",
30-
visibility = ["//visibility:public"],
31-
# keep
32-
deps = [
33-
"//api/base/change/proto:changepb_go_proto",
34-
"//api/base/mergestrategy/proto:mergestrategypb_go_proto",
35-
"//api/base/messagequeue/proto:messagequeuepb_go_proto",
36-
],
37-
)
38-
39-
go_library(
40-
name = "proto",
41-
embed = [":mergepb_go_proto"],
42-
importpath = "github.com/uber/submitqueue/api/runway/messagequeue/proto",
43-
visibility = ["//visibility:public"],
44-
)
45-
46-
go_library(
47-
name = "protopb",
48-
embed = [":mergepb_go_proto"],
49-
importpath = "github.com/uber/submitqueue/api/runway/messagequeue/protopb",
50-
visibility = ["//visibility:public"],
51-
)

api/runway/proto/BUILD.bazel

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["runway.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "runwaypb_proto",
12-
srcs = ["runway.proto"],
13-
visibility = ["//visibility:public"],
14-
)
15-
16-
# keep
17-
go_proto_library(
18-
name = "runwaypb_go_proto",
19-
compilers = [
20-
"@rules_go//proto:go_proto",
21-
"@rules_go//proto:go_grpc_v2",
22-
],
23-
importpath = "github.com/uber/submitqueue/api/runway/proto",
24-
proto = ":runwaypb_proto",
25-
visibility = ["//visibility:public"],
26-
)
27-
28-
go_library(
29-
name = "proto",
30-
embed = [":runwaypb_go_proto"],
31-
importpath = "github.com/uber/submitqueue/api/runway/proto",
32-
visibility = ["//visibility:public"],
33-
)
34-
35-
go_library(
36-
name = "protopb",
37-
embed = [":runwaypb_go_proto"],
38-
importpath = "github.com/uber/submitqueue/api/runway/protopb",
39-
visibility = ["//visibility:public"],
40-
)

api/stovepipe/proto/BUILD.bazel

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["stovepipe.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "stovepipepb_proto",
12-
srcs = ["stovepipe.proto"],
13-
visibility = ["//visibility:public"],
14-
)
15-
16-
# keep
17-
go_proto_library(
18-
name = "stovepipepb_go_proto",
19-
compilers = [
20-
"@rules_go//proto:go_proto",
21-
"@rules_go//proto:go_grpc_v2",
22-
],
23-
importpath = "github.com/uber/submitqueue/api/stovepipe/proto",
24-
proto = ":stovepipepb_proto",
25-
visibility = ["//visibility:public"],
26-
)
27-
28-
go_library(
29-
name = "proto",
30-
embed = [":stovepipepb_go_proto"],
31-
importpath = "github.com/uber/submitqueue/api/stovepipe/proto",
32-
visibility = ["//visibility:public"],
33-
)
34-
35-
go_library(
36-
name = "protopb",
37-
embed = [":stovepipepb_go_proto"],
38-
importpath = "github.com/uber/submitqueue/api/stovepipe/protopb",
39-
visibility = ["//visibility:public"],
40-
)
Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["gateway.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "gatewaypb_proto",
12-
srcs = ["gateway.proto"],
13-
visibility = ["//visibility:public"],
14-
deps = [
15-
"//api/base/change/proto:changepb_proto",
16-
"//api/base/mergestrategy/proto:mergestrategypb_proto",
17-
],
18-
)
19-
20-
# keep
21-
go_proto_library(
22-
name = "gatewaypb_go_proto",
23-
compilers = [
24-
"@rules_go//proto:go_proto",
25-
"@rules_go//proto:go_grpc_v2",
26-
],
27-
importpath = "github.com/uber/submitqueue/api/submitqueue/gateway/proto",
28-
proto = ":gatewaypb_proto",
29-
visibility = ["//visibility:public"],
30-
# keep
31-
deps = [
32-
"//api/base/change/proto:changepb_go_proto",
33-
"//api/base/mergestrategy/proto:mergestrategypb_go_proto",
34-
],
35-
)
36-
37-
go_library(
38-
name = "proto",
39-
embed = [":gatewaypb_go_proto"],
40-
importpath = "github.com/uber/submitqueue/api/submitqueue/gateway/proto",
41-
visibility = ["//visibility:public"],
42-
)
43-
44-
go_library(
45-
name = "protopb",
46-
embed = [":gatewaypb_go_proto"],
47-
importpath = "github.com/uber/submitqueue/api/submitqueue/gateway/protopb",
48-
visibility = ["//visibility:public"],
49-
)
Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
load("@rules_go//go:def.bzl", "go_library")
2-
load("@rules_go//proto:def.bzl", "go_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
4-
51
exports_files(
62
["orchestrator.proto"],
73
visibility = ["//tool/proto:__pkg__"],
84
)
9-
10-
proto_library(
11-
name = "orchestratorpb_proto",
12-
srcs = ["orchestrator.proto"],
13-
visibility = ["//visibility:public"],
14-
)
15-
16-
# keep
17-
go_proto_library(
18-
name = "orchestratorpb_go_proto",
19-
compilers = [
20-
"@rules_go//proto:go_proto",
21-
"@rules_go//proto:go_grpc_v2",
22-
],
23-
importpath = "github.com/uber/submitqueue/api/submitqueue/orchestrator/proto",
24-
proto = ":orchestratorpb_proto",
25-
visibility = ["//visibility:public"],
26-
)
27-
28-
go_library(
29-
name = "proto",
30-
embed = [":orchestratorpb_go_proto"],
31-
importpath = "github.com/uber/submitqueue/api/submitqueue/orchestrator/proto",
32-
visibility = ["//visibility:public"],
33-
)
34-
35-
go_library(
36-
name = "protopb",
37-
embed = [":orchestratorpb_go_proto"],
38-
importpath = "github.com/uber/submitqueue/api/submitqueue/orchestrator/protopb",
39-
visibility = ["//visibility:public"],
40-
)

0 commit comments

Comments
 (0)