Skip to content

Commit

Permalink
Add fast fail for branch builds too
Browse files Browse the repository at this point in the history
[av skip]
  • Loading branch information
tkelman committed Jul 30, 2015
1 parent 4d2db56 commit 97a269e
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions contrib/travis_fastfail.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
#!/bin/sh

curlhdr="Accept: application/vnd.travis-ci.2+json"
endpoint="https://api.travis-ci.org/repos/$TRAVIS_REPO_SLUG"

# Fail fast for superseded builds to PR's
if ! [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
if ! [ \"$TRAVIS_BUILD_NUMBER\" = $(curl -H "Accept: application/vnd.travis-ci.2+json" \
https://api.travis-ci.org/repos/JuliaLang/julia/builds?event_type=pull_request | \
jq ".builds | map(select(.pull_request_number == $TRAVIS_PULL_REQUEST))[0].number") ]; then
echo "There are newer queued builds for this pull request, failing early."
exit 1
fi
if ! [ \"$TRAVIS_BUILD_NUMBER\" = $(curl -H "$curlhdr" $endpoint/builds?event_type=pull_request | \
jq ".builds | map(select(.pull_request_number == $TRAVIS_PULL_REQUEST))[0].number") ]; then
echo "There are newer queued builds for this pull request, failing early."
exit 1
fi
fi

# And for non-latest push builds in branches other than master or release*
case $TRAVIS_BRANCH in
master | release*)
;;
*)
if ! [ \"$TRAVIS_BUILD_NUMBER\" = $(curl -H "$curlhdr" \
$endpoint/branches/$TRAVIS_BRANCH | jq ".branch.number") ]; then
echo "There are newer queued builds for this branch, failing early."
exit 1
fi
;;
esac

0 comments on commit 97a269e

Please sign in to comment.