Skip to content

Commit ad54e48

Browse files
authored
Merge pull request #182 from lrytz/appveyor
AppVeyor
2 parents 4dc0809 + 091b8f9 commit ad54e48

File tree

9 files changed

+231
-28
lines changed

9 files changed

+231
-28
lines changed

.travis.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
# we need rpmbuild but it's unlikely to be whitelisted, according to
22
# https://github.com/travis-ci/apt-package-whitelist/pull/1700
33
sudo: required
4-
before_install:
4+
5+
install:
56
- sudo apt-get -qq update
67
- sudo apt-get install -y rpm
78

89
language: scala
910
jdk: oraclejdk8
1011

12+
env:
13+
global:
14+
# PRIV_KEY_SECRET
15+
- secure: "NlnFqZs4mvCi63GqCdUNDsx9BoiyrjgoV0cUaKlhVYp49/qAMlEaKf6JABWy/oCHoWsTyysyLEtZLsWfjAyE4+FUHSzngNUHVFBbtyudA6aKQ7jMsqkcMM/K0h+ymnhHSv8bugc8jXKFgmfYk4YTi5dZgv8CAOSQFAFUaxVdYTY="
16+
# APPVEYOR_TOKEN
17+
- secure: "aHM0UWkbFN0bXQja2f9lUcSgqHzXYkYqqV8/nP5MTLKJG8BpuaLYxI4gHfkPmxSm9/TTniA3zUVN//lJTvhco5J5Dtxfo5DeCLWsjQcQxrsgAFD97FpMpGbtFAViZuiv7SdPGvzXQY6AwvteBpxOday4T224aH5OjZJ0DxySx8Q="
18+
# TRAVIS_TOKEN
19+
- secure: "K6G3SeMRMgC8JUZADyd4RKvQpgHOZb8/8kk3AlDtRWZmrBPkZpTrtcuQLYXRiEAO/beQH956i3+uDeFryF079YTJZKtdqLTxwXS53gVurOv9VVbZFubu4HzXWMWeCIi9Np7S0eB1qc4NIKB+T5pbmIfEFGKThBGK179uwf2lqQ8="
20+
# AWS_ACCESS_KEY_ID
21+
- secure: "BrsLFLXLdJ3aesJGuoVXFdKluYl7QYBYjn5+ttoep2nc6/E+L3UDaR//ztxwex4a9yFi5q2jCs911FzVsk78ODamr5w8FBlOuu06RoVx642+U/agG7yUdAtvEzH2KVTBNjY0oYHZ+OlVEkeYgnkrsbfki+ujPWEnxkakWyrGtJw="
22+
# AWS_SECRET_ACCESS_KEY
23+
- secure: "dv0pR9uqnLyKVHu1L1nvl5TVpo3bOxh4icLNybwFyCFQd9XiM/RU8Vhx3svZqqnAG+GiCDSiCaBQkTLUS5u9e+9eVw3cUj5meNr9EW673f8D6H8Tr433jlvu54CynD9DsBjhNo/xIrECOKTq+0wu480OLSjOkuNoclG2dSm4Dis="
24+
1125
script:
12-
- sbt -Dproject.version=2.12.0 s3Upload::mappings
26+
- admin/build.sh
1327

1428
cache:
1529
directories:

admin/build.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
Function checkExit() {
4+
if (-not $?) {
5+
echo "Last command failed."
6+
Exit 1
7+
}
8+
}
9+
10+
# oh boy. i don't (want to) fully understand, but executing commands and redirecting is difficult.
11+
# - https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/
12+
# - https://stackoverflow.com/a/35980675/248998
13+
# letting cmd do the redirect avoids confusing powershell.
14+
& cmd /c 'java -version' '2>&1'
15+
checkExit
16+
17+
Function ensureVersion() {
18+
$verPat="^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?$"
19+
if ($env:version -notmatch $verPat) {
20+
echo "Not a valid Scala version: '$env:version'"
21+
Exit 1
22+
}
23+
}
24+
25+
if ($env:APPVEYOR_FORCED_BUILD -eq 'true') {
26+
ensureVersion
27+
if ($env:mode -eq 'release') {
28+
echo "Running a release for $env:version"
29+
$repositoriesFile="$env:APPVEYOR_BUILD_FOLDER\conf\repositories"
30+
& cmd /c "sbt ""-Dsbt.override.build.repos=true"" ""-Dsbt.repository.config=$repositoriesFile"" ""-Dproject.version=$env:version"" ""show fullResolvers"" clean update s3Upload" '2>&1'
31+
checkExit
32+
} else {
33+
echo "Unknown mode: '$env:mode'"
34+
Exit 1
35+
}
36+
} else {
37+
# By default, test building the packages (but don't uplaod)
38+
# Need to redirect stderr, otherwise any error output (like jvm warning) fails the build (ErrorActionPreference)
39+
& cmd /c 'sbt "-Dproject.version=2.12.4" "show s3Upload::mappings"' '2>&1'
40+
checkExit
41+
}

