From c5f8c9586ff188ed7d13ae8e95245b7a972bb4a7 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 27 Jul 2015 17:00:01 -0700 Subject: [PATCH] chore: added presubmit-queue to travis --- .travis.yml | 12 ++++++-- scripts/ci/after-script.sh | 28 +++++++++++++++++ scripts/ci/presubmit-queue-setup.sh | 20 ++++++++++++ scripts/ci/presubmit-queue-success.sh | 44 +++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 3 deletions(-) create mode 100755 scripts/ci/after-script.sh create mode 100755 scripts/ci/presubmit-queue-setup.sh create mode 100755 scripts/ci/presubmit-queue-success.sh diff --git a/.travis.yml b/.travis.yml index fe78fec7e4..1fafc73082 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,14 +27,18 @@ env: # This SSO token belongs to github account angular-github-ratelimit-token which has no access # (password is in Valentine) - TSDRC='{"token":"ef474500309daea53d5991b3079159a29520a40b"}' + # GITHUB_TOKEN_ANGULAR + - secure: "fq/U7VDMWO8O8SnAQkdbkoSe2X92PVqg4d044HmRYVmcf6YbO48+xeGJ8yOk0pCBwl3ISO4Q2ot0x546kxfiYBuHkZetlngZxZCtQiFT9kyId8ZKcYdXaIW9OVdw3Gh3tQyUwDucfkVhqcs52D6NZjyE2aWZ4/d1V4kWRO/LMgo=" matrix: - - MODE=js DART_CHANNEL=dev + # Make slowest build on top, so that we don't hog VMs while waiting for others to complete. - MODE=dart DART_CHANNEL=stable - MODE=dart DART_CHANNEL=dev - MODE=dart_experimental DART_CHANNEL=dev - - MODE=saucelabs DART_CHANNEL=dev + - MODE=js DART_CHANNEL=dev + # Dissabled until we can make it pass. + # - MODE=saucelabs DART_CHANNEL=dev -matrix: +matrix: allow_failures: - env: "MODE=saucelabs DART_CHANNEL=dev" @@ -61,12 +65,14 @@ install: before_script: - mkdir -p $LOGS_DIR +- ./scripts/ci/presubmit-queue-setup.sh script: - ./scripts/ci/build_and_test.sh ${MODE} after_script: - ./scripts/ci/print-logs.sh +- ./scripts/ci/after-script.sh notifications: webhooks: diff --git a/scripts/ci/after-script.sh b/scripts/ci/after-script.sh new file mode 100755 index 0000000000..caa8b2a85a --- /dev/null +++ b/scripts/ci/after-script.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e -o pipefail + +echo '*******************' +echo '** AFTER_SUCCESS **' +echo '*******************' + + +echo '---------------------' +echo '-- WAIT FOR OTHERS --' +echo '---------------------' + +curl -Lo travis_after_all.py https://raw.github.com/jbdeboer/travis_after_all/master/travis_after_all.py +python travis_after_all.py +. .to_export_back + +echo BUILD_LEADER=$BUILD_LEADER +echo BUILD_AGGREGATE_STATUS=$BUILD_AGGREGATE_STATUS + +if [ "$BUILD_LEADER" = "YES" ]; then + if [ "$BUILD_AGGREGATE_STATUS" = "others_succeeded" ]; then + ./scripts/ci/presubmit-queue-success.sh + else + echo "ERROR: Some Failed, not submitting" + fi +else + echo "ERROR: Other builds have not finished, not submitting" +fi diff --git a/scripts/ci/presubmit-queue-setup.sh b/scripts/ci/presubmit-queue-setup.sh new file mode 100755 index 0000000000..dd07a3cc48 --- /dev/null +++ b/scripts/ci/presubmit-queue-setup.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e -o pipefail + +if [ "$TRAVIS_REPO_SLUG" = "angular/angular" ]; then + if [[ $TRAVIS_BRANCH == "presubmit-"* ]]; then + + echo '*********************' + echo '** PRESUBMIT SETUP **' + echo '*********************' + + git config credential.helper "store --file=.git/credentials" + # travis encrypt GITHUB_TOKEN_ANGULAR=??? --repo=angular/angular + echo "https://${GITHUB_TOKEN_ANGULAR}:@github.com" > .git/credentials + git config user.name "travis@travis-ci.org" + + git remote add upstream https://github.com/angular/angular.git + git fetch upstream master + git rebase upstream/master + fi +fi diff --git a/scripts/ci/presubmit-queue-success.sh b/scripts/ci/presubmit-queue-success.sh new file mode 100755 index 0000000000..2fedbd2d0f --- /dev/null +++ b/scripts/ci/presubmit-queue-success.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -e -o pipefail + +# If we're on the presubmit branch, the dev Dart release, and all unit +# tests pass, merge the presubmit branch into master and push it. + + +CHANNEL=`echo $JOB | cut -f 2 -d -` +SHA=`git rev-parse HEAD` + +echo Current channel is: $CHANNEL +echo Current branch is: $TRAVIS_BRANCH +echo Test result is: $TRAVIS_TEST_RESULT + +if [ "$TRAVIS_REPO_SLUG" = "angular/angular" ]; then + if [ $TRAVIS_TEST_RESULT -eq 0 ] && [[ $TRAVIS_BRANCH == "presubmit-"* ]]; then + echo '***************' + echo '** PRESUBMIT **' + echo '***************' + echo + echo "Pushing HEAD to master..." + git stash + git fetch upstream master + git rebase upstream/master + if git push upstream HEAD:master; then + echo "$TRAVIS_BRANCH has been merged into master, deleting..." + git push upstream :"$TRAVIS_BRANCH" + else + COMITTER_EMAIL=`git --no-pager show -s --format='%cE' HEAD` + echo Sending failure email to ${COMITTER_EMAIL} + mail \ + -s "Failed to merge branch $TRAVIS_BRANCH to master" \ + ${COMMITTER_EMAIL} \ + << EOM +Your travis branch ${TRAVIS_BRANCH} failed! + +https://travis-ci.org/angular/angular/builds/${TRAVIS_JOB_ID} + +Please take a look. +EOM + fi + fi +fi +`