sbt/scripts/travis.sh

212 lines
5.5 KiB
Bash
Raw Normal View History

2017-02-27 16:15:15 +01:00
#!/usr/bin/env bash
Add json report to fetch and local exclusion option (#692) This patch introduces changes for cli with json output #659. Format as follows: ``` { "conflict_resolution": { "org:name:version" (requested): "org:name:version" (reconciled) }, "dependencies": [ { "coord": "orgA:nameA:versionA", "files": [ [ <classifier>, <path> ] ], "dependencies": [ // coodinates for its transitive dependencies <orgX:nameX:versionX>, <orgY:nameY:versionY>, ] }, { "coord": "orgB:nameB:versionB", "files": [ [ <classifier>, <path> ] ], "dependencies": [ // coodinates for its transitive dependencies <orgX:nameX:versionX>, <orgZ:nameZ:versionZ>, ] }, ] } ``` For example: ``` fetch -t org.apache.avro:trevni-avro:1.8.2 org.slf4j:slf4j-api:1.7.6 --json-output-file x.out Result: ├─ org.apache.avro:trevni-avro:1.8.2 │ ├─ org.apache.avro:trevni-core:1.8.2 │ │ ├─ org.apache.commons:commons-compress:1.8.1 │ │ ├─ org.slf4j:slf4j-api:1.7.7 │ │ └─ org.xerial.snappy:snappy-java:1.1.1.3 │ └─ org.slf4j:slf4j-api:1.7.7 └─ org.slf4j:slf4j-api:1.7.6 -> 1.7.7 ``` would produce the following json file: ``` $ jq < x.out { "conflict_resolution": { "org.slf4j:slf4j-api:1.7.6": "org.slf4j:slf4j-api:1.7.7" }, "dependencies": [ { "coord": "org.apache.avro:trevni-core:1.8.2", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/avro/trevni-core/1.8.2/trevni-core-1.8.2.jar" ] ], "dependencies": [ "org.slf4j:slf4j-api:1.7.7", "org.xerial.snappy:snappy-java:1.1.1.3", "org.apache.commons:commons-compress:1.8.1" ] }, { "coord": "org.apache.avro:trevni-avro:1.8.2", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/avro/trevni-avro/1.8.2/trevni-avro-1.8.2.jar" ] ], "dependencies": [ "org.apache.avro:trevni-core:1.8.2", "org.slf4j:slf4j-api:1.7.7", "org.xerial.snappy:snappy-java:1.1.1.3", "org.apache.commons:commons-compress:1.8.1" ] }, { "coord": "org.slf4j:slf4j-api:1.7.7", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar" ] ], "dependencies": [] }, { "coord": "org.apache.commons:commons-compress:1.8.1", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar" ] ], "dependencies": [] }, { "coord": "org.xerial.snappy:snappy-java:1.1.1.3", "files": [ [ "", "/Users/yic/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.1.3/snappy-java-1.1.1.3.jar" ] ], "dependencies": [] } ] } ```
2017-12-26 19:46:35 +01:00
set -evx
2015-06-16 20:17:07 +02:00
2017-02-27 16:15:15 +01:00
setupCoursierBinDir() {
mkdir -p bin
cp coursier bin/
export PATH="$(pwd)/bin:$PATH"
2015-06-16 20:17:07 +02:00
}
2017-02-27 16:15:15 +01:00
downloadInstallSbtExtras() {
2017-07-08 14:18:03 +02:00
mkdir -p bin
2017-02-27 16:15:15 +01:00
curl -L -o bin/sbt https://github.com/paulp/sbt-extras/raw/9ade5fa54914ca8aded44105bf4b9a60966f3ccd/sbt
chmod +x bin/sbt
2015-06-16 20:17:07 +02:00
}
2017-02-27 16:15:15 +01:00
integrationTestsRequirements() {
# Required for ~/.ivy2/local repo tests
sbt scala211 coreJVM/publishLocal scala212 cli/publishLocal
2015-06-16 20:17:07 +02:00
}
2017-02-27 16:15:15 +01:00
isScalaJs() {
[ "$SCALA_JS" = 1 ]
}
2016-05-06 13:53:55 +02:00
sbtCoursier() {
[ "$SBT_COURSIER" = 1 ]
}
sbtShading() {
[ "$SBT_SHADING" = 1 ]
}
2017-02-27 16:15:15 +01:00
runSbtCoursierTests() {
2017-06-06 19:51:38 +02:00
addPgpKeys
2018-09-20 16:17:55 +02:00
./scripts/with-test-repo.sh sbt scalaFromEnv sbt-coursier/scripted
sbt scalaFromEnv sbt-pgp-coursier/scripted
2017-02-27 16:15:15 +01:00
}
runSbtShadingTests() {
2018-09-20 16:17:55 +02:00
sbt scalaFromEnv sbt-shading/scripted
2017-02-27 16:15:15 +01:00
}
2015-06-17 19:36:53 +02:00
2017-02-27 16:15:15 +01:00
jsCompile() {
sbt scalaFromEnv js/compile js/test:compile coreJS/fastOptJS cacheJS/fastOptJS testsJS/test:fastOptJS js/test:fastOptJS
2017-02-27 16:15:15 +01:00
}
2016-04-06 22:38:10 +02:00
2017-02-27 16:15:15 +01:00
jvmCompile() {
sbt scalaFromEnv jvm/compile jvm/test:compile
2017-02-27 16:15:15 +01:00
}
2017-01-30 22:57:24 +01:00
2017-02-27 16:15:15 +01:00
runJsTests() {
sbt scalaFromEnv js/test
2017-02-27 16:15:15 +01:00
}
2017-01-30 22:57:24 +01:00
2017-02-27 16:15:15 +01:00
runJvmTests() {
if [ "$(uname)" == "Darwin" ]; then
IT="testsJVM/it:test" # don't run proxy-tests in particular
else
IT="jvm/it:test"
fi
./scripts/with-test-repo.sh sbt scalaFromEnv jvm/test $IT
2017-02-27 16:15:15 +01:00
}
2017-01-30 22:57:24 +01:00
2017-02-27 16:15:15 +01:00
validateReadme() {
# check that tut runs fine, and that the README doesn't change after a `sbt tut`
mv README.md README.md.orig
if [ "$SCALA_VERSION" = 2.12 ]; then
# Later 2.12 versions seem to make tut not see the coursier binaries
sbt '++2.12.1!' tut
else
sbt scalaFromEnv tut
fi
if cmp -s README.md.orig README.md; then
echo "README.md doesn't change"
else
echo "Error: README.md not the same after a \"sbt tut\":"
diff -u README.md.orig README.md
exit 1
fi
2017-02-27 16:15:15 +01:00
}
2017-01-30 22:57:24 +01:00
2017-02-27 16:15:15 +01:00
checkBinaryCompatibility() {
sbt scalaFromEnv coreJVM/mimaReportBinaryIssues cacheJVM/mimaReportBinaryIssues
2017-02-27 16:15:15 +01:00
}
2017-01-30 22:57:24 +01:00
2017-05-05 18:04:20 +02:00
testBootstrap() {
if [ "$SCALA_VERSION" = 2.12 ]; then
sbt scalaFromEnv "project cli" pack
2018-04-30 00:02:01 +02:00
cli/target/pack/bin/coursier bootstrap -o cs-echo io.get-coursier:echo:1.0.1
local OUT="$(./cs-echo foo)"
if [ "$OUT" != foo ]; then
2017-05-05 18:04:20 +02:00
echo "Error: unexpected output from bootstrapped echo command." 1>&2
exit 1
fi
if echo "$OSTYPE" | grep -q darwin; then
GREP="ggrep"
else
GREP="grep"
fi
CURRENT_VERSION="$("$GREP" -oP '(?<=")[^"]*(?<!")' version.sbt)"
sbt scalaFromEnv cli/publishLocal
ACTUAL_VERSION="$CURRENT_VERSION" OUTPUT="coursier-test" scripts/generate-launcher.sh -r ivy2Local
./coursier-test bootstrap -o cs-echo-launcher io.get-coursier:echo:1.0.0
if [ "$(./cs-echo-launcher foo)" != foo ]; then
echo "Error: unexpected output from bootstrapped echo command (generated by proguarded launcher)." 1>&2
exit 1
fi
if [ "$(./cs-echo-launcher -J-Dother=thing foo -J-Dfoo=baz)" != foo ]; then
echo "Error: unexpected output from bootstrapped echo command (generated by proguarded launcher)." 1>&2
exit 1
fi
if [ "$(./cs-echo-launcher "-n foo")" != "-n foo" ]; then
echo "Error: unexpected output from bootstrapped echo command (generated by proguarded launcher)." 1>&2
exit 1
fi
# run via the launcher rather than via the sbt-pack scripts, because the latter interprets -Dfoo=baz itself
# rather than passing it to coursier since https://github.com/xerial/sbt-pack/pull/118
./coursier-test bootstrap -o cs-props -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2
local OUT="$(./cs-props foo)"
if [ "$OUT" != baz ]; then
echo -e "Error: unexpected output from bootstrapped props command.\n$OUT" 1>&2
exit 1
fi
local OUT="$(./cs-props other)"
if [ "$OUT" != thing ]; then
echo -e "Error: unexpected output from bootstrapped props command.\n$OUT" 1>&2
exit 1
fi
if [ "$(./cs-props -J-Dhappy=days happy)" != days ]; then
echo "Error: unexpected output from bootstrapped props command." 1>&2
exit 1
fi
# assembly tests
./coursier-test bootstrap -a -o cs-props-assembly -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2
local OUT="$(./cs-props-assembly foo)"
if [ "$OUT" != baz ]; then
echo -e "Error: unexpected output from assembly props command.\n$OUT" 1>&2
exit 1
fi
local OUT="$(./cs-props-assembly other)"
if [ "$OUT" != thing ]; then
echo -e "Error: unexpected output from assembly props command.\n$OUT" 1>&2
exit 1
fi
2017-05-05 18:04:20 +02:00
fi
}
2017-07-08 14:18:03 +02:00
testNativeBootstrap() {
if [ "$SCALA_VERSION" = "2.12" -a "$NATIVE" = "1" ]; then
sbt scalaFromEnv "project cli" pack
cli/target/pack/bin/coursier bootstrap -S -o native-echo io.get-coursier:echo_native0.3_2.11:1.0.1
if [ "$(./native-echo -n foo a)" != "foo a" ]; then
2017-07-08 14:18:03 +02:00
echo "Error: unexpected output from native test bootstrap." 1>&2
exit 1
fi
fi
}
2017-06-06 19:51:38 +02:00
addPgpKeys() {
for key in b41f2bce 9fa47a44 ae548ced b4493b94 53a97466 36ee59d9 dc426429 3b80305d 69e0a56c fdd5c0cd 35543c27 70173ee5 111557de 39c263a9; do
gpg --keyserver keyserver.ubuntu.com --recv "$key"
done
}
2017-02-27 16:15:15 +01:00
# TODO Add coverage once https://github.com/scoverage/sbt-scoverage/issues/111 is fixed
downloadInstallSbtExtras
2017-07-08 14:18:03 +02:00
setupCoursierBinDir
2017-02-27 16:15:15 +01:00
if isScalaJs; then
jsCompile
runJsTests
else
2017-07-08 14:18:03 +02:00
testNativeBootstrap
2017-02-27 16:15:15 +01:00
integrationTestsRequirements
jvmCompile
if sbtCoursier; then
2018-09-20 16:17:55 +02:00
if [ "$SCALA_VERSION" = "2.12" ]; then
runSbtCoursierTests
fi
elif sbtShading; then
2018-09-20 16:17:55 +02:00
if [ "$SCALA_VERSION" = "2.12" ]; then
runSbtShadingTests
fi
else
runJvmTests
2016-04-06 22:38:10 +02:00
2018-05-21 18:30:54 +02:00
testBootstrap
validateReadme
checkBinaryCompatibility
2017-02-27 16:15:15 +01:00
fi
2015-06-16 20:17:07 +02:00
fi
2015-06-17 19:36:53 +02:00