88 # <username>jenkinside</username>
99 # <password></password>
1010 # </server>
11- # - ~/.ivy2/. credentials (for sonatype)
11+ # - ~/.credentials (for sonatype)
1212 # realm=Sonatype Nexus Repository Manager
1313 # host=oss.sonatype.org
1414 # user=lamp
1515 # password=
16- # - ~/.ivy2/. credentials-private-repo for private-repo.typesafe.com, as follows:
16+ # - ~/.credentials-private-repo for private-repo.typesafe.com, as follows:
1717 # realm=Artifactory Realm
1818 # host=private-repo.typesafe.com
1919 # user=jenkinside
4646# Rebuild modules with this Scala build, and stage them on sonatype as well
4747# This script can be run in multiple modes. It is design to work without any input,
4848# so that it could be run in Travis CI. In that mode, it'll build a release when
49- # the current HEAD of $SCALA_REF is tagged, and stage to sonatype. Otherwise,
49+ # the current HEAD of the checkout in $WORKSPACE is tagged, and stage to sonatype. Otherwise,
5050# it'll build a nightly.
5151#
5252# Since the nightlies are intended to be a drop in replacement, all modules are built with the
5656# The other way to trigger a release is by setting the SCALA_VER_BASE env var.
5757#
5858# By default, we build the versions of the modules as specified by versions.properties
59- # (as specified in the $SCALA_REF commit). Set moduleVersioning to something random
59+ # (as specified in the HEAD commit). Set moduleVersioning to something random
6060# to trigger building HEAD of each module, generating a fresh -$(git describe)-nightly version for each.
6161#
6262# PS: set publishToSonatype to anything but "yes" to avoid publishing to sonatype
63- # (publishing only done when $SCALA_REF 's HEAD is tagged / SCALA_VER_BASE is set.)
63+ # (publishing only done when $WORKSPACE checkout 's HEAD is tagged / SCALA_VER_BASE is set.)
6464
65- SCALA_REF=${SCALA_REF-" 2.11.x" }
6665
6766# set to something besides the default to build nightly snapshots of the modules instead of some tagged version
6867moduleVersioning=${moduleVersioning-" versions.properties" }
6968
70- baseDir=${baseDir -`pwd`}
69+ baseDir=${WORKSPACE -`pwd`}
7170publishPrivateTask=${publishPrivateTask-" publish" }
7271publishSonatypeTaskCore=${publishSonatypeTaskCore-" publish-signed" }
7372publishSonatypeTaskModules=${publishSonatypeTaskModules-" publish-signed" }
@@ -86,12 +85,70 @@ forceRebuild=${forceRebuild-no}
8685# overridden to "no" when no SCALA_VER_BASE is passed and HEAD is not tagged with a valid version tag
8786#
8887
89- antBuildTask=" ${antBuildTask-nightly} " # TESTING leave empty to avoid the sanity check
88+ antBuildTask=" ${antBuildTask-nightly} " # TESTING leave empty to avoid the sanity check (don't set it to "init" because ant will croak)
9089clean=" clean" # TESTING leave empty to speed up testing
9190
92- scriptsDir=" $( cd " $( dirname " $0 " ) /.." && pwd ) "
93- . $scriptsDir /common
94- . $scriptsDir /pr-scala-common
91+ scriptsDir=" $WORKSPACE /scripts"
92+
93+ # This is for forcibly stopping the job from a subshell (see test
94+ # below).
95+ trap " exit 1" TERM
96+ export TOP_PID=$$
97+ set -e
98+
99+ # Known problems : does not fare well with interrupted, partial
100+ # compilations. We should perhaps have a multi-dependency version
101+ # of do_i_have below
102+
103+ LOGGINGDIR=" $WORKSPACE /logs"
104+ mkdir -p $LOGGINGDIR
105+
106+ unset SBT_HOME
107+ SBT_HOME=" $WORKSPACE /.sbt"
108+ mkdir -p $SBT_HOME
109+ IVY_CACHE=" $WORKSPACE /.ivy2"
110+ mkdir -p $IVY_CACHE
111+ rm -rf $IVY_CACHE /cache/org.scala-lang
112+
113+ # temp dir where all 'non-build' operation are performed
114+ TMP_ROOT_DIR=$( mktemp -d -t pr-scala.XXXX)
115+ TMP_DIR=" ${TMP_ROOT_DIR} /tmp"
116+ mkdir " ${TMP_DIR} "
117+
118+
119+ # detect sed version and how to enable extended regexes
120+ SEDARGS=" -n$( if (echo " a" | sed -nE " s/a/b/" & > /dev/null); then echo E; else echo r; fi) "
121+
122+
123+
124+ # :docstring test:
125+ # Usage: test <argument ..>
126+ # Executes <argument ..>, logging the launch of the command to the
127+ # main log file, and kills global script execution with the TERM
128+ # signal if the commands ends up failing.
129+ # DO NOT USE ON FUNCTIONS THAT DECLARE VARIABLES,
130+ # AS YOU'LL BE RUNNING IN A SUBSHELL AND VARIABLE DECLARATIONS WILL BE LOST
131+ # :end docstring:
132+
133+ function test() {
134+ echo " ### $@ "
135+ " $@ "
136+ status=$?
137+ if [ $status -ne 0 ]; then
138+ say " ### ERROR with $1 "
139+ kill -s TERM $TOP_PID
140+ fi
141+ }
142+
143+ # :docstring say:
144+ # Usage: say <argument ..>
145+ # Prints <argument ..> to both console and the main log file.
146+ # :end docstring:
147+
148+ function say(){
149+ (echo " $@ " ) | tee -a $LOGGINGDIR /compilation-$SCALADATE -$SCALAHASH .log
150+ }
151+
95152
96153# we must change ivy home to get a fresh ivy cache, otherwise we get half-bootstrapped scala
97154# rm it in case it existed (and there's no ivy2-shadow, which indicates we're running in a TESTING environment)...
@@ -102,15 +159,12 @@ mkdir -p $baseDir/ivy2
102159rm -rf $baseDir /resolutionScratch_
103160mkdir -p $baseDir /resolutionScratch_
104161
105- mkdir -p $baseDir /logs
106-
107-
108162# repo used to publish "locker" scala to (to start the bootstrap)
109163privateCred=" private-repo"
110164privateRepo=" http://private-repo.typesafe.com/typesafe/scala-release-temp/"
111165
112166function parseScalaProperties(){
113- propFile=" $baseDir /scala/ $1 "
167+ propFile=" $baseDir /$1 "
114168 if [ ! -f $propFile ]; then
115169 echo " Property file $propFile not found."
116170 exit 1
@@ -206,7 +260,7 @@ buildXML() {
206260 then echo " Found scala-xml $XML_VER ; not building."
207261 else
208262 update scala scala-xml " $XML_REF " && gfxd
209- sbtBuild ' set version := "' $XML_VER ' -DOC"' $clean doc ' set version := "' $XML_VER ' "' " ${buildTasks[@]} "
263+ sbtBuild ' set version := "' $XML_VER ' -DOC"' $clean doc ' set version := "' $XML_VER ' "' test " ${buildTasks[@]} "
210264 XML_BUILT=" yes" # ensure the module is built and published when buildXML is invoked for the second time, see comment above
211265 fi
212266}
@@ -216,7 +270,7 @@ buildParsers() {
216270 then echo " Found scala-parser-combinators $PARSERS_VER ; not building."
217271 else
218272 update scala scala-parser-combinators " $PARSERS_REF " && gfxd
219- sbtBuild ' set version := "' $PARSERS_VER ' -DOC"' $clean doc ' set version := "' $PARSERS_VER ' "' " ${buildTasks[@]} "
273+ sbtBuild ' set version := "' $PARSERS_VER ' -DOC"' $clean doc ' set version := "' $PARSERS_VER ' "' test " ${buildTasks[@]} "
220274 PARSERS_BUILT=" yes"
221275 fi
222276}
@@ -226,7 +280,7 @@ buildPartest() {
226280 then echo " Found scala-partest $PARTEST_VER ; not building."
227281 else
228282 update scala scala-partest " $PARTEST_REF " && gfxd
229- sbtBuild ' set version :="' $PARTEST_VER ' "' ' set VersionKeys.scalaXmlVersion := "' $XML_VER ' "' ' set VersionKeys.scalaCheckVersion := "' $SCALACHECK_VER ' "' $clean " ${buildTasks[@]} "
283+ sbtBuild ' set version :="' $PARTEST_VER ' "' ' set VersionKeys.scalaXmlVersion := "' $XML_VER ' "' ' set VersionKeys.scalaCheckVersion := "' $SCALACHECK_VER ' "' $clean test " ${buildTasks[@]} "
230284 PARTEST_BUILT=" yes"
231285 fi
232286}
@@ -247,7 +301,7 @@ buildContinuations() {
247301 update scala scala-continuations $CONTINUATIONS_REF && gfxd
248302
249303 $sbtCmd $sbtArgs ' project plugin' " ${scalaVersionTasks[@]} " " ${publishTasks[@]} " \
250- ' set version := "' $CONTINUATIONS_VER ' "' $clean " compile:package" " ${buildTasks[@]} " # https://github.com/scala/scala-continuations/pull/4
304+ ' set version := "' $CONTINUATIONS_VER ' "' $clean " compile:package" test " ${buildTasks[@]} " # https://github.com/scala/scala-continuations/pull/4
251305 CONT_PLUG_BUILT=" yes"
252306 fi
253307
@@ -256,7 +310,7 @@ buildContinuations() {
256310 else
257311 update scala scala-continuations $CONTINUATIONS_REF && gfxd
258312 $sbtCmd $sbtArgs ' project library' " ${scalaVersionTasks[@]} " " ${publishTasks[@]} " \
259- ' set version := "' $CONTINUATIONS_VER ' "' $clean " ${buildTasks[@]} "
313+ ' set version := "' $CONTINUATIONS_VER ' "' $clean test " ${buildTasks[@]} "
260314 CONT_LIB_BUILT=" yes"
261315 fi
262316}
@@ -266,7 +320,7 @@ buildSwing() {
266320 then echo " Found scala-swing $SWING_VER ; not building."
267321 else
268322 update scala scala-swing " $SWING_REF " && gfxd
269- sbtBuild ' set version := "' $SWING_VER ' "' $clean " ${buildTasks[@]} "
323+ sbtBuild ' set version := "' $SWING_VER ' "' $clean test " ${buildTasks[@]} "
270324 SWING_BUILT=" yes"
271325 fi
272326}
@@ -276,6 +330,8 @@ buildActorsMigration(){
276330 then echo " Found scala-actors-migration $ACTORS_MIGRATION_VER ; not building."
277331 else
278332 update scala actors-migration " $ACTORS_MIGRATION_REF " && gfxd
333+ # not running tests because
334+ # [error] Test scala.actors.migration.NestedReact.testNestedReactAkka failed: java.util.concurrent.TimeoutException: Futures timed out after [20 seconds]
279335 sbtBuild ' set version := "' $ACTORS_MIGRATION_VER ' "' ' set VersionKeys.continuationsVersion := "' $CONTINUATIONS_VER ' "' $clean " ${buildTasks[@]} "
280336 ACTORS_MIGRATION_BUILT=" yes"
281337 fi
@@ -307,7 +363,7 @@ buildModules() {
307363# # BUILD STEPS:
308364
309365determineScalaVersion () {
310- update scala scala $SCALA_REF
366+ cd $WORKSPACE
311367 parseScalaProperties " versions.properties"
312368
313369 if [ -z " $SCALA_VER_BASE " ]; then
@@ -327,7 +383,7 @@ determineScalaVersion() {
327383
328384 # TODO: publish nightly snapshot using this script
329385 publishToSonatype=" no"
330- echo " dist_ref =2.11.x" >> $baseDir /jenkins.properties # for the -dist downstream jobs that build the actual archives
386+ echo " repo_ref =2.11.x" >> $baseDir /jenkins.properties # for the -dist downstream jobs that build the actual archives
331387 else
332388 echo " HEAD is tagged as $scalaTag ."
333389 # borrowed from https://github.com/cloudflare/semver_bash/blob/master/semver.sh
@@ -452,7 +508,7 @@ constructUpdatedModuleVersions() {
452508bootstrap () {
453509 echo " ### Bootstrapping"
454510
455- update scala scala $SCALA_REF && gfxd
511+ cd $WORKSPACE
456512
457513 # ### LOCKER
458514
@@ -480,7 +536,7 @@ bootstrap() {
480536 # we only need to build the modules necessary to build Scala itself
481537 # since the version of locker and quick are the same
482538 publishTasks=(' set credentials += Credentials(Path.userHome / ".credentials-private-repo")' " set every publishTo := Some(\" private-repo\" at \" $privateRepo \" )" )
483- buildTasks=(test $publishPrivateTask )
539+ buildTasks=($publishPrivateTask )
484540 buildModules
485541
486542 constructUpdatedModuleVersions
@@ -497,8 +553,9 @@ bootstrap() {
497553 # Sanity check: make sure the Scala test suite passes / docs can be generated with these modules.
498554 # don't skip locker (-Dlocker.skip=1), or stability will fail
499555 # overwrite "locker" version of scala at private-repo with bootstrapped version
500- cd $baseDir /scala
501- gfxd
556+ cd $baseDir
557+ rm -rf build/ # must leave everything else in $baseDir for downstream jobs
558+
502559 ant -Dstarr.version=$SCALA_VER \
503560 -Dextra.repo.url=$privateRepo \
504561 -Dmaven.version.suffix=$SCALA_VER_SUFFIX \
@@ -518,7 +575,7 @@ bootstrap() {
518575 # git commit versions.properties -m"Bump versions.properties for $SCALA_VER."
519576}
520577
521- # assumes we just bootstrapped, and current directory is $baseDir/scala
578+ # assumes we just bootstrapped, and current directory is $baseDir
522579# publishes locker to sonatype, then builds modules again (those for which version numbers were provided),
523580# and publishes those to sonatype as well
524581# finally, the staging repos are closed
@@ -534,7 +591,7 @@ publishSonatype() {
534591 # NOTE: only publish those for which versions are set
535592 # test and publish to sonatype, assuming you have ~/.sbt/0.13/sonatype.sbt and ~/.sbt/0.13/plugin/gpg.sbt
536593 publishTasks=(' set credentials += Credentials(Path.userHome / ".credentials-sonatype")' " set pgpPassphrase := Some(Array.empty)" )
537- buildTasks=(test $publishSonatypeTaskModules )
594+ buildTasks=($publishSonatypeTaskModules )
538595 buildModules
539596
540597 open=$( st_stagingReposOpen)
@@ -561,7 +618,7 @@ if [ "$publishToSonatype" == "yes" ]
561618 then publishSonatype
562619 else # build modules one more time, just to mimic the regular build as much when running as nightly
563620 echo " ### Rebuilding modules with quick, publishing to $baseDir /ivy/local"
564- buildTasks=(test publish-local)
621+ buildTasks=(publish-local)
565622 # buildScalacheck always uses publishPrivateTask (not buildTasks). we override it to avoid publishing to private-repo.
566623 publishPrivateTask=" publish-local"
567624 forceRebuild=" yes"
0 commit comments