From 3410d25e37820e8936acc3fc1a444069dc415524 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 23 Dec 2014 15:54:18 -0800 Subject: Towards travis-style CI Move script to the repo it acts on, out of scala/jenkins-scripts Had to make some changes: - scala checkout is now in root ($WORKSPACE) - credentials are actually in homedir (sonatype/private-repo) - inline pr-scala-common - don't run tests for actors-migration due to timeout (TODO: revert?) --- scripts/pr-scala-common | 260 ------------------------------------------------ 1 file changed, 260 deletions(-) delete mode 100755 scripts/pr-scala-common (limited to 'scripts/pr-scala-common') diff --git a/scripts/pr-scala-common b/scripts/pr-scala-common deleted file mode 100755 index 01112588f7..0000000000 --- a/scripts/pr-scala-common +++ /dev/null @@ -1,260 +0,0 @@ -# This is for forcibly stopping the job from a subshell (see test -# below). -trap "exit 1" TERM -export TOP_PID=$$ -set -e - -# Known problems : does not fare well with interrupted, partial -# compilations. We should perhaps have a multi-dependency version -# of do_i_have below - -BASEDIR="$(pwd)" - -LOGGINGDIR="$BASEDIR/logs" -mkdir -p $LOGGINGDIR - -unset SBT_HOME -SBT_HOME="$BASEDIR/.sbt" -mkdir -p $SBT_HOME -IVY_CACHE="$BASEDIR/.ivy2" -mkdir -p $IVY_CACHE -rm -rf $IVY_CACHE/cache/org.scala-lang - -# temp dir where all 'non-build' operation are performed -TMP_ROOT_DIR=$(mktemp -d -t pr-scala.XXXX) -TMP_DIR="${TMP_ROOT_DIR}/tmp" -mkdir "${TMP_DIR}" - - -# detect sed version and how to enable extended regexes -SEDARGS="-n$(if (echo "a" | sed -nE "s/a/b/" &> /dev/null); then echo E; else echo r; fi)" - - -# :docstring getOrUpdate: -# Usage : getOrUpdate -# -# Updates or clones the checkout of taken from the -# git repo at into the local directory -# and cleans the checkout. -# -# :end docstring: - -function getOrUpdate(){ - if [ ! -d $1 ]; then - git clone --depth 1 $2 - fi - pushd $1 - - git fetch $2 $3 - - git checkout -q FETCH_HEAD - - git reset --hard FETCH_HEAD - - git clean -fxd - - git log --oneline -1 - - git status - - popd -} - - -# :docstring parse_properties: -# Usage: parse_properties javaPropertyFile -# Exports variables set in property file under $BASEDIR, mangling names by replacing dots with _ -# :end docstring: - -function parse_properties(){ - propFile="$BASEDIR/$1" - if [ ! -f $propFile ]; then - say "Property file $propFile not found." - exit 1 - else - awk -f "$scriptsDir/readproperties.awk" "$propFile" > "$propFile.sh" - . "$propFile.sh" # yeah yeah, not that secure, improvements welcome (I tried, but bash made me cry again) - fi -} - - -# :docstring test: -# Usage: test -# Executes , logging the launch of the command to the -# main log file, and kills global script execution with the TERM -# signal if the commands ends up failing. -# DO NOT USE ON FUNCTIONS THAT DECLARE VARIABLES, -# AS YOU'LL BE RUNNING IN A SUBSHELL AND VARIABLE DECLARATIONS WILL BE LOST -# :end docstring: - -function test() { - echo "### $@" - "$@" - status=$? - if [ $status -ne 0 ]; then - say "### ERROR with $1" - kill -s TERM $TOP_PID - fi -} - -# :docstring say: -# Usage: say -# Prints to both console and the main log file. -# :end docstring: - -function say(){ - (echo "$@") | tee -a $LOGGINGDIR/compilation-$SCALADATE-$SCALAHASH.log -} - -# General debug logging -# $* - message -function debug () { - echo "----- $*" -} - - -## TAKEN FROM UBER-BUILD, except that it "returns" (via $RES) true/false -# Check if an artifact is available -# $1 - groupId -# $2 - artifacId -# $3 - version -# $4 - extra repository to look in (optional) -# return value in $RES -function checkAvailability () { - cd "${TMP_DIR}" - rm -rf * - -# pom file for the test project - cat > pom.xml << EOF - - 4.0.0 - com.typesafe - typesafeDummy - war - 1.0-SNAPSHOT - Dummy - http://127.0.0.1 - - - $1 - $2 - $3 - - - - - sonatype.snapshot - Sonatype maven snapshot repository - https://oss.sonatype.org/content/repositories/snapshots - - daily - - -EOF - - if [ -n "$4" ] - then -# adds the extra repository - cat >> pom.xml << EOF - - extrarepo - extra repository - $4 - -EOF - fi - - cat >> pom.xml << EOF - - -EOF - - set +e - mvn "${MAVEN_ARGS[@]}" compile &> "${TMP_DIR}/mvn.log" - RES=$? - # Quiet the maven, but allow diagnosing problems. - grep -i downloading "${TMP_DIR}/mvn.log" - grep -i exception "${TMP_DIR}/mvn.log" - grep -i error "${TMP_DIR}/mvn.log" - set -e - -# log the result - if [ ${RES} == 0 ] - then - debug "$1:$2:jar:$3 found !" - RES=true - else - debug "$1:$2:jar:$3 not found !" - RES=false - fi -} - - -# :docstring preparesbt: -# Usage: preparesbt -# This lets sbt know to look for the local maven repository. -# :end docstring: - -# don't share any caches, sbt dirs, repos,... to avoid concurrent writes -# keep them local to the workspace also lets us diagnose problems more easily -# Make sure this is an absolute path with preceding '/' -LOCAL_M2_REPO="$BASEDIR/m2repo" -GENMVNOPTS="-e -B -X -Dmaven.repo.local=${LOCAL_M2_REPO}" -# otherwise this just keeps growing and growing due to the -$sha-SNAPSHOT approach -[[ -d "$LOCAL_M2_REPO"/org/scala-lang ]] && rm -rf "$LOCAL_M2_REPO"/org/scala-lang - -function preparesbt(){ - # Am I using sbt-extras? I.e., do we need to use -sbt-dir? - set +e - sbt -h 2>&1 | grep -qe "-sbt-dir" - sbt_extraed=$? - set -e - export DEST_REPO_FILE=$SBT_HOME/repositories - if [ $sbt_extraed -eq 0 ]; then - # sbt-extras does not honor an explicit -Dsbt.global.base - export SBT_ARGS="-verbose -debug -no-colors -sbt-dir $SBT_HOME -ivy $IVY_CACHE" - say "### sbt-extras detected, using args $SBT_ARGS" - else - # don't pass -verbose or -debug, they tend to break sbt... - export SBT_ARGS="-Dsbt.global.base=$SBT_HOME -Dsbt.ivy.home=$IVY_CACHE" - say "### vanilla sbt detected, using args $SBT_ARGS" - fi - - if [ -f $DEST_REPO_FILE ]; then - export OLD_SBT_REPO_FILE=$(mktemp -t sbtreposXXX) - cat $DEST_REPO_FILE > $OLD_SBT_REPO_FILE - fi - cat > $DEST_REPO_FILE <