Skip to content

Commit ce078a3

Browse files
committed
Simplify CI builds
1 parent 3db8041 commit ce078a3

File tree

4 files changed

+99
-116
lines changed

4 files changed

+99
-116
lines changed

.drone.yml

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
11
pipeline:
2+
test_legacy:
3+
group: test
4+
image: lampepfl/dotty:2017-09-05
5+
commands:
6+
- ./project/scripts/sbt legacyTests
7+
28
test:
9+
group: test
10+
image: lampepfl/dotty:2017-09-05
11+
commands:
12+
- ./project/scripts/sbt dotty-bootstrapped/test
13+
14+
test_bootstrapped:
15+
group: test
316
image: lampepfl/dotty:2017-09-05
417
commands:
5-
- ./project/scripts/sbt "${CI_TEST}"
18+
- ./project/scripts/sbt test
19+
20+
test_optimised:
21+
group: test
22+
image: lampepfl/dotty:2017-09-05
23+
commands:
24+
- ./project/scripts/sbt "set bootstrapOptimised in ThisBuild := true ;dotty-bootstrapped/test"
25+
26+
test_sbt:
27+
group: test
28+
image: lampepfl/dotty:2017-09-05
29+
commands:
30+
- ./project/scripts/sbt sbt-dotty/scripted
31+
32+
documentation:
33+
image: lampepfl/dotty:2017-09-05
34+
commands:
35+
- ./project/scripts/genDocs
36+
secrets: [ bot_pass ]
37+
when:
38+
event: push
639

740
publish_nightly:
841
image: lampepfl/dotty:2017-09-05
942
environment:
1043
- NIGHTLYBUILD=yes
1144
commands:
12-
- ./project/scripts/sbt ";clean ;publishLocal" "${CI_PUBLISH}"
13-
- ./project/scripts/sbt "sbt-dotty/scripted source-dependencies/*" "${CI_PUBLISH}"
14-
- ./project/scripts/sbtPublish "${CI_PUBLISH}" "$SONATYPE_USER" "$SONATYPE_PW" "$PGP_PW" ";dotty-bootstrapped/publishSigned ;sonatypeRelease"
45+
- ./project/scripts/sbtPublish ";dotty-bootstrapped/publishSigned ;sonatypeRelease"
1546
volumes:
1647
- /home/drone/keys:/keys
1748
secrets: [ sonatype_user, sonatype_pw, pgp_pw ]
@@ -24,9 +55,7 @@ pipeline:
2455
environment:
2556
- RELEASEBUILD=yes
2657
commands:
27-
- ./project/scripts/sbt ";clean ;publishLocal" "${CI_PUBLISH}"
28-
- ./project/scripts/sbt "sbt-dotty/scripted source-dependencies/*" "${CI_PUBLISH}"
29-
- ./project/scripts/sbtPublish "${CI_PUBLISH}" "$SONATYPE_USER" "$SONATYPE_PW" "$PGP_PW" ";dotty-bootstrapped/publishSigned ;sonatypeRelease"
58+
- ./project/scripts/sbtPublish ";dotty-bootstrapped/publishSigned ;sonatypeRelease"
3059
volumes:
3160
- /home/drone/keys:/keys
3261
secrets: [ sonatype_user, sonatype_pw, pgp_pw ]
@@ -39,22 +68,14 @@ pipeline:
3968
environment:
4069
- RELEASEBUILD=yes
4170
commands:
42-
- ./project/scripts/sbtPublish "${CI_PUBLISH}" "$SONATYPE_USER" "$SONATYPE_PW" "$PGP_PW" ";sbt-dotty/publishSigned ;sonatypeRelease"
71+
- ./project/scripts/sbtPublish ";sbt-dotty/publishSigned ;sonatypeRelease"
4372
volumes:
4473
- /home/drone/keys:/keys
4574
secrets: [ sonatype_user, sonatype_pw, pgp_pw ]
4675
when:
4776
event: deployment
4877
environment: sbt_release
4978

50-
documentation:
51-
image: lampepfl/dotty:2017-09-05
52-
commands:
53-
- ./project/scripts/genDocs "${CI_PUBLISH}" "$BOT_PASS"
54-
secrets: [ bot_pass ]
55-
when:
56-
event: push
57-
5879
slack:
5980
image: plugins/slack
6081
channel: dotty
@@ -63,15 +84,6 @@ pipeline:
6384
status: [ success, failure ]
6485
event: [ push, deployment ]
6586

