From e0ee7e8639ee5fa141ece16c4b302d8d086472c6 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Sun, 28 Feb 2021 02:28:07 +0100 Subject: [PATCH 01/40] Modify release-drafter name-template --- .github/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 8849bfd..95820e7 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,4 +1,4 @@ -name-template: '$RESOLVED_VERSION' +name-template: 'v$RESOLVED_VERSION' categories: - title: 'Enhancements' label: 'enhancement' From 4679e593c5b9e5e2e412da84780379a6ea1876e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 08:56:01 +0000 Subject: [PATCH 02/40] Bump stefda/action-cloud-run from v1.2 to v1.3 Bumps [stefda/action-cloud-run](https://github.com/stefda/action-cloud-run) from v1.2 to v1.3. - [Release notes](https://github.com/stefda/action-cloud-run/releases) - [Commits](https://github.com/stefda/action-cloud-run/compare/v1.2...e8982017e0c6ab696405f84a578a23fcc475ddfa) Signed-off-by: dependabot[bot] --- .github/workflows/ci_cd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd.yaml b/.github/workflows/ci_cd.yaml index b58f34e..4be90a7 100644 --- a/.github/workflows/ci_cd.yaml +++ b/.github/workflows/ci_cd.yaml @@ -43,7 +43,7 @@ jobs: docker tag $IMAGE_GHCR $IMAGE_GCR echo "image_gcr=$IMAGE_GCR" >> $GITHUB_ENV - name: Deploy to Cloud Run - uses: stefda/action-cloud-run@v1.2 + uses: stefda/action-cloud-run@v1.3 with: image: ${{ env.image_gcr }} service: graalnative4s From 38ba5ff136a08b3f503cae53f34e1debece37950 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Mon, 1 Mar 2021 12:42:16 +0100 Subject: [PATCH 03/40] Automatically merge successful dependabot PRs --- .github/mergify.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/mergify.yml b/.github/mergify.yml index 99a4cd9..3b94e55 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -17,9 +17,9 @@ pull_request_rules: actions: label: add: [dependency-update] - - name: Automatically merge Scala Steward PRs on CI success + - name: Automatically merge dependency update PRs on CI success conditions: - - author=scala-steward + - author~=^(scala-steward|dependabot)$ - status-success=ci actions: merge: From e5bf29ec7e00502db2d7817abe0f56f95b81aa18 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Mon, 1 Mar 2021 12:53:49 +0100 Subject: [PATCH 04/40] Remove end of string match because it does not work with dependabot --- .github/mergify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/mergify.yml b/.github/mergify.yml index 3b94e55..240ab6c 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -19,7 +19,7 @@ pull_request_rules: add: [dependency-update] - name: Automatically merge dependency update PRs on CI success conditions: - - author~=^(scala-steward|dependabot)$ + - author~=^(scala-steward|dependabot) - status-success=ci actions: merge: From 56c939919914411f99824d5d737ccf069b99c893 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Mon, 1 Mar 2021 13:20:00 +0100 Subject: [PATCH 05/40] Don't try to merge dependabot PRs automatically This repository uses dependabot primarly to update one Dockerfile and a couple of GitHub actions. However, mergify is not able to merge PRs that alter GitHub actions. --- .github/mergify.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/mergify.yml b/.github/mergify.yml index 240ab6c..99a4cd9 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -17,9 +17,9 @@ pull_request_rules: actions: label: add: [dependency-update] - - name: Automatically merge dependency update PRs on CI success + - name: Automatically merge Scala Steward PRs on CI success conditions: - - author~=^(scala-steward|dependabot) + - author=scala-steward - status-success=ci actions: merge: From bc7e50cefe2c45a3d8a83ef8562a139390df0619 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 2 Mar 2021 17:33:59 +0100 Subject: [PATCH 06/40] Update http4s-blaze-server, http4s-circe, ... to 0.21.20 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 841c69e..accd86a 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ ThisBuild / organization := "dev.usommerl" ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0" val v = new { - val http4s = "0.21.19" + val http4s = "0.21.20" val circe = "0.13.0" val ciris = "1.2.1" val tapir = "0.17.13" From 1bfaabc844c05b528e45a41d0f6fec5b5181f631 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 4 Mar 2021 10:48:55 +0100 Subject: [PATCH 07/40] Update tapir-core, tapir-http4s-server, ... to 0.17.14 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index accd86a..f8af363 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ val v = new { val http4s = "0.21.20" val circe = "0.13.0" val ciris = "1.2.1" - val tapir = "0.17.13" + val tapir = "0.17.14" val odin = "0.11.0" val munit = "0.7.22" val munitCE = "0.13.1" From d0503584bd5de94550c4382a913b9f4f4205a5fc Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Sun, 7 Mar 2021 17:34:43 +0100 Subject: [PATCH 08/40] Make logging configurable You can now configure the log level and choose one of the predefined Odin formatters via environment variables (LOG_LEVEL, LOG_FORMATTER) --- .github/workflows/cloud_run_env_vars | 2 +- src/main/scala/{server => app}/Api.scala | 2 +- src/main/scala/app/Config.scala | 60 +++++++++++++++++++ src/main/scala/app/Main.scala | 46 ++++++++++++++ src/main/scala/app/OdinInterop.scala | 26 ++++++++ .../org/slf4j/impl/StaticLoggerBinder.scala | 27 +-------- src/main/scala/server/Config.scala | 27 --------- src/main/scala/server/Main.scala | 48 --------------- src/test/scala/ApiSpec.scala | 2 +- 9 files changed, 136 insertions(+), 104 deletions(-) rename src/main/scala/{server => app}/Api.scala (99%) create mode 100644 src/main/scala/app/Config.scala create mode 100644 src/main/scala/app/Main.scala create mode 100644 src/main/scala/app/OdinInterop.scala delete mode 100644 src/main/scala/server/Config.scala delete mode 100644 src/main/scala/server/Main.scala diff --git a/.github/workflows/cloud_run_env_vars b/.github/workflows/cloud_run_env_vars index a634a86..508d284 100644 --- a/.github/workflows/cloud_run_env_vars +++ b/.github/workflows/cloud_run_env_vars @@ -1 +1 @@ -APIDOCS_SERVER_URL=https://graalnative4s.usommerl.dev,APIDOCS_DESCRIPTION="[github.com/usommerl/graalnative4s](https://github.com/usommerl/graalnative4s)" +APIDOCS_SERVER_URL=https://graalnative4s.usommerl.dev,APIDOCS_DESCRIPTION="[github.com/usommerl/graalnative4s](https://github.com/usommerl/graalnative4s)",LOG_FORMATTER="default" diff --git a/src/main/scala/server/Api.scala b/src/main/scala/app/Api.scala similarity index 99% rename from src/main/scala/server/Api.scala rename to src/main/scala/app/Api.scala index ca868ad..13e19e9 100644 --- a/src/main/scala/server/Api.scala +++ b/src/main/scala/app/Api.scala @@ -1,4 +1,4 @@ -package server +package app import cats.Applicative import cats.data.Kleisli diff --git a/src/main/scala/app/Config.scala b/src/main/scala/app/Config.scala new file mode 100644 index 0000000..dd02573 --- /dev/null +++ b/src/main/scala/app/Config.scala @@ -0,0 +1,60 @@ +package app + +import cats.implicits._ +import ciris._ +import ciris.refined._ +import eu.timepit.refined.api.Refined +import eu.timepit.refined.auto._ +import eu.timepit.refined.string.Url +import eu.timepit.refined.types.net.PortNumber + +import app.ServerUrl +import io.odin.Level +import io.odin.formatter.Formatter + +case class Config(server: ServerConfig, logger: LoggerConfig) +case class ServerConfig(port: PortNumber, apiDocs: ApiDocsConfig) +case class ApiDocsConfig(serverUrl: ServerUrl, description: Option[String]) +case class LoggerConfig(level: Level, formatter: Formatter) + +package object app { + + type ServerUrl = String Refined Url + + implicit val logLevelDecoder: ConfigDecoder[String, Level] = + ConfigDecoder[String, String].mapOption("Level")(_.toLowerCase match { + case "trace" => Level.Trace.some + case "debug" => Level.Debug.some + case "info" => Level.Info.some + case "warn" => Level.Warn.some + case "error" => Level.Error.some + case _ => None + }) + + implicit val logFormatterDecoder: ConfigDecoder[String, Formatter] = + ConfigDecoder[String, String].mapOption("Formatter")(_.toLowerCase match { + case "default" => Formatter.default.some + case "colorful" => Formatter.colorful.some + case _ => None + }) + + private val loggerConfig: ConfigValue[LoggerConfig] = ( + env("LOG_LEVEL").as[Level].default(Level.Info), + env("LOG_FORMATTER").as[Formatter].default(Formatter.colorful) + ).parMapN(LoggerConfig) + + private val apiDocsConfig: ConfigValue[ApiDocsConfig] = ( + env("APIDOCS_SERVER_URL").as[ServerUrl].default("http://localhost:8080"), + env("APIDOCS_DESCRIPTION").option + ).parMapN(ApiDocsConfig) + + private val serverConfig: ConfigValue[ServerConfig] = ( + env("PORT").as[PortNumber].default(8080), + apiDocsConfig + ).parMapN(ServerConfig) + + val config: ConfigValue[Config] = ( + serverConfig, + loggerConfig + ).parMapN(Config) +} diff --git a/src/main/scala/app/Main.scala b/src/main/scala/app/Main.scala new file mode 100644 index 0000000..c8c701b --- /dev/null +++ b/src/main/scala/app/Main.scala @@ -0,0 +1,46 @@ +package app + +import scala.concurrent.ExecutionContext.global + +import cats.effect.{Resource, _} +import cats.implicits._ +import dev.usommerl.BuildInfo +import eu.timepit.refined.auto._ +import io.odin._ +import org.http4s.server.{middleware, Server} +import org.http4s.server.blaze.BlazeServerBuilder + +object Main extends IOApp { + + def run(args: List[String]): IO[ExitCode] = + runF[IO].use(_ => IO.never) + + private def runF[F[_]: ContextShift: ConcurrentEffect: Timer]: Resource[F, Unit] = + for { + config <- app.config.resource[F] + implicit0(logger: Logger[F]) <- createLogger[F](config.logger) + _ <- Resource.liftF(logger.info(startMessage)) + _ <- serve[F](config.server) + } yield () + + private def createLogger[F[_]: ConcurrentEffect: Timer](config: LoggerConfig): Resource[F, Logger[F]] = + Resource + .pure[F, Logger[F]](consoleLogger[F](config.formatter).withMinimalLevel(config.level)) + .evalTap(logger => Sync[F].delay(OdinInterop.globalLogger.set(logger.mapK(Effect.toIOK).some))) + + private def serve[F[_]: ContextShift: ConcurrentEffect: Timer](config: ServerConfig): Resource[F, Server[F]] = + BlazeServerBuilder[F](global) + .bindHttp(config.port, "0.0.0.0") + .withHttpApp(middleware.Logger.httpApp(logHeaders = true, logBody = false)(Api[F](config.apiDocs))) + .resource + + private lazy val startMessage: String = + "STARTED [ name: %s, version: %s, vmVersion: %s, scalaVersion: %s, sbtVersion: %s, builtAt: %s ]".format( + BuildInfo.name, + BuildInfo.version, + System.getProperty("java.vm.version"), + BuildInfo.scalaVersion, + BuildInfo.sbtVersion, + BuildInfo.builtAtString + ) +} diff --git a/src/main/scala/app/OdinInterop.scala b/src/main/scala/app/OdinInterop.scala new file mode 100644 index 0000000..d074154 --- /dev/null +++ b/src/main/scala/app/OdinInterop.scala @@ -0,0 +1,26 @@ +package app + +import java.util.concurrent.atomic.AtomicReference + +import cats.effect.Clock +import cats.effect.Effect +import cats.effect.IO +import io.odin.Logger +import io.odin.slf4j.OdinLoggerBinder + +/** This implementation was stolen from here: + * https://github.com/pitgull/pitgull/blob/v0.0.7/src/main/scala/io/pg/OdinInterop.scala + */ +class OdinInterop extends OdinLoggerBinder[IO] { + implicit val F: Effect[IO] = IO.ioEffect + implicit val clock: Clock[IO] = Clock.create[IO] + + val loggers: PartialFunction[String, Logger[IO]] = { + val theLogger: String => Option[Logger[IO]] = _ => OdinInterop.globalLogger.get() + theLogger.unlift + } +} + +object OdinInterop { + val globalLogger = new AtomicReference[Option[Logger[IO]]](None) +} diff --git a/src/main/scala/org/slf4j/impl/StaticLoggerBinder.scala b/src/main/scala/org/slf4j/impl/StaticLoggerBinder.scala index 15e01b7..2a826a4 100644 --- a/src/main/scala/org/slf4j/impl/StaticLoggerBinder.scala +++ b/src/main/scala/org/slf4j/impl/StaticLoggerBinder.scala @@ -1,33 +1,8 @@ package org.slf4j.impl -import scala.concurrent.ExecutionContext - -import cats.effect.{Clock, Effect, IO, Timer} -import io.odin.{consoleLogger, Level, Logger} -import io.odin.formatter.Formatter -import io.odin.slf4j.OdinLoggerBinder - -/** This is bridge is needed for project dependencies that require an SLF4J API - * See: https://github.com/valskalla/odin/tree/v0.9.1#slf4j-bridge - * - * This particular implementation was stolen from here: - * https://github.com/pitgull/pitgull/blob/v0.0.2/src/main/scala/org/slf4j/impl/StaticLoggerBinder.scala - */ -class StaticLoggerBinder extends OdinLoggerBinder[IO] { - implicit val F: Effect[IO] = IO.ioEffect - implicit val clock: Clock[IO] = Clock.create[IO] - - import StaticLoggerBinder.baseLogger - - val loggers: PartialFunction[String, Logger[IO]] = { case _ => - baseLogger.withMinimalLevel(Level.Info) - } -} +class StaticLoggerBinder extends app.OdinInterop object StaticLoggerBinder extends StaticLoggerBinder { - //EC isn't used - only Clock is required - implicit val timer: Timer[IO] = IO.timer(ExecutionContext.parasitic) - val baseLogger = consoleLogger[IO](formatter = Formatter.colorful) val REQUESTED_API_VERSION: String = "1.7" def getSingleton: StaticLoggerBinder = this } diff --git a/src/main/scala/server/Config.scala b/src/main/scala/server/Config.scala deleted file mode 100644 index 10d7ecd..0000000 --- a/src/main/scala/server/Config.scala +++ /dev/null @@ -1,27 +0,0 @@ -package server - -import cats.implicits._ -import ciris._ -import ciris.refined._ -import eu.timepit.refined.api.Refined -import eu.timepit.refined.auto._ -import eu.timepit.refined.string.Url -import eu.timepit.refined.types.net.PortNumber - -import app.ServerUrl - -case class Config(port: PortNumber, apiDocs: ApiDocsConfig) -case class ApiDocsConfig(serverUrl: ServerUrl, description: Option[String]) - -package object app { - - type ServerUrl = String Refined Url - - val config: ConfigValue[Config] = - ( - env("PORT").as[PortNumber].default(8080), - env("APIDOCS_SERVER_URL").as[ServerUrl].default("http://localhost:8080"), - env("APIDOCS_DESCRIPTION").option - ).parMapN { case (port, url, description) => Config(port, ApiDocsConfig(url, description)) } - -} diff --git a/src/main/scala/server/Main.scala b/src/main/scala/server/Main.scala deleted file mode 100644 index ccb2059..0000000 --- a/src/main/scala/server/Main.scala +++ /dev/null @@ -1,48 +0,0 @@ -package server - -import scala.concurrent.ExecutionContext.global - -import cats.effect._ -import cats.implicits._ -import dev.usommerl.BuildInfo -import eu.timepit.refined.auto._ -import eu.timepit.refined.types.net.PortNumber -import io.odin._ -import org.http4s.HttpApp -import org.http4s.server.blaze.BlazeServerBuilder -import org.http4s.server.middleware.{Logger => Log} -import org.slf4j.impl.StaticLoggerBinder - -object Main extends IOApp { - - def run(args: List[String]): IO[ExitCode] = { - implicit val logger = StaticLoggerBinder.baseLogger.withMinimalLevel(Level.Info) - runF[IO] - } - - private def runF[F[_]: Sync: ContextShift: ConcurrentEffect: Timer: Logger]: F[ExitCode] = - for { - _ <- Logger[F].info(startMessage) - config <- app.config.load[F] - httpApp = Log.httpApp(logHeaders = true, logBody = false)(Api[F](config.apiDocs)) - exitCode <- serve[F](config.port, httpApp).as(ExitCode.Success) - } yield exitCode - - private def serve[F[_]: ConcurrentEffect: Timer](port: PortNumber, httpApp: HttpApp[F]): F[Unit] = - BlazeServerBuilder[F](global) - .bindHttp(port, "0.0.0.0") - .withHttpApp(httpApp) - .serve - .compile - .drain - - private lazy val startMessage: String = - "STARTED [ name: %s, version: %s, vmVersion: %s, scalaVersion: %s, sbtVersion: %s, builtAt: %s ]".format( - BuildInfo.name, - BuildInfo.version, - System.getProperty("java.vm.version"), - BuildInfo.scalaVersion, - BuildInfo.sbtVersion, - BuildInfo.builtAtString - ) -} diff --git a/src/test/scala/ApiSpec.scala b/src/test/scala/ApiSpec.scala index ea4b7e2..d2161a8 100644 --- a/src/test/scala/ApiSpec.scala +++ b/src/test/scala/ApiSpec.scala @@ -1,4 +1,4 @@ -package server +package app import cats.data.Kleisli import cats.effect.IO From d80fbc64114cc3e20b41be35a6ca905afebd6e6b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 8 Mar 2021 01:37:04 +0100 Subject: [PATCH 09/40] Update sbt to 1.4.8 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 0b2e09c..b5ef6ff 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.7 +sbt.version=1.4.8 From c120f54ffaf3ee258919c920109f08e019a03b6e Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Mon, 8 Mar 2021 09:18:04 +0100 Subject: [PATCH 10/40] Refactor logger construction --- src/main/scala/app/Main.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/app/Main.scala b/src/main/scala/app/Main.scala index c8c701b..5066090 100644 --- a/src/main/scala/app/Main.scala +++ b/src/main/scala/app/Main.scala @@ -25,7 +25,7 @@ object Main extends IOApp { private def createLogger[F[_]: ConcurrentEffect: Timer](config: LoggerConfig): Resource[F, Logger[F]] = Resource - .pure[F, Logger[F]](consoleLogger[F](config.formatter).withMinimalLevel(config.level)) + .pure[F, Logger[F]](consoleLogger[F](config.formatter, config.level)) .evalTap(logger => Sync[F].delay(OdinInterop.globalLogger.set(logger.mapK(Effect.toIOK).some))) private def serve[F[_]: ContextShift: ConcurrentEffect: Timer](config: ServerConfig): Resource[F, Server[F]] = From ef3da524e16c06cba0477cca939add414a7deccf Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Mon, 8 Mar 2021 10:36:08 +0100 Subject: [PATCH 11/40] Add optional JSON formatter for logging --- build.sbt | 1 + src/main/scala/app/Config.scala | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index f8af363..8c78862 100644 --- a/build.sbt +++ b/build.sbt @@ -27,6 +27,7 @@ lazy val graalnative4s = project "com.softwaremill.sttp.tapir" %% "tapir-openapi-circe-yaml" % v.tapir, "com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-http4s" % v.tapir, "com.github.valskalla" %% "odin-core" % v.odin, + "com.github.valskalla" %% "odin-json" % v.odin, "com.github.valskalla" %% "odin-slf4j" % v.odin, "io.circe" %% "circe-core" % v.circe, "io.circe" %% "circe-generic" % v.circe, diff --git a/src/main/scala/app/Config.scala b/src/main/scala/app/Config.scala index dd02573..7162776 100644 --- a/src/main/scala/app/Config.scala +++ b/src/main/scala/app/Config.scala @@ -7,10 +7,11 @@ import eu.timepit.refined.api.Refined import eu.timepit.refined.auto._ import eu.timepit.refined.string.Url import eu.timepit.refined.types.net.PortNumber - -import app.ServerUrl import io.odin.Level import io.odin.formatter.Formatter +import io.odin.json.{Formatter => JFormatter} + +import app.ServerUrl case class Config(server: ServerConfig, logger: LoggerConfig) case class ServerConfig(port: PortNumber, apiDocs: ApiDocsConfig) @@ -35,6 +36,7 @@ package object app { ConfigDecoder[String, String].mapOption("Formatter")(_.toLowerCase match { case "default" => Formatter.default.some case "colorful" => Formatter.colorful.some + case "json" => JFormatter.json.some case _ => None }) From afc309850c2d1bf1a6c8b73392d4157c309dde74 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 8 Mar 2021 16:05:45 +0100 Subject: [PATCH 12/40] Update tapir-core, tapir-http4s-server, ... to 0.17.15 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8c78862..afdcd8e 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ val v = new { val http4s = "0.21.20" val circe = "0.13.0" val ciris = "1.2.1" - val tapir = "0.17.14" + val tapir = "0.17.15" val odin = "0.11.0" val munit = "0.7.22" val munitCE = "0.13.1" From 4562d26219d1c662216d071d33c29f1742383724 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Mon, 8 Mar 2021 21:58:18 +0100 Subject: [PATCH 13/40] Do not run server process as root Fixes #87 --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index a3257ca..846a155 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2 as builder + ARG upx_compression RUN gu install native-image RUN curl https://bintray.com/sbt/rpm/rpm | tee /etc/yum.repos.d/bintray-sbt-rpm.repo && microdnf install sbt git xz @@ -38,8 +39,12 @@ RUN if [ -n "${upx_compression}" ]; then \ upx-3.96-amd64_linux/upx "$upx_compression" /build/target/graalvm-native-image/graalnative4s; \ fi +RUN echo 'unprivileged:x:65534:65534:unprivileged:/:' > /etc/passwd.minimal + FROM scratch COPY --from=builder /build/target/graalvm-native-image/graalnative4s /server +COPY --from=builder /etc/passwd.minimal /etc/passwd +USER unprivileged ENV PATH "/" EXPOSE 8080 ENTRYPOINT [ "/server" ] From 3f650b5995f4359c36dfd88062b8fe7c18dd2b0b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 10 Mar 2021 08:56:16 +0100 Subject: [PATCH 14/40] Update sbt to 1.4.9 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index b5ef6ff..dbae93b 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.8 +sbt.version=1.4.9 From fb4678f4f26c34390cf91627e665cd2066e3aca1 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 11 Mar 2021 19:43:06 +0100 Subject: [PATCH 15/40] Update tapir-core, tapir-http4s-server, ... to 0.17.16 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index afdcd8e..17cc3f7 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ val v = new { val http4s = "0.21.20" val circe = "0.13.0" val ciris = "1.2.1" - val tapir = "0.17.15" + val tapir = "0.17.16" val odin = "0.11.0" val munit = "0.7.22" val munitCE = "0.13.1" From ccf1185cff988f3f302c20362ea0835c934c3bc2 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Sat, 13 Mar 2021 23:12:12 +0100 Subject: [PATCH 16/40] Use refined to check that the value of the name parameter is not empty --- build.sbt | 1 + src/main/scala/app/Api.scala | 8 ++++++-- src/test/scala/ApiSpec.scala | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 17cc3f7..1f86404 100644 --- a/build.sbt +++ b/build.sbt @@ -25,6 +25,7 @@ lazy val graalnative4s = project "com.softwaremill.sttp.tapir" %% "tapir-json-circe" % v.tapir, "com.softwaremill.sttp.tapir" %% "tapir-openapi-docs" % v.tapir, "com.softwaremill.sttp.tapir" %% "tapir-openapi-circe-yaml" % v.tapir, + "com.softwaremill.sttp.tapir" %% "tapir-refined" % v.tapir, "com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-http4s" % v.tapir, "com.github.valskalla" %% "odin-core" % v.odin, "com.github.valskalla" %% "odin-json" % v.odin, diff --git a/src/main/scala/app/Api.scala b/src/main/scala/app/Api.scala index 13e19e9..d65ec6a 100644 --- a/src/main/scala/app/Api.scala +++ b/src/main/scala/app/Api.scala @@ -5,7 +5,9 @@ import cats.data.Kleisli import cats.effect.{Concurrent, ContextShift, Sync, Timer} import cats.implicits._ import dev.usommerl.BuildInfo +import eu.timepit.refined.api.Refined import eu.timepit.refined.auto._ +import eu.timepit.refined.collection._ import io.circe.generic.auto._ import org.http4s.{HttpRoutes, Request, Response} import org.http4s.dsl.Http4sDsl @@ -15,6 +17,7 @@ import org.http4s.server.middleware.CORS import sttp.model.StatusCode import sttp.tapir._ import sttp.tapir.apispec.Tag +import sttp.tapir.codec.refined._ import sttp.tapir.docs.openapi._ import sttp.tapir.generic.auto._ import sttp.tapir.json.circe.jsonBody @@ -49,6 +52,7 @@ object Examples { def apply[F[_]: Sync: Concurrent: ContextShift: Timer]()(implicit F: Applicative[F]) = new TapirApi[F] { override val tag = Tag("Getting started", None) override lazy val serverEndpoints = List(info, hello) + type NonEmptyString = String Refined NonEmpty private val info: ServerEndpoint[Unit, StatusCode, Info, Any, F] = endpoint.get @@ -71,12 +75,12 @@ object Examples { ) ) - private val hello: ServerEndpoint[Option[String], StatusCode, String, Any, F] = + private val hello: ServerEndpoint[Option[NonEmptyString], StatusCode, String, Any, F] = endpoint.get .summary("The infamous hello world endpoint") .tag(tag.name) .in("hello") - .in(query[Option[String]]("name").description("Optional name to greet")) + .in(query[Option[NonEmptyString]]("name").description("Optional name to greet")) .out(stringBody) .errorOut(statusCode) .serverLogic(name => F.pure(s"Hello ${name.getOrElse("World")}!".asRight)) diff --git a/src/test/scala/ApiSpec.scala b/src/test/scala/ApiSpec.scala index d2161a8..fa3d950 100644 --- a/src/test/scala/ApiSpec.scala +++ b/src/test/scala/ApiSpec.scala @@ -27,6 +27,11 @@ class ApiSpec extends ApiSuite { check(response, Ok, "Hello John Doe!") } + test("GET /hello not accept empty string as name parameter") { + val response = api().run(Request[IO](method = GET, uri = uri"/hello?name=")) + check(response, BadRequest, evaluateBody = false) + } + test("GET /info should respond with application information") { val response = api().run(Request[IO](method = GET, uri = uri"/info")) check( @@ -66,10 +71,15 @@ trait ApiSuite extends CatsEffectSuite { io: IO[Response[IO]], expectedStatus: Status, expectedBody: Option[String] = None, - expectedContentType: Option[`Content-Type`] = None + expectedContentType: Option[`Content-Type`] = None, + evaluateBody: Boolean = true ): IO[Unit] = io.flatMap { response => assertEquals(response.status, expectedStatus) - assertEquals(response.headers.get(`Content-Type`), expectedContentType) - response.as[String].assertEquals(expectedBody.getOrElse("")) + if (evaluateBody) { + assertEquals(response.headers.get(`Content-Type`), expectedContentType) + response.as[String].assertEquals(expectedBody.getOrElse("")) + } else { + IO.unit + } } } From c1aec1067a20004b6f56857240f86085e83c39bc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 15 Mar 2021 19:35:54 +0100 Subject: [PATCH 17/40] Update sbt-native-packager to 1.8.1 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 5d30be0..19509ab 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ addSbtPlugin("com.alejandrohdezma" % "sbt-codecov" % "0.2.0") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") From 4cbdbdc1694c2bb84a5e7abc7fba4a410c4f9571 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 16 Mar 2021 18:59:48 +0100 Subject: [PATCH 18/40] Update tapir-core, tapir-http4s-server, ... to 0.17.18 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 1f86404..14a9ea4 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ val v = new { val http4s = "0.21.20" val circe = "0.13.0" val ciris = "1.2.1" - val tapir = "0.17.16" + val tapir = "0.17.18" val odin = "0.11.0" val munit = "0.7.22" val munitCE = "0.13.1" From c925a7526c9e33e80ffd135e68f8e7be31bcb593 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 16 Mar 2021 21:07:18 +0100 Subject: [PATCH 19/40] Update sbt-tpolecat to 0.1.17 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 19509ab..9af5bcd 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.17") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.8.2") From 6829ccebe821996bdd800bac3158fe271c8626df Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 18 Mar 2021 15:14:43 +0100 Subject: [PATCH 20/40] Update tapir-core, tapir-http4s-server, ... to 0.17.19 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 14a9ea4..defbaab 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ val v = new { val http4s = "0.21.20" val circe = "0.13.0" val ciris = "1.2.1" - val tapir = "0.17.18" + val tapir = "0.17.19" val odin = "0.11.0" val munit = "0.7.22" val munitCE = "0.13.1" From 0bd97a77506c8b1cf35db51b2a26f3ae0e8c50bc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 27 Feb 2021 03:01:24 +0100 Subject: [PATCH 21/40] Update scala-library to 2.13.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 1f86404..b3233ec 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -ThisBuild / scalaVersion := "2.13.4" +ThisBuild / scalaVersion := "2.13.5" ThisBuild / organization := "dev.usommerl" ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0" From 0dfbcd214aa600cba21a25b0b0def19f1990c313 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Sat, 27 Mar 2021 22:42:27 +0100 Subject: [PATCH 22/40] Remove superfluous Sync context bound --- src/main/scala/app/Api.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/app/Api.scala b/src/main/scala/app/Api.scala index d65ec6a..6c7038a 100644 --- a/src/main/scala/app/Api.scala +++ b/src/main/scala/app/Api.scala @@ -2,7 +2,7 @@ package app import cats.Applicative import cats.data.Kleisli -import cats.effect.{Concurrent, ContextShift, Sync, Timer} +import cats.effect.{Concurrent, ContextShift, Timer} import cats.implicits._ import dev.usommerl.BuildInfo import eu.timepit.refined.api.Refined @@ -28,7 +28,7 @@ import sttp.tapir.server.http4s._ import sttp.tapir.swagger.http4s.SwaggerHttp4s object Api { - def apply[F[_]: Sync: Concurrent: ContextShift: Timer](config: ApiDocsConfig): Kleisli[F, Request[F], Response[F]] = { + def apply[F[_]: Concurrent: ContextShift: Timer](config: ApiDocsConfig): Kleisli[F, Request[F], Response[F]] = { val dsl = Http4sDsl[F] import dsl._ @@ -49,7 +49,7 @@ object Api { } object Examples { - def apply[F[_]: Sync: Concurrent: ContextShift: Timer]()(implicit F: Applicative[F]) = new TapirApi[F] { + def apply[F[_]: Concurrent: ContextShift: Timer]()(implicit F: Applicative[F]) = new TapirApi[F] { override val tag = Tag("Getting started", None) override lazy val serverEndpoints = List(info, hello) type NonEmptyString = String Refined NonEmpty @@ -97,7 +97,7 @@ object Examples { } } -abstract class TapirApi[F[_]: Sync: Concurrent: ContextShift: Timer] { +abstract class TapirApi[F[_]: Concurrent: ContextShift: Timer] { def tag: Tag def serverEndpoints: List[ServerEndpoint[_, _, _, Any, F]] def endpoints: List[Endpoint[_, _, _, _]] = serverEndpoints.map(_.endpoint) From 33b58b1276815e540822dae402f6c1e67d72d706 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Sat, 27 Mar 2021 23:11:23 +0100 Subject: [PATCH 23/40] Use semanticdb version that is available for scala 2.13.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index b3233ec..3eda645 100644 --- a/build.sbt +++ b/build.sbt @@ -48,7 +48,7 @@ lazy val graalnative4s = project buildInfoPackage := organization.value, buildInfoOptions ++= Seq[BuildInfoOption](BuildInfoOption.BuildTime), semanticdbEnabled := true, - semanticdbVersion := scalafixSemanticdb.revision, + semanticdbVersion := "4.4.10", docker / dockerfile := NativeDockerfile(file("Dockerfile")), docker / imageNames := Seq(ImageName(s"ghcr.io/usommerl/${name.value}:${dockerImageTag}")), docker / dockerBuildArguments := sys.env.get(upx).map(s => Map("upx_compression" -> s)).getOrElse(Map.empty), From d7628fd43d941254aa5a29402e3a655a5c9840bb Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Sun, 28 Mar 2021 18:48:46 +0200 Subject: [PATCH 24/40] Don't make Logger available implicitly --- src/main/scala/app/Main.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/app/Main.scala b/src/main/scala/app/Main.scala index 5066090..5bbad26 100644 --- a/src/main/scala/app/Main.scala +++ b/src/main/scala/app/Main.scala @@ -17,10 +17,10 @@ object Main extends IOApp { private def runF[F[_]: ContextShift: ConcurrentEffect: Timer]: Resource[F, Unit] = for { - config <- app.config.resource[F] - implicit0(logger: Logger[F]) <- createLogger[F](config.logger) - _ <- Resource.liftF(logger.info(startMessage)) - _ <- serve[F](config.server) + config <- app.config.resource[F] + logger <- createLogger[F](config.logger) + _ <- Resource.liftF(logger.info(startMessage)) + _ <- serve[F](config.server) } yield () private def createLogger[F[_]: ConcurrentEffect: Timer](config: LoggerConfig): Resource[F, Logger[F]] = From f35db27f1f8685973758a327cb578e2c456588da Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 29 Mar 2021 16:52:59 +0200 Subject: [PATCH 25/40] Update http4s-blaze-server, http4s-circe, ... to 0.21.21 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e8d079e..43d1c70 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ ThisBuild / organization := "dev.usommerl" ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0" val v = new { - val http4s = "0.21.20" + val http4s = "0.21.21" val circe = "0.13.0" val ciris = "1.2.1" val tapir = "0.17.19" From 9f26ed241eb430965e1c92102b46307d4ee5fc1c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 29 Mar 2021 16:53:03 +0200 Subject: [PATCH 26/40] Update munit-cats-effect-2 to 1.0.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e8d079e..7de3caa 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ val v = new { val tapir = "0.17.19" val odin = "0.11.0" val munit = "0.7.22" - val munitCE = "0.13.1" + val munitCE = "1.0.0" } val upx = "UPX_COMPRESSION" From 9e624da8a0d9fd9598fe04b530b1dd71af743374 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 29 Mar 2021 21:52:02 +0200 Subject: [PATCH 27/40] Update sbt-scalafix to 0.9.27 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 9af5bcd..4f6caa8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.26") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.27") addSbtPlugin("com.alejandrohdezma" % "sbt-codecov" % "0.2.0") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") From e00e623c7d6c7491fd257fafbb93fda8f7e0ee56 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 29 Mar 2021 21:52:06 +0200 Subject: [PATCH 28/40] Update munit to 0.7.23 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7de3caa..bef5695 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ val v = new { val ciris = "1.2.1" val tapir = "0.17.19" val odin = "0.11.0" - val munit = "0.7.22" + val munit = "0.7.23" val munitCE = "1.0.0" } From 405279604dac4511a7691ecc924f4845b9906023 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Tue, 30 Mar 2021 14:51:53 +0200 Subject: [PATCH 29/40] Use Resource.eval instead of Resource.liftF --- src/main/scala/app/Main.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/app/Main.scala b/src/main/scala/app/Main.scala index 5bbad26..62e0b1e 100644 --- a/src/main/scala/app/Main.scala +++ b/src/main/scala/app/Main.scala @@ -19,7 +19,7 @@ object Main extends IOApp { for { config <- app.config.resource[F] logger <- createLogger[F](config.logger) - _ <- Resource.liftF(logger.info(startMessage)) + _ <- Resource.eval(logger.info(startMessage)) _ <- serve[F](config.server) } yield () From 8becded808e43ea8ed404ad04a6a5e1ed6d9659b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 30 Mar 2021 20:14:20 +0200 Subject: [PATCH 30/40] Update munit-cats-effect-2 to 1.0.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 17f9c42..60eec03 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ val v = new { val tapir = "0.17.19" val odin = "0.11.0" val munit = "0.7.23" - val munitCE = "1.0.0" + val munitCE = "1.0.1" } val upx = "UPX_COMPRESSION" From e5316a69b257738736aae00835712f264473d6e5 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Tue, 30 Mar 2021 21:27:57 +0200 Subject: [PATCH 31/40] Use scalafix compatible semanticdb version --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 60eec03..e6f4e17 100644 --- a/build.sbt +++ b/build.sbt @@ -48,7 +48,7 @@ lazy val graalnative4s = project buildInfoPackage := organization.value, buildInfoOptions ++= Seq[BuildInfoOption](BuildInfoOption.BuildTime), semanticdbEnabled := true, - semanticdbVersion := "4.4.10", + semanticdbVersion := scalafixSemanticdb.revision, docker / dockerfile := NativeDockerfile(file("Dockerfile")), docker / imageNames := Seq(ImageName(s"ghcr.io/usommerl/${name.value}:${dockerImageTag}")), docker / dockerBuildArguments := sys.env.get(upx).map(s => Map("upx_compression" -> s)).getOrElse(Map.empty), From 6ea34af3a21d56659afe3d6c85681a8abab68ec3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 5 Apr 2021 01:46:59 +0200 Subject: [PATCH 32/40] Update sbt to 1.5.0 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index dbae93b..e67343a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.9 +sbt.version=1.5.0 From 80e1a8ac09e4e5864a25968cabbf30e7d8b2655e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Apr 2021 07:19:09 +0000 Subject: [PATCH 33/40] Bump actions/setup-java from v1 to v2 Bumps [actions/setup-java](https://github.com/actions/setup-java) from v1 to v2. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v1...8764a52df183aa0ccea74521dfd9d506ffc7a19a) Signed-off-by: dependabot[bot] --- .github/workflows/ci_cd.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd.yaml b/.github/workflows/ci_cd.yaml index 4be90a7..cd35a73 100644 --- a/.github/workflows/ci_cd.yaml +++ b/.github/workflows/ci_cd.yaml @@ -9,7 +9,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Set up JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: java-version: 1.11 - name: Run tests @@ -22,7 +22,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Set up JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: java-version: 1.11 - name: Docker login From 939c044f9e694cfd9914e8d2f63d6fd25c34e6cc Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Tue, 6 Apr 2021 18:49:42 +0200 Subject: [PATCH 34/40] Adapt parameters for setup-java@v2 --- .github/workflows/ci_cd.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd.yaml b/.github/workflows/ci_cd.yaml index cd35a73..07f5010 100644 --- a/.github/workflows/ci_cd.yaml +++ b/.github/workflows/ci_cd.yaml @@ -11,7 +11,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@v2 with: - java-version: 1.11 + distribution: 'adopt' + java-version: 11 - name: Run tests run: sbt testCovered cd: @@ -24,7 +25,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@v2 with: - java-version: 1.11 + distribution: 'adopt' + java-version: 11 - name: Docker login env: TOKEN: ${{ secrets.PAT_GHCR }} From d723b415c8f33be5b1c587a90d6ca156de3408b1 Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Tue, 6 Apr 2021 20:27:24 +0200 Subject: [PATCH 35/40] Remove deprecated sbt syntax --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e6f4e17..6cc2f2d 100644 --- a/build.sbt +++ b/build.sbt @@ -56,7 +56,7 @@ lazy val graalnative4s = project case "META-INF/maven/org.webjars/swagger-ui/pom.properties" => MergeStrategy.singleOrError case x if x.endsWith("module-info.class") => MergeStrategy.discard case x => - val oldStrategy = (assemblyMergeStrategy in assembly).value + val oldStrategy = (assembly / assemblyMergeStrategy).value oldStrategy(x) } ) From 630b466dc87dd1ab1bcab0a1a92893e8826f8cbe Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Tue, 6 Apr 2021 20:32:11 +0200 Subject: [PATCH 36/40] Remove local variable in build.sbt --- build.sbt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 6cc2f2d..1c4ee4a 100644 --- a/build.sbt +++ b/build.sbt @@ -55,9 +55,7 @@ lazy val graalnative4s = project assembly / assemblyMergeStrategy := { case "META-INF/maven/org.webjars/swagger-ui/pom.properties" => MergeStrategy.singleOrError case x if x.endsWith("module-info.class") => MergeStrategy.discard - case x => - val oldStrategy = (assembly / assemblyMergeStrategy).value - oldStrategy(x) + case x => (assembly / assemblyMergeStrategy).value(x) } ) From 556bf27ab78fd619aba0d4d6301be8bb56e49be7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 7 Apr 2021 07:22:15 +0200 Subject: [PATCH 37/40] Update http4s-blaze-server, http4s-circe, ... to 0.21.22 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 1c4ee4a..bbc31f8 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ ThisBuild / organization := "dev.usommerl" ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0" val v = new { - val http4s = "0.21.21" + val http4s = "0.21.22" val circe = "0.13.0" val ciris = "1.2.1" val tapir = "0.17.19" From 0b9b668a74a83768dfed6f61bf625cd023bb957e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Apr 2021 08:58:27 +0000 Subject: [PATCH 38/40] Bump stefda/action-cloud-run from v1.3 to v1.4 Bumps [stefda/action-cloud-run](https://github.com/stefda/action-cloud-run) from v1.3 to v1.4. - [Release notes](https://github.com/stefda/action-cloud-run/releases) - [Commits](https://github.com/stefda/action-cloud-run/compare/v1.3...4ec852446f36b30f2fd5630d16d0d2ed9f9bf430) Signed-off-by: dependabot[bot] --- .github/workflows/ci_cd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd.yaml b/.github/workflows/ci_cd.yaml index 07f5010..eb2ba1a 100644 --- a/.github/workflows/ci_cd.yaml +++ b/.github/workflows/ci_cd.yaml @@ -45,7 +45,7 @@ jobs: docker tag $IMAGE_GHCR $IMAGE_GCR echo "image_gcr=$IMAGE_GCR" >> $GITHUB_ENV - name: Deploy to Cloud Run - uses: stefda/action-cloud-run@v1.3 + uses: stefda/action-cloud-run@v1.4 with: image: ${{ env.image_gcr }} service: graalnative4s From 6fb90fc1a71e60d5cd949c6d64e933fe4ff354d7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 13 Apr 2021 13:07:12 +0200 Subject: [PATCH 39/40] Update sbt-codecov to 0.2.1 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4f6caa8..4694735 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.27") -addSbtPlugin("com.alejandrohdezma" % "sbt-codecov" % "0.2.0") +addSbtPlugin("com.alejandrohdezma" % "sbt-codecov" % "0.2.1") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") From 5415068d6b4477e112bf3e5646c59239c2e1ec6c Mon Sep 17 00:00:00 2001 From: Uwe Sommerlatt Date: Sun, 18 Apr 2021 15:48:59 +0200 Subject: [PATCH 40/40] Use GITHUB_TOKEN instead of personal access token to log in to ghcr.io --- .github/workflows/ci_cd.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_cd.yaml b/.github/workflows/ci_cd.yaml index eb2ba1a..6cc3f06 100644 --- a/.github/workflows/ci_cd.yaml +++ b/.github/workflows/ci_cd.yaml @@ -27,11 +27,12 @@ jobs: with: distribution: 'adopt' java-version: 11 - - name: Docker login - env: - TOKEN: ${{ secrets.PAT_GHCR }} - USERNAME: ${{ github.repository_owner }} - run: echo $TOKEN | docker login ghcr.io -u $USERNAME --password-stdin + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Create and publish a docker image with a UPX compressed executable run: export UPX_COMPRESSION='--best'; sbt ';docker;dockerPush' - name: Create and publish a docker image without compression