Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies, build and CI #1478

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,58 @@ jobs:
steps:
- name: Checkout current branch
uses: actions/checkout@v3.3.0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v14
- name: Setup Java
uses: actions/setup-java@v4.5.0
with:
distribution: temurin
java-version: 11
check-latest: true
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Check Document Generation
run: ./sbt docs/compileDocs

lint:
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Checkout current branch
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4.5.0
with:
distribution: temurin
java-version: 11
check-latest: true
- 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: ['11', '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
- name: Setup Java
uses: actions/setup-java@v4.5.0
with:
distribution: temurin
java-version: ${{ matrix.java }}
check-latest: true
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Run JS tests
Expand Down Expand Up @@ -76,8 +103,12 @@ jobs:
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v14
- name: Setup Java
uses: actions/setup-java@v4.5.0
with:
distribution: temurin
java-version: 11
check-latest: true
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Release artifacts
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ jobs:
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.9.0
uses: actions/setup-java@v4.5.0
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Check that site workflow is up to date
run: sbt docs/checkGithubWorkflow
- name: Check website build process
run: sbt docs/buildWebsite
publish-docs:
Expand All @@ -41,7 +39,7 @@ jobs:
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.9.0
uses: actions/setup-java@v4.5.0
with:
distribution: temurin
java-version: 17
Expand All @@ -66,7 +64,7 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.9.0
uses: actions/setup-java@v4.5.0
with:
distribution: temurin
java-version: 17
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
}
}
66 changes: 45 additions & 21 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import BuildHelper._
import BuildHelper.*

welcomeMessage

Global / onChangedBuildSource := ReloadOnSourceChanges

inThisBuild(
List(
organization := "dev.zio",
homepage := Some(url("https://zio.dev/zio-config/")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
organization := "dev.zio",
homepage := Some(url("https://zio.dev/zio-config/")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"afsalthaj",
"Afsal Thaj",
Expand All @@ -20,14 +22,16 @@ inThisBuild(
"john@degoes.net",
url("http://degoes.net")
)
)
),
versionScheme := Some("early-semver")
)
)

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 +53,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 +127,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 +154,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 +179,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 +198,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 +235,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 +268,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 +285,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 +295,7 @@ lazy val zioConfigMagnolia = crossProject(JVMPlatform)
.settings(stdSettings("zio-config-magnolia"))
.settings(crossProjectSettings)
.settings(dottySettings)
.settings(enableMimaSettings)
.settings(
magnoliaDependencies,
scalacOptions ++= {
Expand All @@ -306,6 +320,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 +337,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 +355,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 +468,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
Loading