Skip to content

Commit

Permalink
pw_presubmit: Run bazel_lint on the WORKSPACE file
Browse files Browse the repository at this point in the history
Fix the lint failure this revealed.

Also remove the buildifier targets. They are obsolete because we run
buildifier through the bazel_lint presubmit program.

Change-Id: I32fb1638295bd994d623e04d119a000042aa538c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/106072
Reviewed-by: Rob Mohr <[email protected]>
Commit-Queue: Ted Pudlik <[email protected]>
  • Loading branch information
tpudlik authored and CQ Bot Account committed Aug 12, 2022
1 parent 61d60d3 commit 400c0f3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 56 deletions.
41 changes: 0 additions & 41 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,9 @@
# License for the specific language governing permissions and limitations under
# the License.

load(
"@com_github_bazelbuild_buildtools//buildifier:def.bzl",
"buildifier",
"buildifier_test",
)

licenses(["notice"])

exports_files(
["tsconfig.json"],
visibility = [":__subpackages__"],
)

# Fix all Bazel relevant files.
buildifier(
name = "buildifier",
# Ignore gn and CIPD outputs in formatting.
# NOTE: These globs are not Bazel native and are passed directly
# through to the buildifier binary.
# TODO: Remove these globs when
# https://github.com/bazelbuild/buildtools/issues/623 is addressed.
exclude_patterns = [
"./.environment/**/*",
"./.presubmit/**/*",
"./.out/**/*",
],
)

# Test to ensure all Bazel build files are properly formatted.
buildifier_test(
name = "buildifier_test",
srcs = glob(
[
"**/*.bazel",
"**/*.bzl",
"**/*.oss",
"**/*.sky",
"**/BUILD",
],
# Node modules do not play nice with buildifier. Exclude these
# generated Bazel files from format testing.
exclude = ["**/node_modules/**/*"],
) + ["WORKSPACE"],
diff_command = "diff -u",
mode = "diff",
verbose = True,
)
14 changes: 0 additions & 14 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ git_repository(
remote = "https://github.com/bazelbuild/stardoc.git",
)

# Set up Protobuf rules.
# Required by: pigweed, com_github_bazelbuild_buildtools.
# Used in modules: //pw_protobuf.
http_archive(
name = "com_google_protobuf",
sha256 = "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db",
strip_prefix = "protobuf-3.17.3",
url = "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz",
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# Set up tools to build custom GRPC rules.
# Required by: pigweed.
# Used in modules: //pw_protobuf.
Expand Down
4 changes: 3 additions & 1 deletion pw_presubmit/py/pw_presubmit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from pw_presubmit import (
call,
Check,
FileFilter,
filter_paths,
format_code,
log_run,
Expand Down Expand Up @@ -355,7 +356,8 @@ def test_server(executable: str, output_dir: Path):
proc.terminate()


@filter_paths(endswith=('.bzl', '.bazel'))
@filter_paths(file_filter=FileFilter(endswith=('.bzl', '.bazel'),
name=('WORKSPACE', )))
def bazel_lint(ctx: PresubmitContext):
"""Runs buildifier with lint on Bazel files.
Expand Down

0 comments on commit 400c0f3

Please sign in to comment.