Skip to content

Commit

Permalink
Exit with non-zero returncode on error.
Browse files Browse the repository at this point in the history
Signed-off-by: format 2020.01.21 <github.com/ChrisCummins/format>
  • Loading branch information
ChrisCummins committed Apr 2, 2020
1 parent 065bb09 commit 4b69fe9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions third_party/bazel/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@
# value for COMMIT_RANGE.
# When running in Travis-CI, you can directly use the $TRAVIS_COMMIT_RANGE
# environment variable.

COMMIT_RANGE=${COMMIT_RANGE:-$(git merge-base origin/master HEAD)".."}

# Go to the root of the repo
cd "$(git rev-parse --show-toplevel)"

returncode=0

# Get a list of the current files in package form by querying Bazel.
files=()
for file in $(git diff --name-only ${COMMIT_RANGE}); do
files+=($(bazel query $file))
echo $(bazel query $file)
query_files=$(bazel query --keep_going --noshow_progress $file)
returncode=$((returncode + $?))
echo "$query_files"
files+=($query_files)
done

# Query for the associated buildables
Expand All @@ -62,6 +65,7 @@ buildables=$(bazel query \
if [[ ! -z $buildables ]]; then
echo "Building binaries"
bazel build $buildables
returncode=$((returncode + $?))
fi

tests=$(bazel query \
Expand All @@ -72,4 +76,10 @@ tests=$(bazel query \
if [[ ! -z $tests ]]; then
echo "Running tests"
bazel test $TEST_ARGS $tests
returncode=$((returncode + $?))
fi

if [[ $returncode != 0 ]]; then
echo "There were errors" >&2
exit 1
fi

0 comments on commit 4b69fe9

Please sign in to comment.