Skip to content

Commit

Permalink
Merge branch 'series/0.6.x' into topic/polling-system
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge authored Dec 30, 2024
2 parents 9405587 + 09f5791 commit 14b5c82
Show file tree
Hide file tree
Showing 53 changed files with 1,825 additions and 310 deletions.
348 changes: 187 additions & 161 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
updates.pin = [
{ groupId = "eu.timepit", artifactId = "refined", version = "0.10." }
]
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version = "3.7.3"
version = "3.8.3"
runner.dialect = Scala213Source3
project.includePaths = [] # disables formatting
2 changes: 1 addition & 1 deletion bin/local
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ esac
export SERVER_KEY=$(cat world/server.key)
export SERVER_CERT=$(cat world/server.crt)

docker-compose $CMD $EXTRA_FLAGS
docker compose $CMD $EXTRA_FLAGS
113 changes: 65 additions & 48 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ThisBuild / tlBaseVersion := "0.6"

// Our Scala versions.
lazy val `scala-2.12` = "2.12.17"
lazy val `scala-2.13` = "2.13.10"
lazy val `scala-3.0` = "3.3.0"
lazy val `scala-2.12` = "2.12.20"
lazy val `scala-2.13` = "2.13.15"
lazy val `scala-3.0` = "3.3.4"

ThisBuild / scalaVersion := `scala-2.13`
ThisBuild / crossScalaVersions :=
Expand All @@ -16,18 +16,19 @@ ThisBuild / developers := List(
)

ThisBuild / tlCiReleaseBranches += "series/0.6.x"
ThisBuild / tlCiScalafmtCheck := false
ThisBuild / tlSitePublishBranch := Some("series/0.6.x")
ThisBuild / tlSonatypeUseLegacyHost := false
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest")
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11"))
ThisBuild / tlJdkRelease := Some(8)

ThisBuild / githubWorkflowBuildPreamble ++= nativeBrewInstallWorkflowSteps.value
ThisBuild / nativeBrewInstallCond := Some("matrix.project == 'rootNative'")
ThisBuild / nativeBrewInstallCond := Some("matrix.project == 'skunkNative'")

lazy val setupCertAndDocker = Seq(
WorkflowStep.Run(
commands = List("export SERVER_KEY=$(cat world/server.key)", "export SERVER_CERT=$(cat world/server.crt)", "docker-compose up -d"),
commands = List("export SERVER_KEY=$(cat world/server.key)", "export SERVER_CERT=$(cat world/server.crt)", "docker compose up -d"),
name = Some("Start up Postgres"),
)
)
Expand All @@ -38,15 +39,13 @@ ThisBuild / tlCiHeaderCheck := true
ThisBuild / githubWorkflowAddedJobs +=
WorkflowJob(
id = "coverage",
name = s"Generate coverage report (${`scala-2.13`} JVM only)",
scalas = List(`scala-2.13`),
name = s"Generate coverage report (2.13 JVM only)",
scalas = Nil,
sbtStepPreamble = Nil,
steps = githubWorkflowJobSetup.value.toList ++
List(
WorkflowStep.Sbt(List("coverage", "rootJVM/test", "coverageReport")),
WorkflowStep.Run(
List("bash <(curl -s https://codecov.io/bash)"),
name = Some("Upload code coverage data")
)
WorkflowStep.Sbt(List("coverage", "skunkJVM/test", "coverageReport")),
WorkflowStep.Use(UseRef.Public("codecov", "codecov-action", "v3"))
)
)

Expand All @@ -61,8 +60,8 @@ ThisBuild / mimaBinaryIssueFilters ++= List(
)

// This is used in a couple places
lazy val fs2Version = "3.8-e358dce"
lazy val natchezVersion = "0.3.1"
lazy val fs2Version = "3.12.0-RC1"
lazy val natchezVersion = "0.3.7"

