diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c39025d..ad7d503 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,9 @@ name: Continuous Integration on: pull_request: - branches: ['*'] + branches: ['**'] push: - branches: ['*'] + branches: ['**'] tags: [v*] env: @@ -26,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.13.5] + scala: [2.13.6] java: [adopt@1.8] runs-on: ${{ matrix.os }} steps: @@ -53,9 +53,9 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Check that workflows are up to date - run: sbt ++${{ matrix.scala }} githubWorkflowCheck + run: sbt --client '++${{ matrix.scala }}; githubWorkflowCheck' - - run: sbt ++${{ matrix.scala }} ci + - run: sbt --client '++${{ matrix.scala }}; ci' - name: Compress target directories run: tar cf targets.tar target db-core-jdbc/target project/target @@ -73,7 +73,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.13.5] + scala: [2.13.6] java: [adopt@1.8] runs-on: ${{ matrix.os }} steps: @@ -99,12 +99,12 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Download target directories (2.13.5) + - name: Download target directories (2.13.6) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-2.13.5-${{ matrix.java }} + name: target-${{ matrix.os }}-2.13.6-${{ matrix.java }} - - name: Inflate target directories (2.13.5) + - name: Inflate target directories (2.13.6) run: | tar xf targets.tar rm targets.tar @@ -112,4 +112,4 @@ jobs: - name: Import signing key run: echo $PGP_SECRET | base64 -d | gpg --import - - run: sbt ++${{ matrix.scala }} release \ No newline at end of file + - run: sbt --client '++${{ matrix.scala }}; release' \ No newline at end of file diff --git a/.scalafmt.conf b/.scalafmt.conf index a8ead2d..dff99c2 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -16,58 +16,68 @@ # limitations under the License. # -# See https://scalameta.org/scalafmt/docs/configuration.html for details, -# mostly done by trial and error. But I guess this formatting is "good enough" +# See https://scalameta.org/scalafmt/docs/configuration.html for details # +# https://github.com/scalameta/scalafmt/releases +version = 3.0.0-RC6 -#https://github.com/scalameta/scalafmt/releases -version = 2.7.5 - -project { - #if you don't specify that files ending in .scala .sbt with $, - # .scalafmt.conf is included in the formatting attempt - includeFilters = [ - ".*.\\.scala$" - ".*\\..sbt$" - ] +fileOverride { + "glob:**/src/main/scala/**" { + runner.dialect = scala213source3 + } + "glob:**/src/test/scala/**" { + runner.dialect = scala213source3 + } + "glob:**/src/main/scala-2/**" { + runner.dialect = scala213source3 + } + "glob:**/src/test/scala-2/**" { + runner.dialect = scala213source3 + } + "glob:**/src/main/scala-3/**" { + runner.dialect = scala3 + } + "glob:**/src/test/scala-3/**" { + runner.dialect = scala3 + } + "glob:**/project/*.scala" { + runner.dialect = scala212 + } + "glob:**/*.sbt" { + runner.dialect = Sbt1 + } } maxColumn = 120 -# Note. Only for the truest vertical aligners. This is a new option, -# feel free to open PR enabling more crazy vertical alignment here. -# Expect changes. align = most align.openParenCallSite = false align.openParenDefnSite = false align.multiline = true +align.tokens."+" = [ -align.tokens.add = [ - - {code = "<-", owner = "Enumerator.Generator"} - //Everything before the Term.Assign was the default regex. To find the - //default value, look through the code here: - //https://github.com/scalameta/scalafmt/blob/master/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala - {code = "=", owner = "(Enumerator.Generator|Val|Defn.(Va(l|r)|Def|Type))|Term.Assign"} + {code = "<-", owner = "Enumerator.Generator"}, - //used to align comments - "//" + # Everything before the Term.Assign was the default regex. To find the + # default value, look through the code here: + # https://github.com/scalameta/scalafmt/blob/master/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala + {code = "=", owner = "(Enumerator.Generator|Val|Defn.(Va(l|r)|Def|Type))|Term.Assign|Param"}, - //used for aligning type definition - ":" - - //used when creating tuples - {code = "->", owner = "Term.ApplyInfix"}, + "//", # used to align comments + ":", # used for aligning type definition + {code = "->", owner = "Term.ApplyInfix"}, # used to align tuples 1 -> 2 //sbt specific {code = "%", owner = "Term.ApplyInfix"}, - {code = "%%", owner = "Term.ApplyInfix"} - {code = "%%%", owner = "Term.ApplyInfix"} - {code = ":=", owner = "Term.ApplyInfix"} - {code = "withSources", owner = "Term.ApplyInfix"} + {code = "%%", owner = "Term.ApplyInfix"}, + {code = "%%%", owner = "Term.ApplyInfix"}, + {code = ":=", owner = "Term.ApplyInfix"}, + {code = "withSources", owner = "Term.ApplyInfix"}, "extends" ] +############################################################################### + continuationIndent { callSite = 2 defnSite = 2 @@ -76,12 +86,16 @@ continuationIndent { withSiteRelativeToExtends = 0 } +############################################################################### + verticalMultiline.atDefnSite = false verticalMultiline.newlineAfterOpenParen = true verticalMultiline.arityThreshold = 3 +############################################################################### + newlines { - alwaysBeforeTopLevelStatements = true + topLevelStatements = [before] sometimesBeforeColonInMethodReturnType = true penalizeSingleSelectMultiArgList = false alwaysBeforeElseAfterCurlyIf = true @@ -91,30 +105,35 @@ newlines { afterCurlyLambda = squash } +############################################################################### + spaces { afterKeywordBeforeParen = true } +############################################################################### + binPack { parentConstructors = true literalArgumentLists = true literalsMinArgCount = 5 } +############################################################################### optIn { breaksInsideChains = false - //preserves existing newlines in . chain calls. - //See: optIn.breakChainOnFirstMethodDot = true + # preserves existing newlines in . chain calls. + # See: optIn.breakChainOnFirstMethodDot = true breakChainOnFirstMethodDot = true blankLineBeforeDocstring = true } +############################################################################### + rewrite { rules = [ - SortImports SortModifiers - # if your for has more than one single <- then it gets transformed into a multit-line curly brace one PreferCurlyFors AvoidInfix RedundantBraces @@ -127,40 +146,21 @@ rewrite.redundantBraces.methodBodies = true rewrite.redundantBraces.includeUnitMethods = false rewrite.redundantBraces.stringInterpolation = true rewrite.redundantBraces.parensForOneLineApply = true +rewrite.neverInfix.excludeFilters = [withSources] -#we only really want to disable infix notation -# for map and flatMap and the like, because it -# kills IDE performance and type inference -rewrite.neverInfix.excludeFilters = [ - until - to - by - eq - ne - "should.*" - "contain.*" - "must.*" - in - be - of # behaviour of ("X") - taggedAs - thrownBy - synchronized - have - when - size - theSameElementsAs - withSources -] +############################################################################### preset = default danglingParentheses.preset = true +############################################################################### + assumeStandardLibraryStripMargin = true includeNoParensInSelectChains = false includeCurlyBraceInSelectChains = true trailingCommas = multiple +############################################################################### runner { optimizer { @@ -171,4 +171,4 @@ runner { # minimum number of func arguments before config-style (look at top of file) is enabled forceConfigStyleMinArgCount = 2 } -} \ No newline at end of file +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 36af979..0afccc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # unreleased +This is the first release that is also available for Scala 3! + +### dependency upgrades + +- [pureharm-core-anomaly](https://github.com/busymachines/pureharm-core/releases) `0.3.0` +- [pureharm-db-core](https://github.com/busymachines/pureharm-db-core/releases) `0.5.0` +- [pgjdbc](https://github.com/pgjdbc/pgjdbc/releases) `42.2.23` + +### internals +- bump scalafmt to `3.0.0-RC6` — from `2.7.5` +- bump sbt to `1.5.5` +- bump sbt-spiewak to `0.21.0` + # 0.4.0 ### dependency upgrades diff --git a/build.sbt b/build.sbt index 0f01ebe..add10a0 100644 --- a/build.sbt +++ b/build.sbt @@ -18,12 +18,12 @@ //============================== build details ================================ //============================================================================= -addCommandAlias("github-gen", "githubWorkflowGenerate") -addCommandAlias("github-check", "githubWorkflowCheck") Global / onChangedBuildSource := ReloadOnSourceChanges -val Scala213 = "2.13.5" -val Scala3RC1 = "3.0.0-RC1" +// format: off +val Scala213 = "2.13.6" +val Scala3 = "3.0.1" +// format: on //============================================================================= //============================ publishing details ============================= @@ -32,10 +32,10 @@ val Scala3RC1 = "3.0.0-RC1" //see: https://github.com/xerial/sbt-sonatype#buildsbt ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org" -ThisBuild / baseVersion := "0.4" -ThisBuild / organization := "com.busymachines" +ThisBuild / baseVersion := "0.5" +ThisBuild / organization := "com.busymachines" ThisBuild / organizationName := "BusyMachines" -ThisBuild / homepage := Option(url("https://github.com/busymachines/pureharm-db-core-jdbc")) +ThisBuild / homepage := Option(url("https://github.com/busymachines/pureharm-db-core-jdbc")) ThisBuild / scmInfo := Option( ScmInfo( @@ -44,8 +44,8 @@ ThisBuild / scmInfo := Option( ) ) -/** I want my email. So I put this here. To reduce a few lines of code, - * the sbt-spiewak plugin generates this (except email) from these two settings: +/** I want my email. So I put this here. To reduce a few lines of code, the sbt-spiewak plugin generates this (except + * email) from these two settings: * {{{ * ThisBuild / publishFullName := "Loránd Szakács" * ThisBuild / publishGithubUser := "lorandszakacs" @@ -60,7 +60,7 @@ ThisBuild / developers := List( ) ) -ThisBuild / startYear := Some(2019) +ThisBuild / startYear := Some(2019) ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")) //until we get to 1.0.0, we keep strictSemVer false @@ -74,8 +74,8 @@ ThisBuild / crossScalaVersions := List(Scala213) //List(Scala213, Scala3RC1) //required for binary compat checks ThisBuild / versionIntroduced := Map( - Scala213 -> "0.1.0", - Scala3RC1 -> "0.1.0", + Scala213 -> "0.1.0", + Scala3 -> "0.5.0", ) //============================================================================= @@ -85,12 +85,12 @@ ThisBuild / resolvers += Resolver.sonatypeRepo("releases") ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots") // format: off -val pureharmCoreV = "0.2.0" //https://github.com/busymachines/pureharm-core/releases -val pureharmDBCoreV = "0.4.0" //https://github.com/busymachines/pureharm-db-core/releases -val attoV = "0.9.3" //https://github.com/tpolecat/atto/releases -val pgJDBCV = "42.2.19" //java — https://github.com/pgjdbc/pgjdbc/releases -val pureharmTestkitV = "0.3.0" //https://github.com/busymachines/pureharm-testkit/releases -val log4catsV = "1.2.2" //https://github.com/typelevel/log4cats/releases +val pureharmCoreV = "0.3.0" //https://github.com/busymachines/pureharm-core/releases +val pureharmDBCoreV = "0.5.0" //https://github.com/busymachines/pureharm-db-core/releases +val attoV = "0.9.5" //https://github.com/tpolecat/atto/releases +val pgJDBCV = "42.2.23" //java — https://github.com/pgjdbc/pgjdbc/releases +val pureharmTestkitV = "0.4.0" //https://github.com/busymachines/pureharm-testkit/releases +val log4catsV = "2.1.1" //https://github.com/typelevel/log4cats/releases // format: on //============================================================================= @@ -100,7 +100,7 @@ val log4catsV = "1.2.2" //https://github.com/typelevel/log4cats/r lazy val root = project .in(file(".")) .aggregate( - `db-core-jdbc`, + `db-core-jdbc` ) .enablePlugins(NoPublishPlugin) .enablePlugins(SonatypeCiReleasePlugin) @@ -129,16 +129,15 @@ lazy val `db-core-jdbc` = project //============================================================================= lazy val commonSettings = Seq( - Compile / unmanagedSourceDirectories ++= { - val major = if (isDotty.value) "-3" else "-2" - List(CrossType.Pure, CrossType.Full).flatMap( - _.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + major)) - ) - }, - Test / unmanagedSourceDirectories ++= { - val major = if (isDotty.value) "-3" else "-2" - List(CrossType.Pure, CrossType.Full).flatMap( - _.sharedSrcDir(baseDirectory.value, "test").toList.map(f => file(f.getPath + major)) - ) - }, + scalacOptions ++= scalaCompilerOptions(scalaVersion.value) ) + +def scalaCompilerOptions(scalaVersion: String): Seq[String] = + CrossVersion.partialVersion(scalaVersion) match { + case Some((2, _)) => + Seq[String]( + //"-Xsource:3" + ) + case _ => Seq.empty[String] + } + diff --git a/db-core-jdbc/src/main/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionInterpreters.scala b/db-core-jdbc/src/main/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionInterpreters.scala index d21c4e9..8f96ac1 100644 --- a/db-core-jdbc/src/main/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionInterpreters.scala +++ b/db-core-jdbc/src/main/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionInterpreters.scala @@ -21,8 +21,10 @@ import cats.syntax.all._ import busymachines.pureharm.db._ import org.postgresql.util._ -/** @author Lorand Szakacs, https://github.com/lorandszakacs - * @since 02 Jul 2020 +/** @author + * Lorand Szakacs, https://github.com/lorandszakacs + * @since 02 + * Jul 2020 */ object PSQLExceptionInterpreters { @@ -92,22 +94,18 @@ object PSQLExceptionInterpreters { } - /** Only call when org.postgresql.util.PSQLException#getSQLState == - * org.postgresql.util.PSQLStates.UniqueViolation]] + /** Only call when org.postgresql.util.PSQLException#getSQLState == org.postgresql.util.PSQLStates.UniqueViolation]] * - * Will attempt to extract the values of the state by doing regex over the - * error message... yey, java? + * Will attempt to extract the values of the state by doing regex over the error message... yey, java? */ def uniqueKey[F[_]: MonadThrow](e: PSQLException): F[DBUniqueConstraintViolationAnomaly] = PSQLExceptionInterpreters.PSQLErrorParsers .unique[F](e.getServerErrorMessage.getDetail) .map(t => DBUniqueConstraintViolationAnomaly(t._1, t._2)) - /** Only call when org.postgresql.util.PSQLException#getSQLState == - * org.postgresql.util.PSQLStates.ForeignKeyViolation + /** Only call when org.postgresql.util.PSQLException#getSQLState == org.postgresql.util.PSQLStates.ForeignKeyViolation * - * Will attempt to extract the values of the state by doing regex over the - * error message... yey, java? + * Will attempt to extract the values of the state by doing regex over the error message... yey, java? */ def foreignKey[F[_]: MonadThrow](e: PSQLException): F[DBForeignKeyConstraintViolationAnomaly] = { val msg = e.getServerErrorMessage diff --git a/db-core-jdbc/src/test/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionParserTests.scala b/db-core-jdbc/src/test/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionParserTests.scala index c23402d..79b42e9 100644 --- a/db-core-jdbc/src/test/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionParserTests.scala +++ b/db-core-jdbc/src/test/scala/busymachines/pureharm/db/pgjdbc/PSQLExceptionParserTests.scala @@ -20,8 +20,10 @@ import cats.effect.IO import busymachines.pureharm.testkit._ import org.typelevel.log4cats.slf4j._ -/** @author Lorand Szakacs, https://github.com/lorandszakacs - * @since 02 Jul 2020 +/** @author + * Lorand Szakacs, https://github.com/lorandszakacs + * @since 02 + * Jul 2020 */ final class PSQLExceptionParserTests extends PureharmTest { diff --git a/project/build.properties b/project/build.properties index 9170632..f4aa9f7 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ // https://github.com/sbt/sbt/releases -sbt.version=1.5.0 +sbt.version=1.5.5 diff --git a/project/plugins.sbt b/project/plugins.sbt index 16268d2..a6cc5c5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ // format: off -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2" ) //https://github.com/scalameta/sbt-scalafmt/releases -addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.20.4") //https://github.com/djspiewak/sbt-spiewak/releases/ -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0" ) //https://github.com/sbt/sbt-header/releases \ No newline at end of file +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3" ) // https://github.com/scalameta/sbt-scalafmt/releases +addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.21.0") // https://github.com/djspiewak/sbt-spiewak/releases/ +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0" ) // https://github.com/sbt/sbt-header/releases