diff --git a/.circleci/config.yml b/.circleci/config.yml index d8d0c51137..e62785641a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/.plzconfig b/.plzconfig index b7fff3b56a..8f5003cd0f 100644 --- a/.plzconfig +++ b/.plzconfig @@ -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 diff --git a/bootstrap.sh b/bootstrap.sh index ec82a6db17..0a2d5865ca 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -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" @@ -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 diff --git a/tools/misc/BUILD b/tools/misc/BUILD index 3a36e68a63..8325809ac3 100644 --- a/tools/misc/BUILD +++ b/tools/misc/BUILD @@ -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", +) diff --git a/tools/misc/buildify.sh b/tools/misc/buildify.sh new file mode 100644 index 0000000000..5c6597f151 --- /dev/null +++ b/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` diff --git a/tools/misc/ci_lint.py b/tools/misc/ci_lint.py index aad80b247a..254bb0f56d 100755 --- a/tools/misc/ci_lint.py +++ b/tools/misc/ci_lint.py @@ -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__':