From 430a6a2a306abd0c99391e678b3d061979c6fb41 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 5 May 2017 14:31:54 +0200 Subject: [PATCH] Use Trusty image on TravisCI - environment is more stable through time (no variations of build durations) - benefit from 8Gb ramdisk - enable parallel Maven build thanks to new CPUs --- .travis.yml | 5 +++-- .travis/setup_ramdisk.sh | 21 +++++++++++++++++++++ clock.sh | 14 -------------- scripts/setupRamdisk.sh | 21 +++++++++++++++++++++ travis.sh | 24 +++++++++++------------- 5 files changed, 56 insertions(+), 29 deletions(-) create mode 100755 .travis/setup_ramdisk.sh delete mode 100755 clock.sh create mode 100755 scripts/setupRamdisk.sh diff --git a/.travis.yml b/.travis.yml index 35d74c724cd..35df96cfde4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ -language: java -sudo: false +language: generic +sudo: required install: true jdk: oraclejdk8 script: ./travis.sh +dist: trusty env: - TARGET=BUILD diff --git a/.travis/setup_ramdisk.sh b/.travis/setup_ramdisk.sh new file mode 100755 index 00000000000..1ac8f5b158d --- /dev/null +++ b/.travis/setup_ramdisk.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail + +RED='\033[0;31m' +NC='\033[0m' # No Color +printf "${RED}SETUP RAMDISK${NC}\n" +printf "${RED}disk size before build${NC}\n" +df -h +du -sh $HOME + +printf "${RED}move original home${NC}\n" +sudo mv /home/travis /home/travis.ori +printf "${RED}create ramdisk mount point${NC}\n" +sudo mkdir -p /home/travis +printf "${RED}create ramdisk${NC}\n" +sudo mount -t tmpfs -o size=8192m tmps /home/travis +printf "${RED}copy home to ramdisk${NC}\n" +time sudo cp -R /home/travis.ori/. /home/travis +printf "${RED}give permissions to travis on its home in ramdisk${NC}\n" +sudo chown -R travis:travis /home/travis + diff --git a/clock.sh b/clock.sh deleted file mode 100755 index 91c2c5868b3..00000000000 --- a/clock.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -RED='\033[0;31m' -NC='\033[0m' # No Color - -echo "start the clock" -while [ ! -f stop ]; do - #echo "File not found!" - seconds=60; date1=$((`date +%s` + $seconds)); - while [ "$date1" -ge `date +%s` ]; do - #echo -ne "$(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r"; > /dev/null - : #busy wait - done - printf "${RED}############# `date` ############${NC}\n" -done \ No newline at end of file diff --git a/scripts/setupRamdisk.sh b/scripts/setupRamdisk.sh new file mode 100755 index 00000000000..1ac8f5b158d --- /dev/null +++ b/scripts/setupRamdisk.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail + +RED='\033[0;31m' +NC='\033[0m' # No Color +printf "${RED}SETUP RAMDISK${NC}\n" +printf "${RED}disk size before build${NC}\n" +df -h +du -sh $HOME + +printf "${RED}move original home${NC}\n" +sudo mv /home/travis /home/travis.ori +printf "${RED}create ramdisk mount point${NC}\n" +sudo mkdir -p /home/travis +printf "${RED}create ramdisk${NC}\n" +sudo mount -t tmpfs -o size=8192m tmps /home/travis +printf "${RED}copy home to ramdisk${NC}\n" +time sudo cp -R /home/travis.ori/. /home/travis +printf "${RED}give permissions to travis on its home in ramdisk${NC}\n" +sudo chown -R travis:travis /home/travis + diff --git a/travis.sh b/travis.sh index e76c29285ed..b317f298813 100755 --- a/travis.sh +++ b/travis.sh @@ -1,6 +1,8 @@ #!/bin/bash set -euo pipefail +./.travis/setup_ramdisk.sh + function installPhantomJs { echo "Setup PhantomJS 2.1" mkdir -p ~/phantomjs @@ -111,7 +113,7 @@ function fixBuildVersion { # Configure Maven settings and install some script utilities # function configureTravis { - mkdir ~/.local + mkdir -p ~/.local curl -sSL https://github.com/SonarSource/travis-utils/tarball/v36 | tar zx --strip-components 1 -C ~/.local source ~/.local/bin/install } @@ -126,17 +128,13 @@ case "$TARGET" in BUILD) - # Hack to keep job alive even if no logs during more than 10 minutes. - # That can occur when uploading sonarqube.zip to Artifactory. - ./clock.sh & - installJdk8 installMaven fixBuildVersion # Minimal Maven settings export MAVEN_OPTS="-Xmx1G -Xms128m" - MAVEN_ARGS="-Dmaven.test.redirectTestOutputToFile=false -Dsurefire.useFile=false -B -e -V -DbuildVersion=$BUILD_VERSION" + MAVEN_ARGS="-T 1C -Dmaven.test.redirectTestOutputToFile=false -Dsurefire.useFile=false -B -e -V -DbuildVersion=$BUILD_VERSION" if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo 'Build and analyze master' @@ -148,13 +146,15 @@ BUILD) # For this reason errors are ignored with "|| true" git fetch --unshallow || true - mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy sonar:sonar \ + mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \ $MAVEN_ARGS \ - -Pdeploy-sonarsource,release \ + -Pdeploy-sonarsource,release + mvn sonar:sonar \ -Dsonar.host.url=$SONAR_HOST_URL \ -Dsonar.login=$SONAR_TOKEN \ -Dsonar.projectVersion=$INITIAL_VERSION + elif [[ "$TRAVIS_BRANCH" == "branch-"* ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo 'Build release branch' @@ -163,10 +163,11 @@ BUILD) elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN:-}" ]; then echo 'Build and analyze internal pull request' - mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy sonar:sonar \ + mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \ $MAVEN_ARGS \ -Dsource.skip=true \ - -Pdeploy-sonarsource \ + -Pdeploy-sonarsource + mvn sonar:sonar \ -Dsonar.analysis.mode=preview \ -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \ -Dsonar.github.repository=$TRAVIS_REPO_SLUG \ @@ -198,6 +199,3 @@ WEB_TESTS) ;; esac - -#stop the clock -touch stop -- 2.39.5