From 66bed6779c64c13484769a489931cc325bedd9c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 21 Jun 2017 18:06:58 -0300 Subject: [PATCH 1/3] [ci] Improve Travis builds - use travis_wait for long running tasks with no output - enable fast-finish to abort all builds if one fails --- .travis.yml | 3 +++ .travis/background-job-funcs.sh | 43 --------------------------------- .travis/build-site.sh | 31 +++--------------------- .travis/build-sonar.sh | 14 +---------- 4 files changed, 7 insertions(+), 84 deletions(-) delete mode 100644 .travis/background-job-funcs.sh diff --git a/.travis.yml b/.travis.yml index 2de6aafd99..3ea0476e99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,9 @@ env: - BUILD=site - BUILD=sonar +matrix: + fast_finish: true + before_install: - bash .travis/setup-secrets.sh - bash .travis/configure-maven.sh diff --git a/.travis/background-job-funcs.sh b/.travis/background-job-funcs.sh deleted file mode 100644 index 5db6740207..0000000000 --- a/.travis/background-job-funcs.sh +++ /dev/null @@ -1,43 +0,0 @@ -# -# Helper functions to run a chatty, long task in the background, -# redirecting the output to file and keep travis happy by regularly -# writing to the log. -# -# This is to workaround the travis log length limit of 4MB -# Solution from http://stackoverflow.com/questions/26082444/how-to-work-around-travis-cis-4mb-output-limit/26082445#26082445 -# -# Source this file into the shell script, that needs it. -# -# expected variables -# Name | Example Value -# PING_SLEEP | 30s -# BUILD_OUTPUT | /tmp/build-step-logfile.out -# PING_PID_FILE | /tmp/build-step-ping.pid - -touch $BUILD_OUTPUT - -dump_output() { - echo Tailing the last 100 lines of output: - tail -100 $BUILD_OUTPUT -} -kill_ping() { - if [ -e $PING_PID_FILE ]; then - PING_LOOP_PID=$(cat $PING_PID_FILE) - kill $PING_LOOP_PID - rm $PING_PID_FILE - fi -} -error_handler() { - kill_ping - echo ERROR: An error was encountered with the build. - dump_output - exit 1 -} -# If an error occurs, run our error handler to output a tail of the build -trap 'error_handler' ERR - -# Set up a repeating loop to send some output to Travis. -bash -c "while true; do echo \$(date) - building ...; sleep $PING_SLEEP; done" & -PING_LOOP_PID=$! -echo "$PING_LOOP_PID" > $PING_PID_FILE - diff --git a/.travis/build-site.sh b/.travis/build-site.sh index c681625621..6443cc54d6 100644 --- a/.travis/build-site.sh +++ b/.travis/build-site.sh @@ -13,21 +13,9 @@ fi ( - export PING_SLEEP=30s - export BUILD_OUTPUT=/tmp/build-site.out - export PING_PID_FILE=/tmp/build-site-ping.pid - - source .travis/background-job-funcs.sh - # Run the build, redirect output into the file - ./mvnw install -DskipTests=true -B -V >> $BUILD_OUTPUT 2>&1 - ./mvnw site site:stage -Psite -B -V >> $BUILD_OUTPUT 2>&1 - - # The build finished without returning an error so dump a tail of the output - dump_output - - # nicely terminate the ping output loop - kill_ping + travis_wait ./mvnw install -DskipTests=true -B -V + travis_wait ./mvnw site site:stage -Psite -B -V ) # create pmd-doc archive @@ -44,20 +32,7 @@ fi ( if [[ "$VERSION" == *-SNAPSHOT && "$TRAVIS_BRANCH" == "master" ]]; then - # this can take very long and no output is generated. therefore use the background job again - export PING_SLEEP=30s - export BUILD_OUTPUT=/tmp/build-site-upload.out - export PING_PID_FILE=/tmp/build-site-upload-ping.pid - - source .travis/background-job-funcs.sh - # Uploading snapshot site... - rsync -ah --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ - - # The build finished without returning an error so dump a tail of the output - dump_output - - # nicely terminate the ping output loop - kill_ping + travis_wait rsync -ah --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ fi ) diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index 19ea2009fb..23a8a83fd2 100644 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -12,18 +12,6 @@ if ! travis_isPush; then fi -export PING_SLEEP=30s -export BUILD_OUTPUT=/tmp/build-sonar.out -export PING_PID_FILE=/tmp/build-sonar-ping.pid - -source .travis/background-job-funcs.sh - # Run the build, redirect output into the file -./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN} -B -V >> $BUILD_OUTPUT 2>&1 - -# The build finished without returning an error so dump a tail of the output -dump_output - -# nicely terminate the ping output loop -kill_ping +travis_wait ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN} -B -V From c9990a53cb454d42ba2b825b25b4d28ac0068457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Sat, 24 Jun 2017 17:28:40 -0300 Subject: [PATCH 2/3] Adopt feedback --- .travis.yml | 2 +- .travis/build-site.sh | 6 +++--- .travis/build-sonar.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ea0476e99..7835f0e612 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ before_install: - bash .travis/configure-maven.sh install: true before_script: true -script: bash .travis/build-$BUILD.sh +script: source .travis/build-$BUILD.sh after_success: true diff --git a/.travis/build-site.sh b/.travis/build-site.sh index 6443cc54d6..3d90ab0b6a 100644 --- a/.travis/build-site.sh +++ b/.travis/build-site.sh @@ -13,9 +13,9 @@ fi ( - # Run the build, redirect output into the file - travis_wait ./mvnw install -DskipTests=true -B -V - travis_wait ./mvnw site site:stage -Psite -B -V + # Run the build, truncate output due to Travis log limits + travis_wait ./mvnw install -DskipTests=true -B -V | tail -100 + travis_wait ./mvnw site site:stage -Psite -B -V | tail -100 ) # create pmd-doc archive diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index 23a8a83fd2..60b4003e23 100644 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -12,6 +12,6 @@ if ! travis_isPush; then fi -# Run the build, redirect output into the file -travis_wait ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN} -B -V +# Run the build, truncate output due to Travis log limits +travis_wait ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN} -B -V | tail -100 From 042672c8f5c012e2a418a11a9c162597cc7b4e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Sat, 24 Jun 2017 17:31:58 -0300 Subject: [PATCH 3/3] Add missing tail --- .travis/build-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build-site.sh b/.travis/build-site.sh index 3d90ab0b6a..5b34191d3f 100644 --- a/.travis/build-site.sh +++ b/.travis/build-site.sh @@ -33,6 +33,6 @@ fi ( if [[ "$VERSION" == *-SNAPSHOT && "$TRAVIS_BRANCH" == "master" ]]; then # Uploading snapshot site... - travis_wait rsync -ah --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ + travis_wait rsync -ah --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ | tail -100 fi )