8
8
# <username>jenkinside</username>
9
9
# <password></password>
10
10
# </server>
11
- # - ~/.ivy2/. credentials (for sonatype)
11
+ # - ~/.credentials (for sonatype)
12
12
# realm=Sonatype Nexus Repository Manager
13
13
# host=oss.sonatype.org
14
14
# user=lamp
15
15
# password=
16
- # - ~/.ivy2/. credentials-private-repo for private-repo.typesafe.com, as follows:
16
+ # - ~/.credentials-private-repo for private-repo.typesafe.com, as follows:
17
17
# realm=Artifactory Realm
18
18
# host=private-repo.typesafe.com
19
19
# user=jenkinside
46
46
# Rebuild modules with this Scala build, and stage them on sonatype as well
47
47
# This script can be run in multiple modes. It is design to work without any input,
48
48
# 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,
50
50
# it'll build a nightly.
51
51
#
52
52
# Since the nightlies are intended to be a drop in replacement, all modules are built with the
56
56
# The other way to trigger a release is by setting the SCALA_VER_BASE env var.
57
57
#
58
58
# 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
60
60
# to trigger building HEAD of each module, generating a fresh -$(git describe)-nightly version for each.
61
61
#
62
62
# 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.)
64
64
65
- SCALA_REF=${SCALA_REF-" 2.11.x" }
66
65
67
66
# set to something besides the default to build nightly snapshots of the modules instead of some tagged version
68
67
moduleVersioning=${moduleVersioning-" versions.properties" }
69
68
70
- baseDir=${baseDir -`pwd`}
69
+ baseDir=${WORKSPACE -`pwd`}
71
70
publishPrivateTask=${publishPrivateTask-" publish" }
72
71
publishSonatypeTaskCore=${publishSonatypeTaskCore-" publish-signed" }
73
72
publishSonatypeTaskModules=${publishSonatypeTaskModules-" publish-signed" }
@@ -86,12 +85,70 @@ forceRebuild=${forceRebuild-no}
86
85
# overridden to "no" when no SCALA_VER_BASE is passed and HEAD is not tagged with a valid version tag
87
86
#
88
87
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)
90
89
clean=" clean" # TESTING leave empty to speed up testing
91
90
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
+
95
152
96
153
# we must change ivy home to get a fresh ivy cache, otherwise we get half-bootstrapped scala
97
154
# 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
102
159
rm -rf $baseDir /resolutionScratch_
103
160
mkdir -p $baseDir /resolutionScratch_
104
161
105
- mkdir -p $baseDir /logs
106
-
107
-
108
162
# repo used to publish "locker" scala to (to start the bootstrap)
109
163
privateCred=" private-repo"
110
164
privateRepo=" http://private-repo.typesafe.com/typesafe/scala-release-temp/"
111
165
112
166
function parseScalaProperties(){
113
- propFile=" $baseDir /scala/ $1 "
167
+ propFile=" $baseDir /$1 "
114
168
if [ ! -f $propFile ]; then
115
169
echo " Property file $propFile not found."
116
170
exit 1
@@ -206,7 +260,7 @@ buildXML() {
206
260
then echo " Found scala-xml $XML_VER ; not building."
207
261
else
208
262
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[@]} "
210
264
XML_BUILT=" yes" # ensure the module is built and published when buildXML is invoked for the second time, see comment above
211
265
fi
212
266
}
@@ -216,7 +270,7 @@ buildParsers() {
216
270
then echo " Found scala-parser-combinators $PARSERS_VER ; not building."
217
271
else
218
272
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[@]} "
220
274
PARSERS_BUILT=" yes"
221
275
fi
222
276
}
@@ -226,7 +280,7 @@ buildPartest() {
226
280
then echo " Found scala-partest $PARTEST_VER ; not building."
227
281
else
228
282
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[@]} "
230
284
PARTEST_BUILT=" yes"
231
285
fi
232
286
}
@@ -247,7 +301,7 @@ buildContinuations() {
247
301
update scala scala-continuations $CONTINUATIONS_REF && gfxd
248
302
249
303
$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
251
305
CONT_PLUG_BUILT=" yes"
252
306
fi
253
307
@@ -256,7 +310,7 @@ buildContinuations() {
256
310
else
257
311
update scala scala-continuations $CONTINUATIONS_REF && gfxd
258
312
$sbtCmd $sbtArgs ' project library' " ${scalaVersionTasks[@]} " " ${publishTasks[@]} " \
259
- ' set version := "' $CONTINUATIONS_VER ' "' $clean " ${buildTasks[@]} "
313
+ ' set version := "' $CONTINUATIONS_VER ' "' $clean test " ${buildTasks[@]} "
260
314
CONT_LIB_BUILT=" yes"
261
315
fi
262
316
}
@@ -266,7 +320,7 @@ buildSwing() {
266
320
then echo " Found scala-swing $SWING_VER ; not building."
267
321
else
268
322
update scala scala-swing " $SWING_REF " && gfxd
269
- sbtBuild ' set version := "' $SWING_VER ' "' $clean " ${buildTasks[@]} "
323
+ sbtBuild ' set version := "' $SWING_VER ' "' $clean test " ${buildTasks[@]} "
270
324
SWING_BUILT=" yes"
271
325
fi
272
326
}
@@ -276,6 +330,8 @@ buildActorsMigration(){
276
330
then echo " Found scala-actors-migration $ACTORS_MIGRATION_VER ; not building."
277
331
else
278
332
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]
279
335
sbtBuild ' set version := "' $ACTORS_MIGRATION_VER ' "' ' set VersionKeys.continuationsVersion := "' $CONTINUATIONS_VER ' "' $clean " ${buildTasks[@]} "
280
336
ACTORS_MIGRATION_BUILT=" yes"
281
337
fi
@@ -307,7 +363,7 @@ buildModules() {
307
363
# # BUILD STEPS:
308
364
309
365
determineScalaVersion () {
310
- update scala scala $SCALA_REF
366
+ cd $WORKSPACE
311
367
parseScalaProperties " versions.properties"
312
368
313
369
if [ -z " $SCALA_VER_BASE " ]; then
@@ -327,7 +383,7 @@ determineScalaVersion() {
327
383
328
384
# TODO: publish nightly snapshot using this script
329
385
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
331
387
else
332
388
echo " HEAD is tagged as $scalaTag ."
333
389
# borrowed from https://github.com/cloudflare/semver_bash/blob/master/semver.sh
@@ -452,7 +508,7 @@ constructUpdatedModuleVersions() {
452
508
bootstrap () {
453
509
echo " ### Bootstrapping"
454
510
455
- update scala scala $SCALA_REF && gfxd
511
+ cd $WORKSPACE
456
512
457
513
# ### LOCKER
458
514
@@ -480,7 +536,7 @@ bootstrap() {
480
536
# we only need to build the modules necessary to build Scala itself
481
537
# since the version of locker and quick are the same
482
538
publishTasks=(' set credentials += Credentials(Path.userHome / ".credentials-private-repo")' " set every publishTo := Some(\" private-repo\" at \" $privateRepo \" )" )
483
- buildTasks=(test $publishPrivateTask )
539
+ buildTasks=($publishPrivateTask )
484
540
buildModules
485
541
486
542
constructUpdatedModuleVersions
@@ -497,8 +553,9 @@ bootstrap() {
497
553
# Sanity check: make sure the Scala test suite passes / docs can be generated with these modules.
498
554
# don't skip locker (-Dlocker.skip=1), or stability will fail
499
555
# 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
+
502
559
ant -Dstarr.version=$SCALA_VER \
503
560
-Dextra.repo.url=$privateRepo \
504
561
-Dmaven.version.suffix=$SCALA_VER_SUFFIX \
@@ -518,7 +575,7 @@ bootstrap() {
518
575
# git commit versions.properties -m"Bump versions.properties for $SCALA_VER."
519
576
}
520
577
521
- # assumes we just bootstrapped, and current directory is $baseDir/scala
578
+ # assumes we just bootstrapped, and current directory is $baseDir
522
579
# publishes locker to sonatype, then builds modules again (those for which version numbers were provided),
523
580
# and publishes those to sonatype as well
524
581
# finally, the staging repos are closed
@@ -534,7 +591,7 @@ publishSonatype() {
534
591
# NOTE: only publish those for which versions are set
535
592
# test and publish to sonatype, assuming you have ~/.sbt/0.13/sonatype.sbt and ~/.sbt/0.13/plugin/gpg.sbt
536
593
publishTasks=(' set credentials += Credentials(Path.userHome / ".credentials-sonatype")' " set pgpPassphrase := Some(Array.empty)" )
537
- buildTasks=(test $publishSonatypeTaskModules )
594
+ buildTasks=($publishSonatypeTaskModules )
538
595
buildModules
539
596
540
597
open=$( st_stagingReposOpen)
@@ -561,7 +618,7 @@ if [ "$publishToSonatype" == "yes" ]
561
618
then publishSonatype
562
619
else # build modules one more time, just to mimic the regular build as much when running as nightly
563
620
echo " ### Rebuilding modules with quick, publishing to $baseDir /ivy/local"
564
- buildTasks=(test publish-local)
621
+ buildTasks=(publish-local)
565
622
# buildScalacheck always uses publishPrivateTask (not buildTasks). we override it to avoid publishing to private-repo.
566
623
publishPrivateTask=" publish-local"
567
624
forceRebuild=" yes"
0 commit comments