Skip to content

Commit

Permalink
repo: Add buf linting
Browse files Browse the repository at this point in the history
initially just for unused imports

Fix #45

Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax committed Jun 24, 2022
1 parent 1e77728 commit 1d99ad3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ def xds_api_dependencies():
"bazel_gazelle",
locations = REPOSITORY_LOCATIONS,
)
xds_http_archive(
"com_github_bufbuild_buf",
locations = REPOSITORY_LOCATIONS,
build_file_content = BUF_BUILD_CONTENT,
tags = ["manual"],
)
xds_http_archive(
"com_envoyproxy_protoc_gen_validate",
locations = REPOSITORY_LOCATIONS,
Expand All @@ -31,3 +37,16 @@ def xds_api_dependencies():
# TODO(roth): Remove once all callers are updated to use the new name.
def udpa_api_dependencies():
xds_api_dependencies()

BUF_BUILD_CONTENT = """
package(
default_visibility = ["//visibility:public"],
)
filegroup(
name = "buf",
srcs = [
"@com_github_bufbuild_buf//:bin/buf",
],
)
"""
5 changes: 5 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ REPOSITORY_LOCATIONS = dict(
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
urls = ["https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz"],
),
com_github_bufbuild_buf = dict(
sha256 = "826ad701db09805eb425723ad3ea0c13ce7ca8353d6a1fb473399db915dafdf9",
strip_prefix = "buf",
urls = ["https://github.com/bufbuild/buf/releases/download/v1.4.0/buf-Linux-x86_64.tar.gz"],
),
com_envoyproxy_protoc_gen_validate = dict(
sha256 = "c695fc5a2e5a1b52904cd8a58ce7a1c3a80f7f50719496fd606e551685c01101",
strip_prefix = "protoc-gen-validate-0.6.1",
Expand Down
15 changes: 15 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: dc09a417d27241f7b069feae2cd74a0e
- remote: buf.build
owner: gogo
repository: protobuf
commit: 4df00b267f944190a229ce3695781e99
- remote: buf.build
owner: googleapis
repository: googleapis
commit: d1a849b8f8304950832335723096e954
8 changes: 8 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: v1
deps:
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/googleapis/googleapis:d1a849b8f8304950832335723096e954
- buf.build/gogo/protobuf
lint:
use:
- IMPORT_USED
3 changes: 3 additions & 0 deletions ci/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

set -e

bazel run @com_github_bufbuild_buf//:bin/buf lint -- --path xds
bazel run @com_github_bufbuild_buf//:bin/buf lint -- --path udpa

bazel test --config=ci //...

rm -rf go/xds go/udpa
Expand Down

0 comments on commit 1d99ad3

Please sign in to comment.