From 111f5e5a0d18be556060fb4f91a89505f9116ff7 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Sat, 5 Dec 2015 04:10:46 -0500 Subject: [PATCH] Fix travis_fastfail.sh for null case when an old PR build gets restarted after some time, the travis API request might not return enough builds to include the most recent one for the PR, so the null result would incorrectly cause a 'superceded' fast-fail condition --- contrib/travis_fastfail.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/travis_fastfail.sh b/contrib/travis_fastfail.sh index 8d692c430653b..6eb349a49b1ff 100755 --- a/contrib/travis_fastfail.sh +++ b/contrib/travis_fastfail.sh @@ -5,9 +5,10 @@ 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 "$curlhdr" $endpoint/builds?event_type=pull_request | \ - jq ".builds | map(select(.pull_request_number == $TRAVIS_PULL_REQUEST))[0].number") ]; then +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + newestbuildforthisPR=$(curl -H "$curlhdr" $endpoint/builds?event_type=pull_request | \ + jq ".builds | map(select(.pull_request_number == $TRAVIS_PULL_REQUEST))[0].number") + if [ $newestbuildforthisPR != null -a $newestbuildforthisPR != \"$TRAVIS_BUILD_NUMBER\" ]; then echo "There are newer queued builds for this pull request, failing early." exit 1 fi @@ -17,7 +18,7 @@ else master | release*) ;; *) - if ! [ \"$TRAVIS_BUILD_NUMBER\" = $(curl -H "$curlhdr" \ + 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