admin/build.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Triggering jobs for a release:
6+
# - Open https://travis-ci.org/scala/scala-dist
7+
# - On the right: "More options" - "Trigger build"
8+
# - Chose the branch and enter a title for the build in the commit message filed
9+
# - Add a `before_install` custom config (see below) to set the `mode` and `version` env vars.
10+
# Using an `env: global: ...` section does not work because that overrides the default `env`
11+
# from .travis.yml. There's no way to specify the "merge mode" (*) from the web UI, that only
12+
# works in the REST API. We use `before_install` and assume it's not used otherwise.
13+
# (*) https://docs.travis-ci.com/user/triggering-builds/#Customizing-the-build-configuration
14+
# - Available modes:
15+
# - `release` to build native packages and upload them to S3
16+
# - `archive` to copy archives to chara (for scala-lang.org)
17+
# - `update-api` to update the scaladoc api symlinks
18+
# In all of the above modes, the `version` needs to be specified.
19+
#
20+
# before_install: export version=2.12.N mode=release
21+
22+
23+
# Encryping files (if you need to encrypt a new file but no longer have the secret, create a new
24+
# secret and re-encrypt all files):
25+
#
26+
# 1. Generate secret
27+
# cat /dev/urandom | head -c 10000 | openssl sha1 > ./secret
28+
# 2. Save the secret on travis
29+
# travis encrypt "PRIV_KEY_SECRET=$(cat ./secret)"
30+
# 3. Encrypt the file
31+
# openssl aes-256-cbc -pass "file:./secret" -in jenkins_lightbend_chara -out jenkins_lightbend_chara.enc
32+
# 4. Decrypt the file
33+
# openssl aes-256-cbc -d -pass "pass:$PRIV_KEY_SECRET" -in admin/files/jenkins_lightbend_chara.enc > ~/.ssh/jenkins_lightbend_chara 2>/dev/null
34+
35+
36+
function ensureVersion() {
37+
local verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
38+
[[ "$version" =~ $verPat ]] || {
39+
echo "Not a valid Scala version: '$version'"
40+
exit 1
41+
}
42+
}
43+
44+
function decrypt() {
45+
# Even though we're running bash with -x, travis hides the private key from the log
46+
openssl aes-256-cbc -d -pass "pass:$PRIV_KEY_SECRET" -in $1 > $2 2>/dev/null
47+
}
48+
49+
function setupSSH() {
50+
mkdir -p ~/.ssh
51+
cp admin/files/ssh_config ~/.ssh/config
52+
echo 'chara.epfl.ch,128.178.154.107 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBLER9rqy0iCfz24+8BBBObh7FXXQJCoLLE9UuyQHNFUU4SS5FSzNjEoKXwTj8nqNy+8l0rOkj3KG8p2cLxsqjY=' >> ~/.ssh/known_hosts
53+
decrypt admin/files/jenkins_lightbend_chara.enc ~/.ssh/jenkins_lightbend_chara
54+
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
55+
}
56+
57+
curlOut="curlOut.txt"
58+
59+
function checkStatus() {
60+
cat $curlOut
61+
rm -f $curlOut
62+
[[ "$1" == "$2" ]] || {
63+
echo "Failed to start smoketest job"
64+
exit 1
65+
}
66+
}
67+
68+
function triggerMsiRelease() {
69+
local jsonTemplate='{ "accountName": "scala", "projectSlug": "scala-dist", "branch": "%s", "commitId": "%s", "environmentVariables": { "mode": "%s", "version": "%s" } }'
70+
local json=$(printf "$jsonTemplate" "$TRAVIS_BRANCH" "$TRAVIS_COMMIT" "$mode" "$version")
71+
72+
local curlStatus=$(curl \
73+
-s -o $curlOut -w "%{http_code}" \
74+
-H "Authorization: Bearer $APPVEYOR_TOKEN" \
75+
-H "Content-Type: application/json" \
76+
-d "$json" \
77+
https://ci.appveyor.com/api/builds)
78+
79+
checkStatus $curlStatus "200"
80+
}
81+
82+
function triggerSmoketest() {
83+
local jsonTemplate='{ "request": { "branch": "%s", "message": "Smoketest %s", "config": { "before_install": "export version=%s" } } }'
84+
local json=$(printf "$jsonTemplate" "$TRAVIS_BRANCH" "$version" "$version")
85+
86+
local curlStatus=$(curl \
87+
-s -o $curlOut -w "%{http_code}" \
88+
-H "Travis-API-Version: 3" \
89+
-H "Authorization: token $TRAVIS_TOKEN" \
90+
-H "Content-Type: application/json" \
91+
-d "$json" \
92+
https://api.travis-ci.org/repo/scala%2Fscala-dist-smoketest/requests)
93+
94+
checkStatus $curlStatus "202"
95+
}
96+
97+
if [[ "$TRAVIS_EVENT_TYPE" == "api" ]]; then
98+
ensureVersion
99+
if [[ "$mode" == "archives" ]]; then
100+
echo "Running 'archives' for $version"
101+
setupSSH
102+
. scripts/jobs/release/website/archives
103+
elif [[ "$mode" == "update-api" ]]; then
104+
echo "Running 'update-api' for $version"
105+
setupSSH
106+
. scripts/jobs/release/website/update-api
107+
elif [[ "$mode" == "release" ]]; then
108+
echo "Running a release for $version"
109+
triggerMsiRelease
110+
repositoriesFile="$TRAVIS_BUILD_DIR/conf/repositories"
111+
# The log is too long for the travis UI, so remove ANSI codes to have a clean raw version
112+
sbt -Dsbt.log.noformat=true \
113+
-Dsbt.override.build.repos=true -Dsbt.repository.config="$repositoriesFile" \
114+
-Dproject.version=$version \
115+
"show fullResolvers" clean update s3Upload
116+
triggerSmoketest
117+
else
118+
echo "Unknown build mode: '$mode'"
119+
exit 1
120+
fi
121+
else
122+
# By default, test building the packages (but don't uplaod)
123+
sbt -Dproject.version=2.12.4 "show s3Upload::mappings"
124+
fi
3.19 KB
Binary file not shown.

admin/files/ssh_config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Host chara
2+
HostName chara.epfl.ch
3+
IdentityFile /home/travis/.ssh/jenkins_lightbend_chara
4+
User scalatest

appveyor.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '{build}'
2+
3+
branches:
4+
only:
5+
- 2.11.x
6+
- 2.12.x
7+
- 2.13.x
8+
9+
image: Visual Studio 2015
10+
11+
environment:
12+
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
13+
AWS_ACCESS_KEY_ID:
14+
secure: X1Ix1soRBDMtfbi8IFNPOggDP2XquhW+uKcJ+XC0kiM=
15+
AWS_SECRET_ACCESS_KEY:
16+
secure: woXwpM2+P3uZ1+LFM+SbJEKLfi7Kax5PvqJSN62nn1PQrJgEzVUAIoRGoXBx6X72
17+
18+
install:
19+
- cmd: choco install sbt -ia "INSTALLDIR=""C:\sbt"""
20+
- cmd: SET PATH=C:\sbt\bin;%JAVA_HOME%\bin;%PATH%
21+
22+
build_script:
23+
- ps: .\admin\build.ps1
24+
25+
cache:
26+
- C:\sbt\
27+
- C:\Users\appveyor\.m2
28+
- C:\Users\appveyor\.ivy2

build.sbt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,17 @@ upload := {
2222
import com.amazonaws.{ClientConfiguration, Protocol}
2323
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
2424
import com.amazonaws.services.s3.AmazonS3ClientBuilder
25-
import com.amazonaws.services.s3.model.{CannedAccessControlList, PutObjectRequest}
25+
import com.amazonaws.services.s3.model.PutObjectRequest
2626
import com.amazonaws.regions.Regions
2727

28-
// the publishing job runs on an EC2 instance that has access to the S3 bucket via its IAM instance profile
29-
val client = AmazonS3ClientBuilder.standard.withRegion(Regions.US_EAST_1).build
28+
// The standard client picks credentials from AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY env vars
29+
val client = AmazonS3ClientBuilder.standard.withRegion(Regions.US_EAST_1).build
3030

3131
val log = streams.value.log
3232

3333
(mappings in upload).value map { case (file, key) =>
3434
log.info("Uploading "+ file.getAbsolutePath() +" as "+ key)
35-
36-
// since the s3 bucket is in a separate account from where the EC2 CI instances are, must explicitly set acl as public-read
37-
client.putObject(new PutObjectRequest("downloads.typesafe.com", key, file).withCannedAcl(CannedAccessControlList.PublicRead))
35+
client.putObject(new PutObjectRequest("downloads.typesafe.com", key, file))
3836
}
3937
}
4038

@@ -48,4 +46,4 @@ enablePlugins(UniversalPlugin, RpmPlugin, JDebPackaging, WindowsPlugin)
4846

4947
// resolvers += "local" at "file:///e:/.m2/repository"
5048
// resolvers += Resolver.mavenLocal
51-
// to test, run e.g., stage, or windows:packageBin, show s3-upload::mappings
49+
// to test, run e.g., stage, or windows:packageBin, show s3Upload::mappings

scripts/jobs/release/website/archives

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash -ex
2-
# need to re-declare it as an array, not sure how to do that directly in jenkins
3-
declare -a sshCharaArgs="$sshCharaArgs"
42

53
url="https://downloads.lightbend.com/scala/$version"
64

@@ -10,24 +8,23 @@ else archivesDir="~linuxsoft/archives/scala"
108
fi
119

1210
# make this build restartable (if interrupted, partial files may remain, and resuming isn't very reliable)
13-
[[ -n $version ]] && ssh "${sshCharaArgs[@]}" "rm -f $archivesDir/scala-*$version* && rm -rf $archivesDir/api/$version/ ||:"
11+
[[ -n $version ]] && ssh chara "rm -f $archivesDir/scala-*$version* && rm -rf $archivesDir/api/$version/ ||:"
1412

1513
cacheBuster="$(date +%s | tail -c2 | head -c1)"
16-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.msi '$url/scala-$version.msi?$cacheBuster'"
17-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.zip '$url/scala-$version.zip?$cacheBuster'"
18-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.tgz '$url/scala-$version.tgz?$cacheBuster'"
19-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.deb '$url/scala-$version.deb?$cacheBuster'"
20-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.rpm '$url/scala-$version.rpm?$cacheBuster'"
21-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-docs-$version.zip '$url/scala-docs-$version.zip?$cacheBuster'"
22-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-docs-$version.tgz '$url/scala-docs-$version.tgz?$cacheBuster'"
23-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-docs-$version.txz '$url/scala-docs-$version.txz?$cacheBuster'"
14+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.msi '$url/scala-$version.msi?$cacheBuster'"
15+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.zip '$url/scala-$version.zip?$cacheBuster'"
16+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.tgz '$url/scala-$version.tgz?$cacheBuster'"
17+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.deb '$url/scala-$version.deb?$cacheBuster'"
18+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.rpm '$url/scala-$version.rpm?$cacheBuster'"
19+
ssh chara "cd $archivesDir && wget -nv -O scala-docs-$version.zip '$url/scala-docs-$version.zip?$cacheBuster'"
20+
ssh chara "cd $archivesDir && wget -nv -O scala-docs-$version.tgz '$url/scala-docs-$version.tgz?$cacheBuster'"
21+
ssh chara "cd $archivesDir && wget -nv -O scala-docs-$version.txz '$url/scala-docs-$version.txz?$cacheBuster'"
2422

2523
echo "Expanding scala-library API docs for $version to api/$version (with subdirectories for scala-compiler and scala-reflect)."
26-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && mkdir -p api/$version && tar -xvz --strip-component 2 -f scala-docs-$version.tgz -C api/$version && mv api/$version/scala-library/* api/$version/" # tar on jenkins does not support the -s option
24+
ssh chara "cd $archivesDir && mkdir -p api/$version && tar -xvz --strip-component 2 -f scala-docs-$version.tgz -C api/$version && mv api/$version/scala-library/* api/$version/" # tar on jenkins does not support the -s option
2725

2826
echo "Expanding the Scaladoc for other bundled modules"
2927
modules="scala-parser-combinators scala-swing scala-xml"
3028
for m in $modules; do
31-
ssh "${sshCharaArgs[@]}" "(set -x; cd $archivesDir && mkdir -p api/$version/$m && unzip \$(find api/$version/jars -name ${m}_'*javadoc.jar' -o -name ${m}-${version}-javadoc.jar) -d api/$version/$m;)"
29+
ssh chara "(set -x; cd $archivesDir && mkdir -p api/$version/$m && unzip \$(find api/$version/jars -name ${m}_'*javadoc.jar' -o -name ${m}-${version}-javadoc.jar) -d api/$version/$m;)"
3230
done
33-
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash -ex
2-
# need to re-declare it as an array, not sure how to do that directly in jenkins
3-
declare -a sshCharaArgs="$sshCharaArgs"
42

53
if [[ "$version" =~ ^.*-(bin|pre)-[0-9a-f]+$ ]]
64
then archivesDir="~linuxsoft/archives/scala/nightly/2.12.x"
@@ -9,8 +7,7 @@ fi
97

108
echo "Symlinking $archivesDir/api/$version to $archivesDir/api/2.12.x."
119

12-
ssh "${sshCharaArgs[@]}" "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn $version 2.12.x"
10+
ssh chara "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn $version 2.12.x"
1311

1412
# needs to run once on new major release:
15-
# ssh "${sshCharaArgs[@]}" "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn 2.12.x current"
16-
13+
# ssh chara "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn 2.12.x current"

0 commit comments

Comments
 (0)