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

Support --error-format #45

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"],

Choose a reason for hiding this comment

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

nit: trailing whitespace.

)
Loading