Skip to content

Commit 4e15cba

Browse files
authored
Various build improvements (#177)
1 parent 5e72978 commit 4e15cba

File tree

9 files changed

+93
-112
lines changed

9 files changed

+93
-112
lines changed

.github/workflows/build.yml

+11-24
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,29 @@ jobs:
2121
sudo apt-get update
2222
unit_version="1.33*"
2323
sudo apt-get install -y libuv1-dev libidn2-dev unit=$unit_version unit-dev=$unit_version
24-
- uses: actions/setup-java@v3
25-
with:
26-
java-version: "11"
27-
architecture: "x64"
28-
distribution: "temurin"
2924
- name: Download dependencies
3025
run: |
31-
./mill --disable-ticker __.prepareOffline
26+
./mill --ticker false __.prepareOffline
3227
- name: Check formatting
3328
run: |
34-
./mill --disable-ticker mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
35-
./mill --disable-ticker --meta-level 1 mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
29+
./mill --ticker false mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
30+
./mill --ticker false --meta-level 1 mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
3631
# - name: Check scalafix
37-
# run: ./mill --disable-ticker __.fix --check
32+
# run: ./mill --ticker false __.fix --check
3833
- name: Compile
39-
run: ./mill --disable-ticker __.compile
34+
run: ./mill --ticker false __.compile
4035
- name: Publish libraries locally
41-
run: ./mill --disable-ticker __.publishLocal
36+
run: ./mill --ticker false __.publishLocal
4237
- name: Run Unit Tests
43-
run: ./mill --disable-ticker snunit[_].test
38+
run: ./mill --ticker false snunit.test
4439
- name: Run Integration Tests
4540
run: |
4641
sudo systemctl stop unit.service
47-
./mill --disable-ticker integration.test
42+
./mill --ticker false integration.test
4843
- name: Start NGINX Unit daemon
4944
run: sudo systemctl start unit.service
5045
- name: Run Mill Plugin Tests
51-
run: ./mill -i --disable-ticker snunit-mill-plugin.__.test
46+
run: ./mill -i --ticker false snunit-mill-plugin.__.test
5247
# - name: Build and Test Sbt plugin
5348
# run: |
5449
# (
@@ -62,12 +57,8 @@ jobs:
6257
- uses: actions/checkout@v3
6358
with:
6459
fetch-depth: 0
65-
- uses: actions/setup-java@v3
66-
with:
67-
distribution: "temurin"
68-
java-version: "11"
6960
- name: Check Binary Compatibility
70-
run: ./mill --disable-ticker __.mimaReportBinaryIssues
61+
run: ./mill --ticker false __.mimaReportBinaryIssues
7162

7263
publish-sonatype:
7364
if: github.repository == 'lolgab/snunit' && contains(github.ref, 'refs/tags/')
@@ -91,12 +82,8 @@ jobs:
9182
with:
9283
path: ./out
9384
key: out
94-
- uses: actions/setup-java@v3
95-
with:
96-
distribution: "temurin"
97-
java-version: "11"
9885
- name: Publish plugin shared locally
99-
run: ./mill --disable-ticker snunit-plugins-shared.__.publishLocal
86+
run: ./mill --ticker false snunit-plugins-shared.__.publishLocal
10087
- run: ./mill io.kipp.mill.ci.release.ReleaseModule/publishAll
10188
env:
10289
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}

.mill-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.8
1+
0.12.8-20-113706-native

build.mill.scala

+61-59
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import $ivy.`com.github.lolgab::mill-mima::0.1.0`
88

