Skip to content

Commit

Permalink
Update dependencies and cleanup build
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou committed Nov 5, 2024
1 parent a023e9d commit e3a0afd
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 193 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,39 @@ jobs:
- name: Check Document Generation
run: ./sbt docs/compileDocs

lint:
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
java: [ 'adopt@1.11', 'adopt@1.21' ]
scala: [ '2.12.20', '2.13.15', '3.3.4' ]
platform: [ 'JS', 'JVM', 'Native' ]
steps:
- name: Checkout current branch
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v14
with:
java-version: 'adopt@1.11'
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Check formatting
run: sbt fmt
- name: Check binary compatibility
run: sbt "++2.12; checkMima; ++2.13; checkMima; ++3.3; checkMima"

test:
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
java: ['adopt@1.8', 'adopt@1.11']
scala: ['2.12.18', '2.13.12', '3.4.1']
java: ['adopt@1.11', 'adopt@1.21']
scala: ['2.12.20', '2.13.15', '3.3.4']
platform: ['JS', 'JVM', 'Native']
steps:
- name: Checkout current branch
Expand Down Expand Up @@ -78,6 +103,8 @@ jobs:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v14
with:
java-version: 'adopt@1.11'
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Release artifacts
Expand Down
16 changes: 13 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ includeCurlyBraceInSelectChains = false
danglingParentheses.preset = true
optIn.annotationNewlines = true

rewrite.rules = [RedundantBraces]
rewrite.rules = [SortImports, RedundantBraces]
project.excludeFilters = [
"core/src/main/scala/zio/config/ProductBuilder.scala",
"core/src/test/scala/zio/config/ProductBuilderTest.scala",
"core/shared/src/main/scala-3.x/*",
"magnolia/shared/src/main/scala-dotty/*"
]

fileOverride {
"glob:**/scala-dotty/**" {
runner.dialect = scala3
}
"glob:**/scala-3.x/**" {
runner.dialect = scala3
}
"glob:**/project/**" {
runner.dialect = scala3
}
}
55 changes: 39 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import BuildHelper._
import BuildHelper.*

welcomeMessage

Global / onChangedBuildSource := ReloadOnSourceChanges

