Skip to content

Commit

Permalink
Improve linting aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
peterebden committed Jan 27, 2019
1 parent 40a5728 commit 5e7baf8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -21,7 +21,7 @@ jobs:
path: plz-out/results
- run:
name: Lint
command: ./tools/misc/ci_lint.py && plz-out/bin/src/please buildify --mode=check `git ls-files | grep BUILD`
command: plz-out/bin/src/please lint
- run:
name: Package
command: ./plz-out/bin/src/please build //package:all //tools/misc:gen_release --exclude asc -p
Expand Down
6 changes: 5 additions & 1 deletion .plzconfig
Expand Up @@ -52,7 +52,11 @@ positionallabels = true

[alias "buildify"]
desc = Runs buildifier, a BUILD file autoformatter.
cmd = run //src:please -p -- run -p //third_party/go:buildifier --
cmd = run //tools/misc:buildify -p -- --mode=fix

[alias "lint"]
desc = Runs the linters for this repo
cmd = run //tools/misc:lint -p --

[licences]
accept = MIT
Expand Down
12 changes: 2 additions & 10 deletions bootstrap.sh
Expand Up @@ -119,11 +119,6 @@ if ! hash java 2>/dev/null ; then
warn "Java not found, excluding Java tests"
EXCLUDES="${EXCLUDES} --exclude=java"
fi
# If the proto files are installed in a different location, their tests won't work.
if [ ! -d "/usr/include/google/protobuf" ]; then
warn "google/protobuf not found, excluding relevant tests"
EXCLUDES="${EXCLUDES} --exclude=proto"
fi
GCCVER="`cc -dumpversion`"
if [ ! -d "/usr/lib/gcc/x86_64-linux-gnu/${GCCVER%.*.*}/32" ] && [ ! -d "/usr/lib/gcc/x86_64-pc-linux-gnu/$GCCVER/32" ]; then
warn "32-bit gcc libraries not found, excluding cross-compile tests"
Expand All @@ -135,15 +130,12 @@ plz-out/bin/src/please $PLZ_ARGS ${PLZ_COVER:-test} $EXCLUDES --exclude=e2e --lo
# We run the end-to-end tests separately to ensure things don't fight with one another; they are
# finicky about some things due to running plz recursively and disabling the lock.
notice "Running end-to-end tests..."
plz-out/bin/src/please $PLZ_ARGS ${PLZ_COVER:-test} $EXCLUDES --include=e2e --log_file plz-out/log/test_build.log --log_file_level 4 --trace_file plz-out/log/trace.json $@
plz-out/bin/src/please $PLZ_ARGS ${PLZ_COVER:-test} $EXCLUDES --include=e2e --log_file plz-out/log/test_build.log --log_file_level 4 $@

# Lint needs python3.
if hash python3 2>/dev/null ; then
# Don't run this in CI or any unusual workflows.
if [ $# -eq 0 ] ; then
tools/misc/ci_lint.py
plz-out/bin/src/please buildify --mode=check `git ls-files | grep BUILD`
# If the above fails, then the fix is to run:
# plz-out/bin/src/please buildify --mode=fix `git ls-files | grep BUILD`
plz lint
fi
fi
10 changes: 10 additions & 0 deletions tools/misc/BUILD
Expand Up @@ -28,3 +28,13 @@ python_test(
srcs = ["gen_release_test.py"],
deps = [":gen_release"],
)

sh_binary(
name = "buildify",
main = "buildify.sh",
)

python_binary(
name = "lint",
main = "ci_lint.py",
)
2 changes: 2 additions & 0 deletions tools/misc/buildify.sh
@@ -0,0 +1,2 @@
#!/bin/sh
exec plz-out/bin/src/please run -p -- //third_party/go:buildifier $@ `git ls-files | grep BUILD`
6 changes: 6 additions & 0 deletions tools/misc/ci_lint.py
Expand Up @@ -71,6 +71,12 @@ def main():
linter.reset_line()
sys.exit('Some linters failed')
linter.reset_line()
# Run Buildifier
try:
subprocess.check_call(['plz-out/bin/src/please', 'run', '//tools/misc:buildify', '-p', '--', '--mode=check'],
stdout=sys.stdout, stderr=sys.stderr)
except subprocess.CalledProcessError:
sys.exit('Your BUILD files are not correctly formatted, run `plz buildify` to fix.')


if __name__ == '__main__':
Expand Down

0 comments on commit 5e7baf8

Please sign in to comment.