Skip to content

Commit

Permalink
Merge pull request #988 from typelevel/pr/merge-0.6-main
Browse files Browse the repository at this point in the history
0.6 -> main
  • Loading branch information
armanbilge authored Oct 4, 2023
2 parents 8affa41 + 646171d commit 33670bb
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 40 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -269,7 +269,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -308,12 +308,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.11]
scala: [2.13.12]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
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.12"
version = "3.7.14"
runner.dialect = Scala213Source3
project.includePaths = [] # disables formatting
18 changes: 9 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ThisBuild / tlBaseVersion := "1.0"

// Our Scala versions.
lazy val `scala-2.13` = "2.13.11"
lazy val `scala-3` = "3.3.0"
lazy val `scala-2.13` = "2.13.12"
lazy val `scala-3` = "3.3.1"

ThisBuild / scalaVersion := `scala-2.13`
ThisBuild / crossScalaVersions := Seq(`scala-2.13`, `scala-3`)
Expand Down Expand Up @@ -57,7 +57,7 @@ ThisBuild / mimaBinaryIssueFilters ++= List(
)

// This is used in a couple places
lazy val fs2Version = "3.8.0"
lazy val fs2Version = "3.9.2"
lazy val openTelemetryVersion = "1.29.0"
lazy val otel4sVersion = "0.2.1"

Expand Down Expand Up @@ -109,7 +109,7 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
description := "Tagless, non-blocking data access library for Postgres.",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.10.0",
"org.typelevel" %%% "cats-effect" % "3.5.1",
"org.typelevel" %%% "cats-effect" % "3.5.2",
"co.fs2" %%% "fs2-core" % fs2Version,
"co.fs2" %%% "fs2-io" % fs2Version,
"org.scodec" %%% "scodec-bits" % "1.1.37",
Expand Down Expand Up @@ -153,8 +153,8 @@ 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.6",
"io.circe" %%% "circe-parser" % "0.14.6"
)
)

Expand All @@ -167,8 +167,8 @@ lazy val tests = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.settings(
tlFatalWarnings := false,
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % "1.0.0-M8",
"org.scalameta" % "junit-interface" % "1.0.0-M8",
"org.scalameta" %%% "munit" % "1.0.0-M10",
"org.scalameta" % "junit-interface" % "1.0.0-M10",
"org.typelevel" %%% "scalacheck-effect-munit" % "2.0.0-M2",
"org.typelevel" %%% "munit-cats-effect" % "2.0.0-M3",
"org.typelevel" %%% "cats-free" % "2.10.0",
Expand Down Expand Up @@ -201,7 +201,7 @@ lazy val tests = crossProject(JVMPlatform, JSPlatform, NativePlatform)
)
.nativeEnablePlugins(ScalaNativeBrewedConfigPlugin)
.nativeSettings(
libraryDependencies += "com.armanbilge" %%% "epollcat" % "0.1.5",
libraryDependencies += "com.armanbilge" %%% "epollcat" % "0.1.6",
Test / nativeBrewFormulas ++= Set("s2n", "utf8proc"),
Test / envVars ++= Map("S2N_DONT_MLOCK" -> "1")
)
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
2 changes: 1 addition & 1 deletion modules/core/shared/src/main/scala/PreparedQuery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object PreparedQuery {
Stream.resource(proto.bind(args, or)).flatMap { cursor =>
def chunks: Stream[F, B] =
Stream.eval(cursor.execute(chunkSize)).flatMap { case (bs, more) =>
val s = Stream.chunk(Chunk.seq(bs))
val s = Stream.chunk(Chunk.from(bs))
if (more) s ++ chunks
else s
}
Expand Down
2 changes: 2 additions & 0 deletions modules/core/shared/src/main/scala/data/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ object Completion {
case object DropTrigger extends Completion
case object SetConstraints extends Completion
case object Explain extends Completion
case object Grant extends Completion
case object Revoke extends Completion
// more ...

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ object CommandComplete {
case Patterns.Copy(s) => apply(Completion.Copy(s.toInt))
case "SET CONSTRAINTS" => apply(Completion.SetConstraints)
case "EXPLAIN" => apply(Completion.Explain)
case "GRANT" => apply(Completion.Grant)
case "REVOKE" => apply(Completion.Revoke)
// more .. fill in as we hit them

case s => apply(Completion.Unknown(s))
Expand Down
6 changes: 1 addition & 5 deletions modules/core/shared/src/main/scala/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package skunk

import cats.effect.Resource
import org.typelevel.scalaccompat.annotation._
import org.typelevel.twiddles.TwiddleCompat

/**
Expand Down Expand Up @@ -126,8 +123,7 @@ import org.typelevel.twiddles.TwiddleCompat
* @groupname Companions Companion Objects
* @groupprio Companions 999
*/
@nowarn213("msg=package object inheritance is deprecated")
object `package` extends TwiddleCompat { // aka package object skunk, yes this actually works ...
package object skunk extends TwiddleCompat {

// we can use this to defeat value discarding warnings for erasable proof terms
private[skunk] def void(a: Any*): Unit = (a, ())._2
Expand Down
4 changes: 2 additions & 2 deletions modules/core/shared/src/main/scala/util/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ object Typer {
val Static: Typer = new Typer {
import Type._

val strategy = Strategy.BuiltinsOnly
val strategy: Strategy = Strategy.BuiltinsOnly

val staticByOid: Map[Int, Type] =
Map(
Expand Down Expand Up @@ -232,7 +232,7 @@ object Typer {
(p.typeInfoMap, p.relInfoMap).mapN { (tim, rim) =>
Static orElse new Typer {

val strategy = Strategy.SearchPath
val strategy: Strategy = Strategy.SearchPath

val nameToOid: Map[String, Int] =
tim.map { case (k, v) => v.name -> k }
Expand Down
26 changes: 26 additions & 0 deletions modules/tests/shared/src/test/scala/CommandTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ class CommandTest extends SkunkTest {
ON city;
""".command

val grant: Command[Void] =
sql"""
GRANT ALL PRIVILEGES
ON ALL TABLES IN SCHEMA public
TO skunk_role
""".command

val revoke: Command[Void] =
sql"""
REVOKE ALL PRIVILEGES
ON ALL TABLES IN SCHEMA public
FROM skunk_role
""".command

sessionTest("create table, create index, drop index, alter table and drop table") { s =>
for {
c <- s.execute(createTable)
Expand Down Expand Up @@ -545,4 +559,16 @@ class CommandTest extends SkunkTest {
.as("ok")
}

sessionTest("grant, revoke") { s =>
for{
_ <- s.execute(createRole)
c <- s.execute(grant)
_ <- assert("completion", c == Completion.Grant)
c <- s.execute(revoke)
_ <- assert("completion", c == Completion.Revoke)
_ <- s.execute(dropRole)
_ <- s.assertHealthy
} yield "ok"
}

}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.3
sbt.version=1.9.6
10 changes: 5 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)

addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.5.0-RC12")
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.5.0-RC12")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.5.3")
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.5.3")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.14")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.15")
addSbtPlugin("com.armanbilge" % "sbt-scala-native-config-brew-github-actions" % "0.2.0-RC1")

0 comments on commit 33670bb

Please sign in to comment.