inThisBuild(
List(
organization := "dev.zio",
Expand All @@ -24,10 +26,11 @@ inThisBuild(
)
)

addCommandAlias("fmt", "; scalafmtSbt; scalafmt; test:scalafmt")
addCommandAlias("lint", "; ++2.13; scalafmtSbtCheck; scalafmtCheck; ++3.3; scalafmtCheck")
addCommandAlias("fmt", "; ++2.13; scalafmtSbt; scalafmtAll; ++3.3; scalafmtAll")
addCommandAlias("fix", "; all compile:scalafix test:scalafix; all scalafmtSbt scalafmtAll")
addCommandAlias("compileAll", "; ++2.12.18; root2-12/compile; ++2.13.12!; root2-13/compile; ++3.2.2!; root3/compile;")
addCommandAlias("testAll", "; ++2.12.18; root2-12/test; ++2.13.12!; root2-13/test; ++3.2.2!; root3/test;")
addCommandAlias("compileAll", "; ++2.12; root2-12/compile; ++2.13!; root2-13/compile; ++3.3!; root3/compile;")
addCommandAlias("testAll", "; ++2.12; root2-12/test; ++2.13!; root2-13/test; ++3.3!; root3/test;")
addCommandAlias(
"testJS",
";zioConfigJS/test"
Expand All @@ -49,13 +52,17 @@ addCommandAlias(
";testJVM212;testJVM213;testJVM3x;"
)

val awsVersion = "1.12.721"
val zioAwsVersion = "5.19.33.2"
val zioVersion = "2.0.13"
addCommandAlias(
"checkMima",
"all zioConfigJVM/mimaReportBinaryIssues zioConfigTypesafeJVM/mimaReportBinaryIssues zioConfigDerivationJVM/mimaReportBinaryIssues zioConfigYamlJVM/mimaReportBinaryIssues zioConfigMagnoliaJVM/mimaReportBinaryIssues zioConfigAwsJVM/mimaReportBinaryIssues zioConfigZioAwsJVM/mimaReportBinaryIssues zioConfigXmlJVM/mimaReportBinaryIssues"
)

val awsVersion = "1.12.777"
val zioAwsVersion = "7.28.29.3"
val zioVersion = "2.1.11"
val magnoliaVersion = "0.17.0"
val refinedVersion = "0.11.1"
val pureconfigVersion = "0.16.0"
val shapelessVersion = "2.4.0-M1"
val refinedVersion = "0.11.2"
val pureconfigVersion = "0.17.7"

lazy val magnoliaDependencies =
libraryDependencies ++= {
Expand Down Expand Up @@ -119,25 +126,25 @@ lazy val root =
project
.in(file("."))
.settings(publish / skip := true)
.aggregate(scala213projects: _*)
.aggregate(scala213projects *)

lazy val `root2-12` =
project
.in(file("2-12"))
.settings(publish / skip := true)
.aggregate(scala212projects: _*)
.aggregate(scala212projects *)

lazy val `root2-13` =
project
.in(file("2-13"))
.settings(publish / skip := true)
.aggregate(scala213projects: _*)
.aggregate(scala213projects *)

lazy val `root3` =
project
.in(file("3"))
.settings(publish / skip := true)
.aggregate(scala3projects: _*)
.aggregate(scala3projects *)

lazy val zioConfig = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("core"))
Expand All @@ -146,6 +153,7 @@ lazy val zioConfig = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.enablePlugins(BuildInfoPlugin)
.settings(buildInfoSettings("zio.config"))
.settings(macroDefinitionSettings)
.settings(enableMimaSettings)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion,
Expand All @@ -170,6 +178,7 @@ lazy val zioConfigAws = crossProject(JVMPlatform)
.settings(stdSettings("zio-config-aws"))
.settings(crossProjectSettings)
.settings(dottySettings)
.settings(enableMimaSettings)
.settings(
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk-ssm" % awsVersion,
Expand All @@ -188,6 +197,7 @@ lazy val zioConfigZioAws = crossProject(JVMPlatform)
.settings(stdSettings("zio-config-zio-aws"))
.settings(crossProjectSettings)
.settings(dottySettings)
.settings(enableMimaSettings)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio-aws-ssm" % zioAwsVersion,
Expand Down Expand Up @@ -224,6 +234,7 @@ lazy val zioConfigPureconfig = crossProject(JVMPlatform)
.settings(stdSettings("zio-config-pureconfig"))
.settings(crossProjectSettings)
.settings(dottySettings)
.settings(enableMimaSettings)
.settings(
pureconfigDependencies,
libraryDependencies ++=
Expand Down Expand Up @@ -256,7 +267,7 @@ lazy val examples = crossProject(JVMPlatform)

val runTasks = classes.map { cc =>
Def.task {
runs.toTask(s" ${cc}").value
runs.toTask(s" $cc").value
}
}

Expand All @@ -273,6 +284,7 @@ lazy val zioConfigDerivation = crossProject(JVMPlatform)
.settings(stdSettings("zio-config-derivation"))
.settings(crossProjectSettings)
.settings(dottySettings)
.settings(enableMimaSettings)
.dependsOn(zioConfig)

lazy val zioConfigDerivationJVM = zioConfigDerivation.jvm
Expand All @@ -282,6 +294,7 @@ lazy val zioConfigMagnolia = crossProject(JVMPlatform)
.settings(stdSettings("zio-config-magnolia"))
.settings(crossProjectSettings)
.settings(dottySettings)
.settings(enableMimaSettings)
.settings(
magnoliaDependencies,
scalacOptions ++= {
Expand All @@ -306,6 +319,7 @@ lazy val zioConfigTypesafe = crossProject(JVMPlatform)
.settings(stdSettings("zio-config-typesafe"))
.settings(crossProjectSettings)
.settings(dottySettings)
.settings(enableMimaSettings)
.settings(
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.4.3",
Expand All @@ -322,9 +336,10 @@ lazy val zioConfigYaml = crossProject(JVMPlatform)
.in(file("yaml"))
.settings(stdSettings("zio-config-yaml"))
.settings(crossProjectSettings)
.settings(enableMimaSettings)
.settings(
libraryDependencies ++= Seq(
"org.snakeyaml" % "snakeyaml-engine" % "2.6",
"org.snakeyaml" % "snakeyaml-engine" % "2.7",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
Expand All @@ -339,6 +354,7 @@ lazy val zioConfigXml = crossProject(JVMPlatform)
.in(file("xml"))
.settings(stdSettings("zio-config-xml"))
.settings(crossProjectSettings)
.settings(enableMimaSettings)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio-parser" % "0.1.9",
Expand Down Expand Up @@ -451,3 +467,10 @@ lazy val docs = project
zioConfigMagnoliaJVM
)
.enablePlugins(WebsitePlugin)

lazy val enableMimaSettings =
Def.settings(
mimaFailOnProblem := true,
mimaPreviousArtifacts := previousStableVersion.value.map(organization.value %% moduleName.value % _).toSet,
mimaBinaryIssueFilters := Seq()
)
32 changes: 18 additions & 14 deletions core/shared/src/main/scala-3.x/zio/config/TupleConversion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ trait TupleConversion[A, B] {
def from(b: B): A
}

object TupleConversion extends ImplicitTupleConversion
object TupleConversion extends ImplicitTupleConversion

trait ImplicitTupleConversion {
inline given autoTupleConversion[Prod <: Product](using m: Mirror.ProductOf[Prod]): TupleConversion[Prod, m.MirroredElemTypes] =
new TupleConversion[Prod, m.MirroredElemTypes] {
def to(a: Prod): m.MirroredElemTypes = Tuple.fromProductTyped(a)
def from(b: m.MirroredElemTypes): Prod = m.fromProduct(b)
}
inline given autoTupleConversion[Prod <: Product](using
m: Mirror.ProductOf[Prod]
): TupleConversion[Prod, m.MirroredElemTypes] =
new TupleConversion[Prod, m.MirroredElemTypes] {
def to(a: Prod): m.MirroredElemTypes = Tuple.fromProductTyped(a)
def from(b: m.MirroredElemTypes): Prod = m.fromProduct(b)
}

inline given autoTupleConversion1[Prod <: Product, A](using c: TupleConversion[Prod, Tuple1[A]]): TupleConversion[Prod, A] =
new TupleConversion[Prod, A] {
def to(a: Prod): A = {
val Tuple1(v) = c.to(a)
v
}
def from(b: A): Prod = c.from(Tuple1(b))
}
inline given autoTupleConversion1[Prod <: Product, A](using
c: TupleConversion[Prod, Tuple1[A]]
): TupleConversion[Prod, A] =
new TupleConversion[Prod, A] {
def to(a: Prod): A = {
val Tuple1(v) = c.to(a)
v
}
def from(b: A): Prod = c.from(Tuple1(b))
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.config.examples.autoderivation

import zio.config._
import zio.config.derivation.{name, discriminator}
import zio.config.derivation.{discriminator, name}
import zio.config.examples.typesafe.EitherImpureOps
import zio.config.magnolia.deriveConfig
import zio.config.typesafe.TypesafeConfigProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ object DeriveConfig {
.toMap

val keyNameIfPureConfig: Option[String] =
sealedTrait.annotations.collectFirst { case discriminator: discriminator => discriminator.keyName }
sealedTrait.annotations.collectFirst { case d: discriminator => d.keyName }

val desc =
keyNameIfPureConfig match {
Expand Down
Loading

0 comments on commit e3a0afd

Please sign in to comment.