Skip to content

Commit

Permalink
Support Error format flag
Browse files Browse the repository at this point in the history
  • Loading branch information
srikrsna-buf committed Nov 9, 2023
1 parent 1191ce8 commit 210d451
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions buf/internal/breaking.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _buf_breaking_test_impl(ctx):
"limit_to_input_files": ctx.attr.limit_to_input_files,
"exclude_imports": ctx.attr.exclude_imports,
"input_config": ctx.file.config.short_path,
"error_format": ctx.attr.error_format,
})
files_to_include = [ctx.file.against]
if ctx.file.config != None:
Expand Down Expand Up @@ -75,6 +76,10 @@ buf_breaking_test = rule(
default = True,
doc = """Checks are limited to the source files excluding imports from breaking change detection. Please refer to https://docs.buf.build/breaking/protoc-plugin for more details""",
),
"error_format": attr.string(
default = "",
doc = "error-format flag for buf breaking: https://buf.build/docs/reference/cli/buf/breaking#error-format",
),
},
toolchains = [_TOOLCHAIN],
test = True,
Expand Down
5 changes: 5 additions & 0 deletions buf/internal/lint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def _buf_lint_test_impl(ctx):
proto_infos = [t[ProtoInfo] for t in ctx.attr.targets]
config = json.encode({
"input_config": "" if ctx.file.config == None else ctx.file.config.short_path,
"error_format": ctx.attr.error_format,
})
files_to_include = []
if ctx.file.config != None:
Expand All @@ -53,6 +54,10 @@ buf_lint_test = rule(
allow_single_file = True,
doc = "The `buf.yaml` file",
),
"error_format": attr.string(
default = "",
doc = "error-format flag for buf lint: https://buf.build/docs/reference/cli/buf/lint#error-format",
),
},
toolchains = [_TOOLCHAIN],
test = True,
Expand Down
1 change: 1 addition & 0 deletions examples/single_module/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ buf_breaking_test(
# The Image file to check against.
against = "testdata/image.bin",
config = ":buf.yaml",
error_format = "json",
# The proto_library targets to include.
# Refer to the documentation for more on this: https://docs.buf.build/build-systems/bazel#buf-breaking-test
targets = [
Expand Down
1 change: 1 addition & 0 deletions examples/single_module/bar/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ buf_lint_test(
name = "bar_proto_lint",
config = "//:buf.yaml",
targets = [":bar_proto"],
error_format = "config-ignore-yaml",
)
2 changes: 1 addition & 1 deletion examples/single_module/foo/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ proto_library(
buf_lint_test(
name = "foo_proto_lint",
config = "//:buf.yaml",
targets = [":foo_proto"],
targets = [":foo_proto"],
)

0 comments on commit 210d451

Please sign in to comment.