From d9cd300c642d447e6c4cde7f9900f53b6cd01330 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 27 Nov 2018 07:55:22 -0500 Subject: [PATCH] Add WORKSPACE to the things checked by buildifier. (#79) Move the find args into a shell variable to simplify things. --- .travis_build.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.travis_build.sh b/.travis_build.sh index 644d355..3c4525d 100755 --- a/.travis_build.sh +++ b/.travis_build.sh @@ -27,17 +27,29 @@ fi if [[ -n "${BUILDIFER:-}" ]]; then FOUND_ISSUES="no" + # buildifier supports BUILD/WORKSPACE/*.bzl files, this provides the args + # to reuse in all the finds. + FIND_ARGS=( + \( + -name BUILD + -o + -name WORKSPACE + -o + -name "*.bzl" + \) + ) + # Check for format issues? if [[ "${FORMAT:-yes}" == "yes" ]] ; then # bazelbuild/buildtools/issues/220 - diff doesn't include the file that needs updating - if ! find . \( -name BUILD -o -name "*.bzl" \) -print | xargs buildifier -d > /dev/null 2>&1 ; then + if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier -d > /dev/null 2>&1 ; then if [[ "${FOUND_ISSUES}" != "no" ]] ; then echo "" fi echo "ERROR: BUILD/.bzl file formatting issue(s):" echo "" # bazelbuild/buildtools/issues/329 - sed out the exit status lines. - find . \( -name BUILD -o -name "*.bzl" \) -print -exec buildifier -v -d {} \; \ + find . "${FIND_ARGS[@]}" -print -exec buildifier -v -d {} \; \ 2>&1 | sed -E -e '/^exit status 1$/d' echo "" echo "Please download the latest buildifier" @@ -49,7 +61,7 @@ if [[ -n "${BUILDIFER:-}" ]]; then # Check for lint issues? if [[ "${LINT:-yes}" == "yes" ]] ; then - LINT_ISSUES=$(find . \( -name BUILD -o -name "*.bzl" \) -print | xargs buildifier --lint=warn 2>&1) + LINT_ISSUES=$(find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn 2>&1) if [[ -n "${LINT_ISSUES}" ]] ; then if [[ "${FOUND_ISSUES}" != "no" ]] ; then echo ""