// Global Settings
lazy val commonSettings = Seq(
Expand All @@ -83,7 +82,7 @@ lazy val commonSettings = Seq(

// Compilation
scalacOptions -= "-language:experimental.macros", // doesn't work cross-version
Compile / doc / scalacOptions --= Seq("-Xfatal-warnings"),
Compile / doc / scalacOptions --= Seq("-Werror"),
Compile / doc / scalacOptions ++= Seq(
"-groups",
"-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath,
Expand All @@ -98,8 +97,7 @@ lazy val commonSettings = Seq(
)

lazy val skunk = tlCrossRootProject
.settings(name := "skunk")
.aggregate(core, tests, circe, refined, example, unidocs)
.aggregate(core, tests, circe, refined, postgis, example, unidocs)
.settings(commonSettings)

lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
Expand All @@ -110,29 +108,28 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.settings(
name := "skunk-core",
description := "Tagless, non-blocking data access library for Postgres.",
scalacOptions ~= (_.filterNot(_ == "-source:3.0-migration")),
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.9.0",
"org.typelevel" %%% "cats-effect" % "3.5.0",
"org.typelevel" %%% "cats-core" % "2.11.0",
"org.typelevel" %%% "cats-effect" % "3.5.7",
"co.fs2" %%% "fs2-core" % fs2Version,
"co.fs2" %%% "fs2-io" % fs2Version,
"org.scodec" %%% "scodec-bits" % "1.1.37",
"org.scodec" %%% "scodec-core" % (if (tlIsScala3.value) "2.2.1" else "1.11.10"),
"org.scodec" %%% "scodec-bits" % "1.1.38",
"org.scodec" %%% "scodec-core" % (if (tlIsScala3.value) "2.2.2" else "1.11.10"),
"org.scodec" %%% "scodec-cats" % "1.2.0",
"org.tpolecat" %%% "natchez-core" % natchezVersion,
"org.tpolecat" %%% "sourcepos" % "1.1.0",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.10.0",
"org.typelevel" %%% "twiddles-core" % "0.6.0",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.11.0",
"org.typelevel" %%% "twiddles-core" % "0.6.2",
) ++ Seq(
"com.beachape" %%% "enumeratum" % "1.7.2",
"com.beachape" %%% "enumeratum" % "1.7.4",
).filterNot(_ => tlIsScala3.value)
).jvmSettings(
libraryDependencies += "com.ongres.scram" % "client" % "2.1",
).platformsSettings(JSPlatform, NativePlatform)(
libraryDependencies ++= Seq(
"com.armanbilge" %%% "saslprep" % "0.1.1",
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0",
"io.github.cquiroz" %%% "locales-minimal-en_us-db" % "1.5.1"
"io.github.cquiroz" %%% "locales-minimal-en_us-db" % "1.5.3"
),
)

Expand All @@ -158,26 +155,44 @@ lazy val circe = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.settings(
name := "skunk-circe",
libraryDependencies ++= Seq(
"io.circe" %%% "circe-core" % "0.14.5",
"io.circe" %%% "circe-parser" % "0.14.5"
"io.circe" %%% "circe-core" % "0.14.8",
"io.circe" %%% "circe-jawn" % "0.14.8"
)
)

lazy val postgis = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("modules/postgis"))
.dependsOn(core)
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings)
.settings(
name := "skunk-postgis",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-parse" % "1.0.0"
),
mimaPreviousArtifacts := mimaPreviousArtifacts.value.filter { artifact =>
VersionNumber(artifact.revision).matchesSemVer(SemanticSelector(">0.6.3"))
},
mimaFailOnNoPrevious := false
)

