-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
84 lines (75 loc) · 2.62 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ThisBuild / scalaVersion := "2.13.4"
ThisBuild / organization := "io.metacall"
ThisBuild / organizationName := "MetaCall"
import Tests._
val commonScalacOptions = Seq(
// Only for debugging purposes
// "-Djava.compiler=NONE",
"-feature",
"-deprecation",
"-Wunused:imports,patvars,privates,locals,explicits,implicits,params",
"-Xlint",
"-explaintypes",
"-Wdead-code",
"-Wextra-implicit",
"-Wnumeric-widen",
"-Wconf:cat=lint-byname-implicit:silent"
)
lazy val dockerTest = taskKey[Unit]("Run tests in metacall/core:dev")
dockerTest := {
import scala.sys.process._
import java.nio.file.Paths
import sbt.Keys.streams
val logger = streams.value.log
logger.info(
"Run `./docker-compose.sh build` in the root of metacall/core first to get the latest metacall/core:dev image"
)
if (
s"""docker run --rm --mount type=bind,source=${Paths
.get("")
.toAbsolutePath()
.toString()},target=/tests metacall-scala-tests""".! != 0
) {
logger.err("TIP: Run `sbt build` if the image `metacall-scala-tests` doesn't exist")
throw new Exception("Failed to run tests in docker. Check printed errors for clews")
}
}
lazy val root = (project in file("."))
.settings(
name := "metacall-scala",
version := "0.1.0",
fork in Test := true,
testGrouping in Test := (testGrouping in Test).value.flatMap { group =>
group.tests map (test => Group(test.name, Seq(test), SubProcess(ForkOptions())))
},
scalacOptions ++= commonScalacOptions,
scalacOptions in (Compile, console) := Seq.empty,
libraryDependencies ++= Seq(
"net.java.dev.jna" % "jna" % "5.6.0",
"com.chuusai" %% "shapeless" % "2.3.3",
"org.scalatest" %% "scalatest" % "3.2.2" % Test
),
dockerfile in docker := new Dockerfile {
from("metacall/core:dev")
// Set up Scala and SBT using Coursier
workDir("/")
run("curl", "-fLo", "cs", "https://git.io/coursier-cli-linux")
run("chmod", "+x", "cs")
run("./cs", "setup", "--env", "--jvm", "11", "--apps", "sbt-launcher")
env(
"JAVA_HOME" -> "/root/.cache/coursier/jvm/adopt@1.11.0-9",
"PATH" -> "/root/.cache/coursier/jvm/adopt@1.11.0-9/bin:/root/.local/share/coursier/bin:$PATH"
)
// To set up dependencies and SBT
import java.nio.file.Paths
copy(Paths.get("").toAbsolutePath().toFile(), new File("/_tests"))
workDir("/_tests")
run("sbt", "compile")
// The SBT project root
volume("/tests")
workDir("/tests/")
entryPoint("sbt", "test")
},
imageNames in docker := Seq(ImageName("metacall-scala-tests"))
)
.enablePlugins(DockerPlugin)