-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
136 lines (124 loc) · 5.5 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
ThisBuild / organization := "org.felher"
ThisBuild / organizationName := "Felix Herrmann"
ThisBuild / version := "0.17.1"
ThisBuild / organizationHomepage := Some(url("https://felher.org"))
ThisBuild / scalaVersion := "3.3.4"
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/felher/laminouter/"),
"scm:[email protected]:felher/laminouter.git"
)
)
ThisBuild / developers := List(
Developer(
id = "felher",
name = "Felix Herrmann",
email = "[email protected]",
url = url("https://felher.org")
)
)
ThisBuild / description := "An ergonomic but minimalistic-to-a-fault router for Laminar"
ThisBuild / licenses := List(sbt.librarymanagement.License.MIT)
ThisBuild / homepage := Some(url("https://github.com/felher/laminouter/"))
ThisBuild / publishTo := sonatypePublishToBundle.value
ThisBuild / publishMavenStyle := true
lazy val root = project
.in(file("."))
.enablePlugins(ScalaJSPlugin)
.settings(
name := "laminouter",
usePgpKeyHex("DE132E3B66E5239F490F52AB3DA07E9E7CFDB415"),
Test / publishArtifact := true,
mimaPreviousArtifacts := Set("org.felher" %%% "laminouter" % "0.17.0"),
scalacOptions ++= Seq(
"-language:strictEquality",
"-feature",
"-deprecation",
"-Ykind-projector:underscores",
"-Ysafe-init",
"-Xmax-inlines:256",
"-Wunused:all",
"-Wvalue-discard",
"-Wconf:any:verbose"
),
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "2.8.0",
"com.raquo" %%% "laminar" % "17.1.0" % Provided,
"com.lihaoyi" %%% "utest" % "0.8.4" % Test
),
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv(),
testFrameworks += new TestFramework("utest.runner.Framework")
)
lazy val testMatrix = project
.in(file("test-matrix"))
.enablePlugins(ScalaJSPlugin)
.settings(
libraryDependencies ++= Seq(
"com.raquo" %%% "laminar" % "17.1.0",
"org.felher" %%% "laminouter" % "0.17.1",
"org.felher" %%% "laminouter" % "0.17.1" % Test classifier "tests",
"com.lihaoyi" %%% "utest" % "0.8.4" % Test
),
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv(),
testFrameworks += new TestFramework("utest.runner.Framework"),
commands += Command.command("testLaminarCompatibility") { state =>
final case class CompatTestKey(
scalaVersion: String,
laminarVersion: String,
laminouterVersion: String
)
val laminarVersions = List("0.14.5", "15.0.1", "16.0.0", "17.0.0", "17.1.0")
val laminouterVersions = List("0.17.0", "0.17.1")
val scalaVersions = List("3.3.4")
val allTestKeys = for {
scalaVersion <- scalaVersions
laminarVersion <- laminarVersions
laminouterVersion <- laminouterVersions
} yield CompatTestKey(scalaVersion, laminarVersion, laminouterVersion)
def setVersions(depList: Seq[ModuleID], laminarVersion: String, laminouterVersion: String): Seq[ModuleID] =
depList.map(dep => {
if (dep.organization == "com.raquo" && dep.name == "laminar") {
dep.withRevision(laminarVersion)
} else if (dep.organization == "org.felher" && dep.name == "laminouter") {
dep.withRevision(laminouterVersion)
} else {
dep
}
})
val results = allTestKeys.foldLeft(Map.empty[CompatTestKey, Boolean])((results, testKey) => {
// this code is tricky. The scalajs plugin changes the dependency list depending on the scala version.
// So just adding `scalaVersion := "3.3.4"` to the `newSettings`
// list doesn't work, because the old dependency list is out of date.
//
// Instead of adding a setting, we set the new scala using the `set` command, which seems
// to trigger scalajs updating the dependency list.
val withNewScala = Command.process("set scalaVersion := \"" + testKey.scalaVersion + "\"", state)
val oldDepList = Project.extract(withNewScala).get(libraryDependencies)
val newDepList = setVersions(oldDepList, testKey.laminarVersion, testKey.laminouterVersion)
val newSettings = Seq(libraryDependencies := newDepList)
val testState = Project.extract(withNewScala).appendWithSession(newSettings, withNewScala)
val testsOk = Project.runTask(Test / test, testState).fold(false)(_._2.toEither.isRight)
results + (testKey -> testsOk)
})
val header = "||" + laminouterVersions.map("Laminouter " + _).mkString("|") + "|"
val sepator = "|" + List.fill(laminouterVersions.size + 1)("-").mkString("|") + "|"
def makeCell(laminarVersion: String, laminouterVersion: String): String = {
val passed = results.filter(entry =>
entry._1.laminarVersion == laminarVersion && entry._1.laminouterVersion == laminouterVersion && entry._2
)
if (passed.isEmpty) {
"❌"
} else {
"scala " + passed.keys.map(_.scalaVersion).toList.sorted.map(_.replaceAll("\\.\\d+$", "")).mkString(", ")
}
}
def makeRow(laminarVersion: String): String = {
val cells = laminouterVersions.map(makeCell(laminarVersion, _))
s"| Laminar $laminarVersion | ${cells.mkString("|")} |"
}
println(header)
println(sepator)
laminarVersions.foreach(laminarVersion => println(makeRow(laminarVersion)))
state
}
)