Skip to content

Commit 44274cb

Browse files
author
jchadwick-buf
authored
Fix Bazel presubmit test (#118)
The Bazel presubmit tests are meant to pass, but currently point to a test that intentionally does not pass. - Move existing test that fails on purpose from `examples/bzlmod` to `examples/unused` - Add new test based on `examples/unused` but without the lint error in `examples/bzlmod`.
1 parent bbac783 commit 44274cb

File tree

12 files changed

+1137
-44
lines changed

12 files changed

+1137
-44
lines changed

MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bzlmod/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ proto_library(
4040
name = "root_proto",
4141
srcs = [
4242
"file.proto",
43-
"unused.proto",
4443
],
4544
visibility = ["//visibility:public"],
4645
deps = ["@buf_deps//validate:validate_proto"],

examples/bzlmod/MODULE.bazel.lock

Lines changed: 19 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bzlmod/file.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@
1313
// limitations under the License.
1414

1515
syntax = "proto3";
16-
17-
import "unused.proto";
18-
import "validate/validate.proto";

examples/unused/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
common --enable_bzlmod --experimental_proto_descriptor_sets_include_source_info

examples/unused/BUILD.bazel

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2021-2025 Buf Technologies, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@rules_buf//buf:defs.bzl", "buf_format", "buf_lint_test")
16+
load("@rules_proto//proto:defs.bzl", "proto_library")
17+
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
18+
19+
exports_files(
20+
["buf.yaml"],
21+
visibility = ["//visibility:public"],
22+
)
23+
24+
gazelle(
25+
name = "gazelle",
26+
gazelle = ":gazelle-buf",
27+
)
28+
29+
gazelle_binary(
30+
name = "gazelle-buf",
31+
languages = [
32+
"@gazelle//language/proto", # Built-in rule from gazelle for Protos.
33+
# Any languages that depend on Gazelle's proto plugin must come after it.
34+
"@rules_buf//gazelle/buf:buf", # Loads the Buf extension
35+
],
36+
visibility = ["//visibility:public"],
37+
)
38+
39+
proto_library(
40+
name = "root_proto",
41+
srcs = [
42+
"file.proto",
43+
"unused.proto",
44+
],
45+
visibility = ["//visibility:public"],
46+
deps = ["@buf_deps//validate:validate_proto"],
47+
)
48+
49+
buf_lint_test(
50+
name = "root_proto_lint",
51+
config = "//:buf.yaml",
52+
targets = [":root_proto"],
53+
)
54+
55+
buf_format(
56+
name = "buf_format",
57+
)

examples/unused/MODULE.bazel

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021-2025 Buf Technologies, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"Bazel dependencies"
16+
17+
bazel_dep(name = "rules_buf", version = "0.0.0", dev_dependency = True)
18+
bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True)
19+
20+
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
21+
bazel_dep(name = "rules_proto", version = "7.0.2")
22+
23+
local_path_override(
24+
module_name = "rules_buf",
25+
path = "../..",
26+
)
27+
28+
buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")
29+
30+
# Override the default version of buf
31+
buf.toolchains(version = "v1.47.2")
32+
33+
# See https://buf.build/docs/build-systems/bazel#buf-dependencies
34+
buf.dependency(module = "buf.build/envoyproxy/protoc-gen-validate:eac44469a7af47e7839a7f1f3d7ac004")
35+
buf.dependency(module = "buf.build/acme/petapis:7abdb7802c8f4737a1a23a35ca8266ef")
36+
37+
# Allow references to labels under @buf_deps
38+
use_repo(buf, "buf_deps")
39+
40+
# Allow people to use `bazel run @rules_buf_toolchains//:buf -- --version`
41+
use_repo(buf, "rules_buf_toolchains")

0 commit comments

Comments
 (0)