From a5655124382ccbf7214456468cec6b7ec2e39c41 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Wed, 20 Feb 2019 14:57:59 -0500 Subject: [PATCH] CI simplification/improvements for buildifier (#113) * buildifier 0.22.0 includes files names in diffs. * Simplify buildifier runs even more. Since exit status are more consistently set and output is generally better, don't bother being as fancy and just print a simple line as lead in incase issues are found, and use the exit status to print directions on what to do if something comes up. --- .travis_build.sh | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/.travis_build.sh b/.travis_build.sh index 706a054..f160280 100755 --- a/.travis_build.sh +++ b/.travis_build.sh @@ -41,43 +41,30 @@ if [[ -n "${BUILDIFIER:-}" ]]; then # Check for format issues? if [[ "${FORMAT:-yes}" == "yes" ]] ; then - # bazelbuild/buildtools/issues/220 - diff doesn't include the file that needs updating - 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 . "${FIND_ARGS[@]}" -print -exec buildifier -v -d {} \; \ - 2>&1 | sed -E -e '/^exit status 1$/d' + echo "buildifier: validating formatting..." + if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier -d ; then echo "" echo "Please download the latest buildifier" echo " https://github.com/bazelbuild/buildtools/releases" echo "and run it over the changed BUILD/.bzl files." + echo "" FOUND_ISSUES="yes" fi fi # Check for lint issues? if [[ "${LINT:-yes}" == "yes" ]] ; then + echo "buildifier: running lint checks..." # NOTE: buildifier defaults to --mode=fix, so these lint runs also # reformat the files. But since this is on travis, that is fine. # https://github.com/bazelbuild/buildtools/issues/453 - if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn > /dev/null 2>&1 ; then - if [[ "${FOUND_ISSUES}" != "no" ]] ; then - echo "" - fi - echo "ERROR: BUILD/.bzl lint issue(s):" - echo "" - # buildifier now exits with error if there are issues, so use `|| true` - # to keep the script running. - find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn || true + if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn ; then echo "" echo "Please download the latest buildifier" echo " https://github.com/bazelbuild/buildtools/releases" echo "and run it with --lint=(warn|fix) over the changed BUILD/.bzl files" echo "and make the edits as needed." + echo "" FOUND_ISSUES="yes" fi fi