lazy val tests = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Full)
.in(file("modules/tests"))
.dependsOn(core, circe)
.dependsOn(core, circe, postgis)
.enablePlugins(AutomateHeaderPlugin, NoPublishPlugin)
.settings(commonSettings)
.settings(
scalacOptions -= "-Xfatal-warnings",
tlFatalWarnings := false,
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % "1.0.0-M7",
"org.scalameta" % "junit-interface" % "1.0.0-M7",
"org.scalameta" %%% "munit" % "1.0.0",
"org.scalameta" % "junit-interface" % "1.0.2",
"org.typelevel" %%% "scalacheck-effect-munit" % "2.0.0-M2",
"org.typelevel" %%% "munit-cats-effect" % "2.0.0-M3",
"org.typelevel" %%% "cats-free" % "2.9.0",
"org.typelevel" %%% "cats-laws" % "2.9.0",
"org.typelevel" %%% "munit-cats-effect" % "2.0.0",
"org.typelevel" %%% "cats-free" % "2.11.0",
"org.typelevel" %%% "cats-laws" % "2.11.0",
"org.typelevel" %%% "cats-effect-testkit" % "3.5.7",
"org.typelevel" %%% "discipline-munit" % "2.0.0-M3",
"org.typelevel" %%% "cats-time" % "0.5.1",
),
Expand Down Expand Up @@ -232,31 +247,33 @@ lazy val docs = project
.enablePlugins(TypelevelSitePlugin)
.settings(commonSettings)
.settings(
scalacOptions ~= {
_.map {
case opt if opt.startsWith("-Xlint") => s"$opt,-missing-interpolator"
case opt => opt
}
},
mdocIn := (Compile / sourceDirectory).value / "laika",
tlSiteIsTypelevelProject := Some(TypelevelProject.Affiliate),
libraryDependencies ++= Seq(
"org.tpolecat" %%% "natchez-jaeger" % natchezVersion,
),
laikaConfig := {
import laika.rewrite.link._
import laika.config._

laikaConfig.value.withRawContent
.withConfigValue("version", mdocVariables.value("VERSION"))
.withConfigValue(
LinkConfig(apiLinks =
List(
ApiLinks(
baseUri = s"https://www.javadoc.io/doc/org.tpolecat/skunk-docs_${scalaBinaryVersion.value}/${mdocVariables.value("VERSION")}/",
packagePrefix = "skunk"
),
ApiLinks(
baseUri = s"https://www.javadoc.io/doc/co.fs2/fs2-docs_${scalaBinaryVersion.value}/$fs2Version/",
packagePrefix = "fs2"
),
)
LinkConfig.empty.addApiLinks(
ApiLinks(
s"https://www.javadoc.io/doc/org.tpolecat/skunk-docs_${scalaBinaryVersion.value}/${mdocVariables.value("VERSION")}/"
).withPackagePrefix("skunk"),
ApiLinks(
s"https://www.javadoc.io/doc/co.fs2/fs2-docs_${scalaBinaryVersion.value}/$fs2Version/"
).withPackagePrefix("fs2")
)
)
}
)

// ci

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'
services:
# main instance for testing
postgres:
image: postgres:11
image: postgis/postgis:11-3.3
volumes:
- ./world/fix_perms.sh:/docker-entrypoint-initdb.d/fix_perms.sh
- ./world/world.sql:/docker-entrypoint-initdb.d/world.sql
Expand Down
2 changes: 1 addition & 1 deletion modules/circe/src/main/scala/JsonCodecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package circe.codec

import cats.syntax.all._
import io.circe.{ Json, Encoder => CEncoder, Decoder => CDecoder }
import io.circe.parser.parse
import io.circe.jawn.parse
import skunk.data.Type

trait JsonCodecs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ private[message] trait PasswordMessagePlatform {
// First round
if (EVP_DigestInit_ex(ctx, `type`, null) != 1)
throw new RuntimeException("EVP_DigestInit_ex")
if (EVP_DigestUpdate(ctx, password.getBytes.at(0), password.length.toULong) != 1)
if (EVP_DigestUpdate(ctx, password.getBytes.atUnsafe(0), password.length.toULong) != 1)
throw new RuntimeException("EVP_DigestUpdate")
if (EVP_DigestUpdate(ctx, user.getBytes.at(0), user.length.toULong) != 1)
if (EVP_DigestUpdate(ctx, user.getBytes.atUnsafe(0), user.length.toULong) != 1)
throw new RuntimeException("EVP_DigestUpdate")
if (EVP_DigestFinal_ex(ctx, md.at(0), size) != 1)
if (EVP_DigestFinal_ex(ctx, md.atUnsafe(0), size) != 1)
throw new RuntimeException("EVP_DigestFinal_ex")
var hex = BigInt(1, md.take((!size).toInt)).toString(16)
while (hex.length < 32)
Expand All @@ -48,11 +48,11 @@ private[message] trait PasswordMessagePlatform {
// Second round
if (EVP_DigestInit_ex(ctx, `type`, null) != 1)
throw new RuntimeException("EVP_DigestInit_ex")
if (EVP_DigestUpdate(ctx, hex.getBytes.at(0), 32.toULong) != 1)
if (EVP_DigestUpdate(ctx, hex.getBytes.atUnsafe(0), 32.toULong) != 1)
throw new RuntimeException("EVP_DigestUpdate")
if (EVP_DigestUpdate(ctx, salt.at(0), salt.length.toULong) != 1)
if (EVP_DigestUpdate(ctx, salt.atUnsafe(0), salt.length.toULong) != 1)
throw new RuntimeException("EVP_DigestUpdate")
if (EVP_DigestFinal_ex(ctx, md.at(0), size) != 1)
if (EVP_DigestFinal_ex(ctx, md.atUnsafe(0), size) != 1)
throw new RuntimeException("EVP_DigestFinal_ex")
hex = BigInt(1, md.take((!size).toInt)).toString(16)
while (hex.length < 32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private[message] trait ScramPlatform { this: Scram.type =>

def clientFirstBareWithRandomNonce: ByteVector = {
val buf = new Array[Byte](32)
if (RAND_bytes(buf.at(0), 32) != 1)
if (RAND_bytes(buf.atUnsafe(0), 32) != 1)
throw new RuntimeException("RAND_bytes")
val nonce = ByteVector.view(buf).toBase64
clientFirstBareWithNonce(nonce)
Expand All @@ -27,7 +27,7 @@ private[message] trait ScramPlatform { this: Scram.type =>
throw new RuntimeException("EVP_get_digestbyname")
val md = new Array[Byte](EVP_MAX_MD_SIZE)
val mdLen = stackalloc[CUnsignedInt]()
if (openssl.HMAC(evpMd, key.toArrayUnsafe.at(0), key.size.toInt, str.toArrayUnsafe.at(0), str.size.toULong, md.at(0), mdLen) == null)
if (openssl.HMAC(evpMd, key.toArrayUnsafe.atUnsafe(0), key.size.toInt, str.toArrayUnsafe.atUnsafe(0), str.size.toULong, md.atUnsafe(0), mdLen) == null)
throw new RuntimeException("HMAC")
ByteVector.view(md, 0, (!mdLen).toInt)
}
Expand All @@ -38,7 +38,7 @@ private[message] trait ScramPlatform { this: Scram.type =>
val `type` = EVP_get_digestbyname(c"SHA256")
if (`type` == null)
throw new RuntimeException("EVP_get_digestbyname")
if (EVP_Digest(input.toArrayUnsafe.at(0), input.size.toULong, md.at(0), size, `type`, null) != 1)
if (EVP_Digest(input.toArrayUnsafe.atUnsafe(0), input.size.toULong, md.atUnsafe(0), size, `type`, null) != 1)
throw new RuntimeException("EVP_Digest")
ByteVector.view(md, 0, (!size).toInt)
}
Expand All @@ -48,7 +48,7 @@ private[message] trait ScramPlatform { this: Scram.type =>
if (digest == null)
throw new RuntimeException("EVP_get_digestbyname")
val out = new Array[Byte](32)
if (PKCS5_PBKDF2_HMAC(str.getBytes.at(0), str.length, salt.toArrayUnsafe.at(0), salt.size.toInt, iterations, digest, 32, out.at(0)) != 1)
if (PKCS5_PBKDF2_HMAC(str.getBytes.atUnsafe(0), str.length, salt.toArrayUnsafe.atUnsafe(0), salt.size.toInt, iterations, digest, 32, out.atUnsafe(0)) != 1)
throw new RuntimeException("PKCS5_PBKDF2_HMAC")
ByteVector.view(out)
}
Expand Down
3 changes: 3 additions & 0 deletions modules/core/native/src/main/scala/net/message/openssl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

package skunk.net.message

import org.typelevel.scalaccompat.annotation._

import scala.scalanative.unsafe._

@nowarn212
@link("crypto")
@extern
private[message] object openssl {
Expand Down
4 changes: 2 additions & 2 deletions modules/core/shared/src/main/scala-2/SqlState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import skunk.exception.PostgresErrorException
sealed abstract class SqlState(val code: String) extends EnumEntry {

def unapply(e: Throwable): Option[PostgresErrorException] =
Some(e).collect { case e: PostgresErrorException if e.code == code => e }
Some(e).collect { case pe: PostgresErrorException if pe.code == code => pe }

}

Expand Down Expand Up @@ -1222,4 +1222,4 @@ object SqlState extends Enum[SqlState] {

override val values: IndexedSeq[SqlState] = findValues

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ object StringContextOps {
}

def identifier_impl(): Tree = {
val Apply(_, List(Apply(_, List(Literal(Constant(part: String)))))) = c.prefix.tree
val Apply(_, List(Apply(_, List(Literal(Constant(part: String)))))) = c.prefix.tree: @unchecked
Identifier.fromString(part) match {
case Left(s) => c.abort(c.enclosingPosition, s)
case Right(Identifier(s)) => q"_root_.skunk.data.Identifier.fromString($s).fold(sys.error, identity)"
Expand Down
1 change: 0 additions & 1 deletion modules/core/shared/src/main/scala-3/SqlState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package skunk

import scala.collection.immutable.IndexedSeq
import skunk.exception.PostgresErrorException

/**
Expand Down
Loading

0 comments on commit 14b5c82

Please sign in to comment.