Buf¶
Rules for linting and detecting breaking changes in .proto files with Buf.
Note that these rules behave differently from the other rules in this repo, since these produce no output and are instead used as tests.
Only Linux and Darwin (MacOS) is currently supported by Buf.
Rule |
Description |
---|---|
Checks .proto files for breaking changes |
|
Lints .proto files |
buf_proto_breaking_test¶
Note: This rule is experimental. It may not work correctly!
Checks .proto files for breaking changes
Example¶
Full example project can be found here
WORKSPACE
¶
load("@rules_proto_grpc//buf:repositories.bzl", rules_proto_grpc_buf_repos = "buf_repos")
rules_proto_grpc_buf_repos()
BUILD.bazel
¶
load("@rules_proto_grpc//buf:defs.bzl", "buf_proto_breaking_test")
buf_proto_breaking_test(
name = "buf_proto_lint",
against_input = "@rules_proto_grpc//buf/example:image.json",
protos = [
"@rules_proto_grpc//example/proto:person_proto",
"@rules_proto_grpc//example/proto:place_proto",
"@rules_proto_grpc//example/proto:routeguide_proto",
"@rules_proto_grpc//example/proto:thing_proto",
],
)
Attributes¶
Name |
Type |
Mandatory |
Default |
Description |
---|---|---|---|---|
|
|
true |
|
List of labels that provide the |
|
|
true |
Label of an existing input image file to check against (.json or .bin) |
|
|
|
false |
|
List of Buf breaking rule IDs or categories to use |
|
|
false |
|
List of Buf breaking rule IDs or categories to drop |
|
|
false |
|
Whether to ignore breaking changes in unstable package versions |
Plugins¶
@rules_proto_grpc//buf:breaking_plugin
buf_proto_lint_test¶
Note: This rule is experimental. It may not work correctly!
Lints .proto files
Example¶
Full example project can be found here
WORKSPACE
¶
load("@rules_proto_grpc//buf:repositories.bzl", rules_proto_grpc_buf_repos = "buf_repos")
rules_proto_grpc_buf_repos()
BUILD.bazel
¶
load("@rules_proto_grpc//buf:defs.bzl", "buf_proto_lint_test")
buf_proto_lint_test(
name = "person_buf_proto_lint",
except_rules = ["PACKAGE_VERSION_SUFFIX"],
protos = ["@rules_proto_grpc//example/proto:person_proto"],
use_rules = [
"DEFAULT",
"COMMENTS",
],
)
buf_proto_lint_test(
name = "place_buf_proto_lint",
except_rules = ["PACKAGE_VERSION_SUFFIX"],
protos = ["@rules_proto_grpc//example/proto:place_proto"],
use_rules = [
"DEFAULT",
"COMMENTS",
],
)
buf_proto_lint_test(
name = "thing_buf_proto_lint",
except_rules = ["PACKAGE_VERSION_SUFFIX"],
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
use_rules = [
"DEFAULT",
"COMMENTS",
],
)
buf_proto_lint_test(
name = "routeguide_buf_proto_lint",
except_rules = [
"PACKAGE_VERSION_SUFFIX",
"RPC_REQUEST_STANDARD_NAME",
"RPC_RESPONSE_STANDARD_NAME",
"SERVICE_SUFFIX",
"PACKAGE_DIRECTORY_MATCH",
"RPC_REQUEST_RESPONSE_UNIQUE",
],
protos = ["@rules_proto_grpc//example/proto:routeguide_proto"],
use_rules = [
"DEFAULT",
"COMMENTS",
],
)
Attributes¶
Name |
Type |
Mandatory |
Default |
Description |
---|---|---|---|---|
|
|
true |
List of labels that provide the |
|
|
|
false |
|
List of Buf lint rule IDs or categories to use |
|
|
false |
|
List of Buf lint rule IDs or categories to drop |
|
|
false |
|
Specify the allowed suffix for the zero enum value |
|
|
false |
|
Allow request and response message to be reused in a single RPC |
|
|
false |
|
Allow request message to be |
|
|
false |
|
Allow response message to be |
|
|
false |
|
The suffix to allow for services |
Plugins¶
@rules_proto_grpc//buf:lint_plugin