Skip to content

Commit 8a42bd9

Browse files
committed
Update Scala SNUnit
1 parent c0164be commit 8a42bd9

File tree

5 files changed

+45
-51
lines changed

5 files changed

+45
-51
lines changed

frameworks/Scala/snunit/build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import scala.scalanative.build._
22

3-
scalaVersion := "2.13.10"
3+
scalaVersion := "3.5.2"
44

5-
val snunitVersion = "0.3.0"
6-
val jsoniterScalaVersion = "2.20.6"
5+
val snunitVersion = "0.10.2"
6+
val jsoniterScalaVersion = "2.31.3"
77

88
libraryDependencies ++= Seq(
99
"com.github.lolgab" %%% "snunit" % snunitVersion,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.8.0
1+
sbt.version=1.10.5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.9")
1+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.6")
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM debian:bullseye-slim as builder
1+
FROM debian:bookworm-slim as builder
22

33
RUN apt-get update && apt-get install -y curl gnupg && \
4-
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" > /etc/apt/sources.list.d/sbt.list && \
4+
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list && \
55
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add - && \
66
curl -sL https://nginx.org/keys/nginx_signing.key | apt-key add - && \
7-
echo "deb https://packages.nginx.org/unit/debian/ bullseye unit" > /etc/apt/sources.list.d/unit.list && \
8-
echo "deb-src https://packages.nginx.org/unit/debian/ bullseye unit" >> /etc/apt/sources.list.d/unit.list && \
9-
apt-get update && apt-get install -y clang unit-dev=1.29* openjdk-11-jdk sbt && \
7+
echo "deb https://packages.nginx.org/unit/debian/ bookworm unit" > /etc/apt/sources.list.d/unit.list && \
8+
echo "deb-src https://packages.nginx.org/unit/debian/ bookworm unit" >> /etc/apt/sources.list.d/unit.list && \
9+
apt-get update && apt-get install -y clang unit-dev=1.33* openjdk-17-jdk sbt=1.10.5 && \
1010
apt-get purge -y gnupg
1111

1212
WORKDIR /workdir
@@ -15,9 +15,9 @@ COPY . .
1515

1616
RUN sbt nativeLink
1717

18-
FROM nginx/unit:1.29.1-minimal
18+
FROM unit:1.33.0-minimal
1919

2020
COPY /config.sh /docker-entrypoint.d/
21-
COPY --from=builder /workdir/target/scala-2.13/workdir-out /app/example
21+
COPY --from=builder /workdir/target/scala-3.5.2/workdir /app/example
2222

2323
EXPOSE 8080
Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
1-
import com.github.plokhotnyuk.jsoniter_scala.core._
2-
import com.github.plokhotnyuk.jsoniter_scala.macros._
3-
import snunit._
1+
import com.github.plokhotnyuk.jsoniter_scala.core.*
2+
import com.github.plokhotnyuk.jsoniter_scala.macros.*
3+
import snunit.*
44

5-
final case class Message(message: String)
5+
final case class Message(message: String) derives ConfiguredJsonValueCodec
66

7-
object Message {
8-
implicit final val codec: JsonValueCodec[Message] = JsonCodecMaker.make
9-
}
7+
final val applicationJson = Headers("Content-Type" -> "application/json")
8+
final val textPlain = Headers("Content-Type" -> "text/plain")
109

11-
object Main {
12-
val applicationJson = Seq("Content-Type" -> "application/json")
13-
val textPlain = Seq("Content-Type" -> "text/plain")
10+
inline def notFound(req: Request) = req.send(
11+
statusCode = StatusCode.NotFound,
12+
content = "Not found",
13+
headers = textPlain
14+
)
1415

15-
@inline
16-
private def notFound(req: Request) = req.send(
17-
statusCode = StatusCode.NotFound,
18-
content = "Not found",
19-
headers = textPlain
20-
)
21-
22-
def main(args: Array[String]): Unit = {
23-
SyncServerBuilder
24-
.build(req =>
25-
if (req.method == Method.GET) {
26-
if(req.target == "/plaintext")
27-
req.send(
28-
statusCode = StatusCode.OK,
29-
content = "Hello, World!",
30-
headers = textPlain
31-
)
32-
else if(req.target == "/json")
33-
req.send(
34-
statusCode = StatusCode.OK,
35-
content = writeToArray(Message("Hello, World!")),
36-
headers = applicationJson
37-
)
38-
else notFound(req)
39-
} else notFound(req)
40-
)
41-
.listen()
42-
}
43-
}
16+
@main
17+
def main =
18+
SyncServerBuilder
19+
.setRequestHandler(req =>
20+
if (req.method == Method.GET) {
21+
if(req.target == "/plaintext")
22+
req.send(
23+
statusCode = StatusCode.OK,
24+
content = "Hello, World!",
25+
headers = textPlain
26+
)
27+
else if(req.target == "/json")
28+
req.send(
29+
statusCode = StatusCode.OK,
30+
content = writeToArray(Message("Hello, World!")),
31+
headers = applicationJson
32+
)
33+
else notFound(req)
34+
} else notFound(req)
35+
)
36+
.build()
37+
.listen()

0 commit comments

Comments
 (0)