99
import mill._, mill.scalalib._, mill.scalanativelib._, mill.scalanativelib.api._
1010
import mill.scalalib.publish._
11+
import mill.util.Jvm
1112
import com.goyeau.mill.scalafix.ScalafixModule
1213
import io.kipp.mill.ci.release.CiReleaseModule
1314
import mill.contrib.buildinfo.BuildInfo
@@ -38,7 +39,10 @@ object Common {
3839
def scalacOptions = super.scalacOptions() ++
3940
Seq("-deprecation")
4041
}
41-
trait SharedNative extends Shared with ScalaNativeModule {
42+
trait Jvm extends Shared {
43+
def scalaVersion = Versions.scala3
44+
}
45+
trait Native extends Jvm with ScalaNativeModule {
4246
def scalaNativeVersion = versions.Versions.scalaNative
4347

4448
def baseTestConfig(binary: os.Path) = {
@@ -64,17 +68,6 @@ object Common {
6468
}
6569

6670
}
67-
68-
trait Scala3Only extends SharedNative {
69-
def crossScalaVersion = Versions.scala3
70-
def scalaVersion = crossScalaVersion
71-
}
72-
trait Scala3OnlyJvm extends Shared {
73-
def crossScalaVersion = Versions.scala3
74-
def scalaVersion = crossScalaVersion
75-
}
76-
trait Cross extends CrossScalaModule with SharedNative
77-
trait CrossJvm extends CrossScalaModule with Shared
7871
}
7972

8073
trait Publish extends CiReleaseModule with Mima {
@@ -93,16 +86,14 @@ trait Publish extends CiReleaseModule with Mima {
9386
// Remove after first release with Scala Native 0.5
9487
def mimaPreviousArtifacts = Task { Seq.empty }
9588
}
96-
object snunit extends Cross[SNUnitModule](scalaVersions)
97-
trait SNUnitModule extends Common.Cross with Publish {
89+
object snunit extends Common.Native with Publish {
9890
object test extends ScalaNativeTests with TestModule.Utest {
9991
def ivyDeps = super.ivyDeps() ++ Agg(utest)
10092
}
10193
}
10294

103-
// object `snunit-async-cats-effect` extends Cross[SNUnitAsyncCatsEffectModule](scalaVersions)
104-
// trait SNUnitAsyncCatsEffectModule extends Common.Cross with Publish {
105-
// def moduleDeps = Seq(snunit())
95+
// object `snunit-async-cats-effect` extends Common.Native with Publish {
96+
// def moduleDeps = Seq(snunit)
10697

10798
// def ivyDeps =
10899
// Task {
@@ -112,33 +103,46 @@ trait SNUnitModule extends Common.Cross with Publish {
112103
// }
113104
// }
114105

115-
object `snunit-undertow` extends Cross[SNUnitUndertow](scalaVersions)
116-
trait SNUnitUndertow extends Common.Cross with Publish {
117-
def moduleDeps = Seq(snunit())
106+
object `snunit-undertow` extends Common.Native with Publish {
107+
def moduleDeps = Seq(snunit)
108+
def ivyDeps = super.ivyDeps() ++ Agg(undertow)
109+
// Remove class and tasty files
110+
override def jar = Task {
111+
Jvm.createJar(
112+
localClasspath().map(_.path).filter(os.exists),
113+
manifest(),
114+
(_, file) =>
115+
file.ext match {
116+
case "class" | "tasty" => false
117+
case _ => true
118+
}
119+
)
120+
}
121+
// Sometimes it gives problems compiling since our internal API is different
122+
// than the java API in the class files.
123+
def zincIncrementalCompilation = false
118124
}
119125

120-
object `snunit-tapir` extends Cross[SNUnitTapirModule](scalaVersions)
121-
trait SNUnitTapirModule extends Common.Cross with Publish {
122-
def moduleDeps = Seq(snunit())
126+
object `snunit-tapir` extends Common.Native with Publish {
127+
def moduleDeps = Seq(snunit)
123128
def ivyDeps = super.ivyDeps() ++ Agg(ivy"com.softwaremill.sttp.tapir::tapir-server::${Versions.tapir}")
124129
}
125-
// object `snunit-tapir-cats-effect` extends Cross[SNUnitTapirCatsEffect](scalaVersions)
126-
// trait SNUnitTapirCatsEffect extends Common.Cross with Publish {
130+
// object `snunit-tapir-cats-effect` extends Common.Native with Publish {
127131
// def moduleDeps = Seq(
128-
// `snunit-tapir`(),
129-
// `snunit-async-cats-effect`()
132+
// `snunit-tapir`,
133+
// `snunit-async-cats-effect`
130134
// )
131135
// def ivyDeps = super.ivyDeps() ++ Agg(
132136
// ivy"com.softwaremill.sttp.tapir::tapir-cats-effect::${Versions.tapir}"
133137
// )
134138
// }
135139

136-
// object `snunit-http4s` extends Cross[SNUnitHttp4s](http4sAndScalaVersions)
137-
// trait SNUnitHttp4s extends Common.Cross with Cross.Module2[String, String] with Publish {
138-
// val http4sVersion = crossValue2
140+
// object `snunit-http4s` extends Cross[SNUnitHttp4s]
141+
// trait SNUnitHttp4s extends Common.Native with Cross.Module[String] with Publish {
142+
// val http4sVersion = crossValue
139143
// def moduleDeps = Seq(
140-
// snunit(),
141-
// `snunit-async-cats-effect`()
144+
// snunit,
145+
// `snunit-async-cats-effect`
142146
// )
143147
// val http4sBinaryVersion = http4sVersion match {
144148
// case s"0.23.$_" => "0.23"
@@ -165,14 +169,13 @@ def castorSources = Task {
165169
.call()
166170
PathRef(dest)
167171
}
168-
object `snunit-cask` extends Cross[SNUnitCaskModule](scalaVersions)
169-
trait SNUnitCaskModule extends Common.Cross with Publish {
172+
object `snunit-cask` extends Common.Native with Publish {
170173
override def generatedSources = Task {
171174
val cask = caskSources().path / "cask"
172175
val castor = castorSources().path / "castor"
173176
Seq(cask / "src", cask / "util" / "src", cask / "src-3", castor / "src", castor / "src-js-native").map(PathRef(_))
174177
}
175-
def moduleDeps = Seq(`snunit-undertow`(crossScalaVersion))
178+
def moduleDeps = Seq(`snunit-undertow`)
176179
def ivyDeps = super.ivyDeps() ++ Agg(
177180
upickle,
178181
ivy"io.github.cquiroz::scala-java-time::${Versions.scalaJavaTime}",
@@ -182,62 +185,61 @@ trait SNUnitCaskModule extends Common.Cross with Publish {
182185

183186
object integration extends ScalaModule {
184187
object tests extends Module {
185-
object `hello-world` extends Cross[HelloWorld](scalaVersions)
186-
trait HelloWorld extends Common.Cross {
187-
def moduleDeps = Seq(snunit())
188+
object `hello-world` extends Common.Native {
189+
def moduleDeps = Seq(snunit)
188190
}
189-
object `websocket-echo` extends Common.Scala3Only {
190-
def moduleDeps = Seq(snunit(crossScalaVersion))
191+
object `websocket-echo` extends Common.Native {
192+
def moduleDeps = Seq(snunit)
191193
}
192-
object `multiple-handlers` extends Common.Scala3Only {
193-
def moduleDeps = Seq(snunit(crossScalaVersion))
194+
object `multiple-handlers` extends Common.Native {
195+
def moduleDeps = Seq(snunit)
194196
}
195197
object `undertow-helloworld` extends CrossPlatform {
196-
object native extends CrossPlatformScalaModule with Common.Scala3Only {
197-
def moduleDeps = Seq(`snunit-undertow`(crossScalaVersion))
198+
object native extends CrossPlatformScalaModule with Common.Native {
199+
def moduleDeps = Seq(`snunit-undertow`)
198200
}
199-
object jvm extends CrossPlatformScalaModule with Common.Scala3OnlyJvm {
201+
object jvm extends CrossPlatformScalaModule with Common.Jvm {
200202
def ivyDeps = super.ivyDeps() ++ Agg(undertow)
201203
}
202204
}
203205
object `cask-helloworld` extends CrossPlatform {
204-
object jvm extends CrossPlatformScalaModule with Common.Scala3OnlyJvm {
206+
object jvm extends CrossPlatformScalaModule with Common.Jvm {
205207
def ivyDeps = super.ivyDeps() ++ Agg(
206208
ivy"com.lihaoyi::cask:${Versions.cask}"
207209
)
208210
}
209-
object native extends CrossPlatformScalaModule with Common.Scala3Only {
210-
def moduleDeps = Seq(`snunit-cask`(crossScalaVersion))
211+
object native extends CrossPlatformScalaModule with Common.Native {
212+
def moduleDeps = Seq(`snunit-cask`)
211213
}
212214
}
213-
object `tapir-helloworld` extends Common.Scala3Only {
214-
override def moduleDeps = Seq(`snunit-tapir`(crossScalaVersion))
215+
object `tapir-helloworld` extends Common.Native {
216+
override def moduleDeps = Seq(`snunit-tapir`)
215217
}
216-
// object `tapir-app` extends Common.Scala3Only {
217-
// override def moduleDeps = Seq(`snunit-tapir-cats-effect`(crossScalaVersion))
218+
// object `tapir-app` extends Common.Native {
219+
// override def moduleDeps = Seq(`snunit-tapir-cats-effect`)
218220
// }
219221
// object `http4s-helloworld` extends Cross[Http4sHelloWorldModule](http4sVersions)
220-
// trait Http4sHelloWorldModule extends Common.Scala3Only with Cross.Module[String] {
222+
// trait Http4sHelloWorldModule extends Common.Native with Cross.Module[String] {
221223
// def http4sVersion = crossValue
222224
// def moduleDeps = Seq(
223-
// `snunit-http4s`(crossScalaVersion, http4sVersion)
225+
// `snunit-http4s`(http4sVersion)
224226
// )
225227
// def ivyDeps = super.ivyDeps() ++ Agg(
226228
// ivy"org.http4s::http4s-dsl::$http4sVersion"
227229
// )
228230
// }
229-
// object `http4s-app` extends Common.Scala3Only {
231+
// object `http4s-app` extends Common.Native {
230232
// val http4sVersion = Versions.http4s1
231233
// def moduleDeps = Seq(
232-
// `snunit-http4s`(crossScalaVersion, http4sVersion)
234+
// `snunit-http4s`(http4sVersion)
233235
// )
234236
// def ivyDeps = super.ivyDeps() ++ Agg(
235237
// ivy"org.http4s::http4s-dsl::$http4sVersion"
236238
// )
237239
// }
238-
// object `tapir-helloworld-cats-effect` extends Common.Scala3Only {
240+
// object `tapir-helloworld-cats-effect` extends Common.Native {
239241
// def moduleDeps = Seq(
240-
// `snunit-tapir-cats-effect`(crossScalaVersion)
242+
// `snunit-tapir-cats-effect`
241243
// )
242244
// }
243245
}
@@ -288,7 +290,7 @@ object `snunit-mill-plugin` extends Common.Shared with Publish with BuildInfo {
288290
def mainClass = Some("mill.runner.client.MillClientMain")
289291
def resources = Task {
290292
// make sure snunit is published
291-
snunit(versions.Versions.scala3).publishLocal()()
293+
snunit.publishLocal()()
292294

293295
val p = Task.dest / "mill/local-test-overrides" / s"com.lihaoyi-${`snunit-mill-plugin`.artifactId()}"
294296
os.write(p, `snunit-mill-plugin`.localClasspath().map(_.path).mkString("\n"), createFolders = true)

integration/test/src/BaseTests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import utest._
55
object BaseTests extends TestSuite {
66
val tests = Tests {
77
test("hello-world") {
8-
withDeployedExampleCross("hello-world") {
8+
withDeployedExample("hello-world") {
99
locally {
1010
val result = request.get(baseUrl).text()
1111
val expectedResult = "Hello world!\n"

integration/test/src/utils.scala

+4-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ private def runMillCommand(command: String) = os
1212
"./mill",
1313
// adding `-i` breaks the ability to close unitd processes
1414
"--no-build-lock",
15-
"--disable-ticker",
15+
"--ticker",
16+
"false",
1617
"show",
1718
command
1819
)
@@ -29,8 +30,8 @@ def withDeployedExampleHttp4s(projectName: String)(f: => Unit) = {
2930
withDeployedExample(projectName, s"[$versions]")(f)
3031
}
3132
}
32-
def withDeployedExampleMultiplatform(projectName: String, crossSuffix: String = "")(f: => Unit) = {
33-
val projectPrefix = s"integration.tests.$projectName$crossSuffix"
33+
def withDeployedExampleMultiplatform(projectName: String)(f: => Unit) = {
34+
val projectPrefix = s"integration.tests.$projectName"
3435
runMillCommand(s"$projectPrefix.native.deployTestApp")
3536
val result = runMillCommand(s"$projectPrefix.jvm.launcher").out.lines().head
3637
val s""""$_:$_:$_:$path"""" = result: @unchecked
@@ -39,16 +40,6 @@ def withDeployedExampleMultiplatform(projectName: String, crossSuffix: String =
3940
try { f }
4041
finally { process.close() }
4142
}
42-
def withDeployedExampleMultiplatformCross(projectName: String)(f: => Unit) = {
43-
BuildInfo.scalaVersions.split(':').foreach { scalaVersion =>
44-
withDeployedExampleMultiplatform(projectName, s"[$scalaVersion]")(f)
45-
}
46-
}
47-
def withDeployedExampleCross(projectName: String)(f: => Unit) = {
48-
BuildInfo.scalaVersions.split(':').foreach { scalaVersion =>
49-
withDeployedExample(projectName, s"[$scalaVersion]")(f)
50-
}
51-
}
5243

5344
private val futureBackend = HttpClientFutureBackend()
5445

sbt-plugin/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ val snunitVersion = Def.setting {
99
val snunitDir = baseDirectory.value / ".."
1010
val versionString =
1111
Process(
12-
Seq("./mill", "--disable-ticker", "show", s"snunit-plugins-shared[${build.Versions.scala212}].publishVersion"),
12+
Seq("./mill", "--ticker", "false", "show", s"snunit-plugins-shared[${build.Versions.scala212}].publishVersion"),
1313
cwd = snunitDir
1414
).!!
1515
val JString(version) = Parser.parseFromString(versionString).get

snunit-undertow/src/io/undertow/server/HttpServerExchange.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.undertow.io.BlockingSenderImpl
55
import io.undertow.io.Sender
66
import io.undertow.server.handlers.Cookie
77
import io.undertow.util.HeaderMap
8+
import io.undertow.util.HttpString
89
import snunit.*
910

1011
import java.io.InputStream
@@ -19,7 +20,7 @@ final class HttpServerExchange private[undertow] (private[undertow] val req: Req
1920

2021
def getRequestHeaders(): HeaderMap = new HeaderMap(req.headers.toMap)
2122
def getResponseHeaders(): HeaderMap = responseHeaders
22-
def getRequestMethod(): String = req.method
23+
def getRequestMethod(): HttpString = HttpString(req.method)
2324
def getInputStream(): InputStream = {
2425
blockingHttpExchange.getInputStream()
2526
}

0 commit comments

Comments
 (0)