66-
branches: master
6787

68-
matrix:
69-
include:
70-
- CI_TEST: legacyTests
71-
CI_PUBLISH: true
72-
- CI_TEST: ;test;sbt-dotty/scripted compilerReporter/*;sbt-dotty/scripted discovery/*;sbt-dotty/scripted sbt-dotty/*
73-
CI_PUBLISH: false
74-
- CI_TEST: dotty-bootstrapped/test
75-
CI_PUBLISH: false
76-
- CI_TEST: ;set bootstrapOptimised in ThisBuild := true ;dotty-bootstrapped/test
77-
CI_PUBLISH: false
88+
89+
branches: master

project/scripts/genDocs

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,59 @@
11
#!/usr/bin/env bash
22

3-
# Usage: ./genDocs <true/false> <dotty-bot password>
3+
# Usage: ./genDocs <dotty-bot password>
44

55
set -e
66
# set extended glob, needed for rm everything but x
77
shopt -s extglob
88

9-
if [ $1 = true ]; then
10-
11-
# make sure that BOT_PASS is set
12-
if [ -z ${2+x} ]; then
13-
echo "BOT_PASS unset, unable to push without password" 1>&2
14-
exit 1
15-
else
16-
BOT_PASS=$2
17-
fi
9+
# make sure that BOT_PASS is set
10+
if [ -z "$BOT_PASS" ]; then
11+
echo "Error: BOT_PASS env unset, unable to push without password" 1>&2
12+
exit 1
13+
fi
1814

19-
echo "Working directory: $PWD"
15+
echo "Working directory: $PWD"
2016

21-
# this command will generate docs in $PWD/docs/_site
22-
sbt -J-Xmx4096m \
23-
-J-XX:ReservedCodeCacheSize=512m \
24-
-J-XX:MaxMetaspaceSize=1024m \
25-
-Ddotty.drone.mem=4096m \
26-
-ivy /var/cache/drone/ivy2 \
27-
"genDocs"
17+
# this command will generate docs in $PWD/docs/_site
18+
sbt -J-Xmx4096m \
19+
-J-XX:ReservedCodeCacheSize=512m \
20+
-J-XX:MaxMetaspaceSize=1024m \
21+
-Ddotty.drone.mem=4096m \
22+
-ivy /var/cache/drone/ivy2 \
23+
"genDocs"
2824

29-
# make sure that the previous command actually succeeded
30-
if [ ! -d "$PWD/docs/_site" ]; then
31-
echo "Output directory did not exist: $PWD/docs/_site" 1>&2
32-
exit 1
33-
fi
25+
# make sure that the previous command actually succeeded
26+
if [ ! -d "$PWD/docs/_site" ]; then
27+
echo "Output directory did not exist: $PWD/docs/_site" 1>&2
28+
exit 1
29+
fi
3430

35-
# save current head for commit message in gh-pages
36-
GIT_HEAD=$(git rev-parse HEAD)
31+
# save current head for commit message in gh-pages
32+
GIT_HEAD=$(git rev-parse HEAD)
3733

38-
# check out correct branch
39-
git fetch origin gh-pages:gh-pages
40-
git checkout gh-pages
34+
# check out correct branch
35+
git fetch origin gh-pages:gh-pages
36+
git checkout gh-pages
4137

42-
# move newly generated _site dir to $PWD
43-
mv $PWD/docs/_site .
38+
# move newly generated _site dir to $PWD
39+
mv $PWD/docs/_site .
4440

45-
# remove everything BUT _site dir
46-
rm -rf !(_site)
41+
# remove everything BUT _site dir
42+
rm -rf !(_site)
4743

48-
# copy new contents to $PWD
49-
mv _site/* .
44+
# copy new contents to $PWD
45+
mv _site/* .
5046

51-
# remove now empty _site dir
52-
rm -rf _site
47+
# remove now empty _site dir
48+
rm -rf _site
5349

54-
# set github credentials
55-
git config user.name "dotty-bot"
56-
git config user.email "felix.mulder@epfl.ch"
50+
# set github credentials
51+
git config user.name "dotty-bot"
52+
git config user.email "felix.mulder@epfl.ch"
5753

58-
# add all contents of $PWD to commit
59-
git add -A
60-
git commit -m "Update gh-pages site for $GIT_HEAD" || echo "nothing new to commit"
54+
# add all contents of $PWD to commit
55+
git add -A
56+
git commit -m "Update gh-pages site for $GIT_HEAD" || echo "nothing new to commit"
6157

62-
# push using dotty-bot to origin
63-
git push https://dotty-bot:$BOT_PASS@github.com/lampepfl/dotty.git || echo "couldn't push, since nothing was added"
64-
else
65-
# wrong parameter passed, should only generate docs if argument is "test"
66-
# to avoid multiple site gens
67-
echo "Not generating docs for $1"
68-
fi
58+
# push using dotty-bot to origin
59+
git push https://dotty-bot:$BOT_PASS@github.com/lampepfl/dotty.git || echo "couldn't push, since nothing was added"

project/scripts/sbt

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
#!/usr/bin/env bash
22

3-
CI_TEST=$1
3+
CMD="$1"
44

5-
if [ -n "$2" ]; then
6-
if [ $2 = true ]; then
7-
SHOULD_RUN=true
8-
else
9-
SHOULD_RUN=false
10-
fi
11-
else
12-
SHOULD_RUN=true
5+
if [ -z "$CMD" ]; then
6+
echo "Error: missing sbt command"
7+
exit 1
138
fi
149

15-
if [ $SHOULD_RUN = true ]; then
16-
# get the ivy2 cache:
17-
ln -s /var/cache/drone/ivy2 "$HOME/.ivy2" || true
10+
# get the ivy2 cache:
11+
ln -s /var/cache/drone/ivy2 "$HOME/.ivy2" || true
1812

19-
# run sbt with the supplied arg:
20-
sbt -J-Xmx4096m \
21-
-J-XX:ReservedCodeCacheSize=512m \
22-
-J-XX:MaxMetaspaceSize=1024m \
23-
-Ddotty.drone.mem=4096m "$CI_TEST"
24-
else
25-
echo "Not running, \$2=$2, SHOULD_RUN=$SHOULD_RUN"
26-
fi
13+
# run sbt with the supplied arg:
14+
sbt -J-Xmx4096m \
15+
-J-XX:ReservedCodeCacheSize=512m \
16+
-J-XX:MaxMetaspaceSize=1024m \
17+
-Ddotty.drone.mem=4096m "$CI_TEST"

project/scripts/sbtPublish

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,23 @@
11
#!/usr/bin/env bash
22

3-
# If the script should publish to maven:
4-
SHOULD_RUN=$1
5-
6-
# Sonatype credentials:
7-
SONATYPE_USER=$2
8-
SONATYPE_PW=$3
9-
10-
# PGP Credentials:
11-
PGP_PW=$4
12-
133
# Release command:
14-
RELEASE_CMD=$5
4+
RELEASE_CMD="$1"
155

16-
if [ $SHOULD_RUN = false ]; then
17-
exit 0
18-
fi
19-
20-
if [ -z "$2" -o -z "$3" -o -z "$4" ]; then
21-
echo "invalid args: this script takes 4 args, usage:"
22-
echo ""
23-
echo " ./project/scripts/sbt SHOULD_RUN SONATYPE_USER SONATYPE_PW PGP_PW"
6+
if [ -z "$SONATYPE_USER" ] || [ -z "$SONATYPE_PW" ] || [ -z "$PGP_PW" ]; then
7+
echo "Error: SONATYPE_USER, SONATYPE_PW or PGP_PW env unset"
248
exit 1
259
fi
2610

2711
if [ ! "$NIGHTLYBUILD" = "yes" ] && [ ! "$RELEASEBUILD" = "yes" ]; then
28-
echo "Neither NIGHTLYBUILD or RELEASEBUILD env var set to \"yes\""
12+
echo "Neither NIGHTLYBUILD nor RELEASEBUILD env var set to \"yes\""
2913
exit 1
3014
fi
3115

16+
if [ -z "$RELEASE_CMD" ]; then
17+
echo "Error: missing publish command"
18+
exit 1
19+
fi
20+
3221
CMD=" ;set credentials in ThisBuild := Seq(Credentials(\"Sonatype Nexus Repository Manager\", \"oss.sonatype.org\", \"$2\", \"$3\"))"
3322
CMD="$CMD ;set pgpPassphrase := Some(\"\"\"$4\"\"\".toCharArray)"
3423
CMD="$CMD ;set pgpSecretRing := file(\"/keys/secring.asc\")"

0 commit comments

Comments
 (0)