Buildifier fixes (#87)
* fix typo * Handing buildifier exit status better. buildifier started reporting an error for lint issue, update the script to not stop because of that.
This commit is contained in:
parent
4795fd6146
commit
6dd0b9cbd6
|
@ -13,7 +13,7 @@ matrix:
|
|||
- os: linux
|
||||
dist: trusty
|
||||
sudo: false
|
||||
env: BUILDIFER=RELEASE
|
||||
env: BUILDIFIER=RELEASE
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# macOS hosted tests
|
||||
|
@ -21,7 +21,7 @@ matrix:
|
|||
- os: osx
|
||||
osx_image: xcode10.1
|
||||
env: BAZEL=HEAD
|
||||
# No need for a BUILDIFER run on mac, the results will be the same.
|
||||
# No need for a BUILDIFIER run on mac, the results will be the same.
|
||||
# And linux boxes test faster on travis, so just use the one.
|
||||
|
||||
before_install:
|
||||
|
|
|
@ -24,7 +24,7 @@ fi
|
|||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Asked to do a buildifier run.
|
||||
if [[ -n "${BUILDIFER:-}" ]]; then
|
||||
if [[ -n "${BUILDIFIER:-}" ]]; then
|
||||
FOUND_ISSUES="no"
|
||||
|
||||
# buildifier supports BUILD/WORKSPACE/*.bzl files, this provides the args
|
||||
|
@ -61,14 +61,18 @@ if [[ -n "${BUILDIFER:-}" ]]; then
|
|||
|
||||
# Check for lint issues?
|
||||
if [[ "${LINT:-yes}" == "yes" ]] ; then
|
||||
LINT_ISSUES=$(find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn 2>&1)
|
||||
if [[ -n "${LINT_ISSUES}" ]] ; then
|
||||
# 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 ""
|
||||
echo "${LINT_ISSUES}"
|
||||
# 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
|
||||
echo ""
|
||||
echo "Please download the latest buildifier"
|
||||
echo " https://github.com/bazelbuild/buildtools/releases"
|
||||
|
|
|
@ -85,7 +85,7 @@ function install_buildifier() {
|
|||
fi
|
||||
|
||||
if [[ "${VERSION}" == "HEAD" ]]; then
|
||||
echo "buildifer head is not supported"
|
||||
echo "buildifier head is not supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -104,4 +104,4 @@ function install_buildifier() {
|
|||
# -------------------------------------------------------------------------------------------------
|
||||
# Install what is requested.
|
||||
[[ -z "${BAZEL:-}" ]] || install_bazel "${BAZEL}"
|
||||
[[ -z "${BUILDIFER:-}" ]] || install_buildifier "${BUILDIFER}"
|
||||
[[ -z "${BUILDIFIER:-}" ]] || install_buildifier "${BUILDIFIER}"
|
||||
|
|
Loading…
Reference in New Issue