From e3a0afd81ae5a5ed609ac54ee29840fc0e92e217 Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Tue, 5 Nov 2024 13:04:15 +0530 Subject: [PATCH 1/4] Update dependencies and cleanup build --- .github/workflows/ci.yml | 31 +++- .scalafmt.conf | 16 +- build.sbt | 55 +++++-- .../zio/config/TupleConversion.scala | 32 ++-- .../AutoDerivationPureConfig.scala | 2 +- .../zio/config/magnolia/DeriveConfig.scala | 2 +- .../zio/config/magnolia/DeriveConfig.scala | 154 +++++++++--------- .../zio/config/magnolia/Macros.scala | 35 ++-- .../examples/AutoDerivationSimple.scala | 30 ++-- project/BuildHelper.scala | 39 +++-- project/build.properties | 2 +- project/plugins.sbt | 35 ++-- .../zio/config/refined/NumericTestTypes.scala | 8 +- .../zio/config/refined/NumericTestTypes.scala | 8 +- .../zio/config/magnolia/AnnotationsTest.scala | 2 +- .../magnolia/CoproductSealedTraitSpec.scala | 2 +- .../TypesafeConfigProviderZIOTest.scala | 2 +- .../zio/config/yaml/YamlConfigSpec.scala | 4 +- 18 files changed, 266 insertions(+), 193 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 974bf3930..4013039ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.scalafmt.conf b/.scalafmt.conf index 4474d18b2..411b2b22e 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -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 + } +} diff --git a/build.sbt b/build.sbt index 2898abf80..fabc2d8b9 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,9 @@ -import BuildHelper._ +import BuildHelper.* welcomeMessage +Global / onChangedBuildSource := ReloadOnSourceChanges + inThisBuild( List( organization := "dev.zio", @@ -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" @@ -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 ++= { @@ -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")) @@ -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, @@ -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, @@ -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, @@ -224,6 +234,7 @@ lazy val zioConfigPureconfig = crossProject(JVMPlatform) .settings(stdSettings("zio-config-pureconfig")) .settings(crossProjectSettings) .settings(dottySettings) + .settings(enableMimaSettings) .settings( pureconfigDependencies, libraryDependencies ++= @@ -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 } } @@ -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 @@ -282,6 +294,7 @@ lazy val zioConfigMagnolia = crossProject(JVMPlatform) .settings(stdSettings("zio-config-magnolia")) .settings(crossProjectSettings) .settings(dottySettings) + .settings(enableMimaSettings) .settings( magnoliaDependencies, scalacOptions ++= { @@ -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", @@ -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 ), @@ -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", @@ -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() + ) diff --git a/core/shared/src/main/scala-3.x/zio/config/TupleConversion.scala b/core/shared/src/main/scala-3.x/zio/config/TupleConversion.scala index b0838cd91..f442b2a07 100644 --- a/core/shared/src/main/scala-3.x/zio/config/TupleConversion.scala +++ b/core/shared/src/main/scala-3.x/zio/config/TupleConversion.scala @@ -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)) + } } diff --git a/examples/shared/src/main/scala/zio/config/examples/autoderivation/AutoDerivationPureConfig.scala b/examples/shared/src/main/scala/zio/config/examples/autoderivation/AutoDerivationPureConfig.scala index e5ca5acd3..f43f7ca8e 100644 --- a/examples/shared/src/main/scala/zio/config/examples/autoderivation/AutoDerivationPureConfig.scala +++ b/examples/shared/src/main/scala/zio/config/examples/autoderivation/AutoDerivationPureConfig.scala @@ -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 diff --git a/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala b/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala index 6e7c63915..7947c163f 100644 --- a/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala +++ b/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala @@ -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 { diff --git a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala index d54a467ac..9ce23bf4e 100644 --- a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala +++ b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala @@ -9,11 +9,11 @@ import java.time.{Duration, Instant, LocalDate, LocalDateTime, LocalTime, Offset import java.util.UUID import scala.concurrent.duration.{Duration => ScalaDuration} import scala.deriving._ -import scala.compiletime.{erasedValue, summonInline, constValue, summonFrom, constValueTuple} +import scala.compiletime.{constValue, constValueTuple, erasedValue, summonFrom, summonInline} import scala.quoted import scala.util.Try import DeriveConfig._ -import zio.{Config, ConfigProvider, LogLevel, Chunk}, Config._ +import zio.{Chunk, Config, ConfigProvider, LogLevel}, Config._ import zio.config.syntax._ import zio.config.derivation._ @@ -44,47 +44,52 @@ object DeriveConfig { sealed trait Metadata { def originalName: String = this match { - case Metadata.Object(name, _) => name.originalName - case Metadata.Product(name, _) => name.originalName + case Metadata.Object(name, _) => name.originalName + case Metadata.Product(name, _) => name.originalName case Metadata.Coproduct(name, _) => name.originalName } def alternativeNames: List[String] = this match { - case Metadata.Object(_, _) => Nil - case Metadata.Product(name, _) => name.alternativeNames + case Metadata.Object(_, _) => Nil + case Metadata.Product(name, _) => name.alternativeNames case Metadata.Coproduct(name, _) => name.alternativeNames } } object Metadata { - final case class Object[T](name: ProductName, constValue: T) extends Metadata - final case class Product(name: ProductName, fields: List[FieldName]) extends Metadata + final case class Object[T](name: ProductName, constValue: T) extends Metadata + final case class Product(name: ProductName, fields: List[FieldName]) extends Metadata final case class Coproduct(name: CoproductName, metadata: List[Metadata]) extends Metadata } final case class FieldName(originalName: String, alternativeNames: List[String], descriptions: List[String]) final case class ProductName(originalName: String, alternativeNames: List[String], descriptions: List[String]) - final case class CoproductName(originalName: String, alternativeNames: List[String], descriptions: List[String], typeDiscriminator: Option[String]) - - lazy given DeriveConfig[Secret] = DeriveConfig.from(secret) - lazy given DeriveConfig[OffsetDateTime] = DeriveConfig.from(offsetDateTime) - lazy given DeriveConfig[LogLevel] = DeriveConfig.from(logLevel) - lazy given DeriveConfig[String] = DeriveConfig.from(string) - lazy given DeriveConfig[Boolean] = DeriveConfig.from(boolean) - lazy given DeriveConfig[Int] = DeriveConfig.from(int) - lazy given DeriveConfig[BigInt] = DeriveConfig.from(bigInt) - lazy given DeriveConfig[Float] = DeriveConfig.from(float) - lazy given DeriveConfig[Double] = DeriveConfig.from(double) - lazy given DeriveConfig[BigDecimal] = DeriveConfig.from(bigDecimal) - lazy given DeriveConfig[URI] = DeriveConfig.from(uri) - lazy given DeriveConfig[zio.Duration] = DeriveConfig.from(duration) - lazy given DeriveConfig[LocalDate] = DeriveConfig.from(localDate) - lazy given DeriveConfig[LocalTime] = DeriveConfig.from(localTime) - lazy given DeriveConfig[LocalDateTime] = DeriveConfig.from(localDateTime) - lazy given DeriveConfig[Byte] = DeriveConfig(Config.byte) - lazy given DeriveConfig[Short] = DeriveConfig(Config.short) - lazy given DeriveConfig[UUID] = DeriveConfig(Config.uuid) - lazy given DeriveConfig[Long] = DeriveConfig(Config.long) + final case class CoproductName( + originalName: String, + alternativeNames: List[String], + descriptions: List[String], + typeDiscriminator: Option[String] + ) + + given DeriveConfig[Secret] = DeriveConfig.from(secret) + given DeriveConfig[OffsetDateTime] = DeriveConfig.from(offsetDateTime) + given DeriveConfig[LogLevel] = DeriveConfig.from(logLevel) + given DeriveConfig[String] = DeriveConfig.from(string) + given DeriveConfig[Boolean] = DeriveConfig.from(boolean) + given DeriveConfig[Int] = DeriveConfig.from(int) + given DeriveConfig[BigInt] = DeriveConfig.from(bigInt) + given DeriveConfig[Float] = DeriveConfig.from(float) + given DeriveConfig[Double] = DeriveConfig.from(double) + given DeriveConfig[BigDecimal] = DeriveConfig.from(bigDecimal) + given DeriveConfig[URI] = DeriveConfig.from(uri) + given DeriveConfig[zio.Duration] = DeriveConfig.from(duration) + given DeriveConfig[LocalDate] = DeriveConfig.from(localDate) + given DeriveConfig[LocalTime] = DeriveConfig.from(localTime) + given DeriveConfig[LocalDateTime] = DeriveConfig.from(localDateTime) + given DeriveConfig[Byte] = DeriveConfig(Config.byte) + given DeriveConfig[Short] = DeriveConfig(Config.short) + given DeriveConfig[UUID] = DeriveConfig(Config.uuid) + given DeriveConfig[Long] = DeriveConfig(Config.long) given optDesc[A](using ev: DeriveConfig[A]): DeriveConfig[Option[A]] = DeriveConfig.from(ev.desc.optional) @@ -113,28 +118,29 @@ object DeriveConfig { inline def summonDeriveConfigForCoProduct[T <: Tuple]: List[DeriveConfig[Any]] = inline erasedValue[T] match case _: EmptyTuple => Nil - case _: (t *: ts) => + case _: (t *: ts) => val desc = summonInline[DeriveConfig[t]] DeriveConfig[Any]( - desc.desc, desc.metadata + desc.desc, + desc.metadata ) :: summonDeriveConfigForCoProduct[ts] inline def summonDeriveConfigAll[T <: Tuple]: List[DeriveConfig[_]] = inline erasedValue[T] match - case _ : EmptyTuple => Nil - case _: (t *: ts) => + case _: EmptyTuple => Nil + case _: (t *: ts) => summonInline[DeriveConfig[t]] :: summonDeriveConfigAll[ts] inline def labelsOf[T <: Tuple]: List[String] = inline erasedValue[T] match case _: EmptyTuple => Nil - case _ : ( t *: ts) => constValue[t].toString :: labelsOf[ts] + case _: (t *: ts) => constValue[t].toString :: labelsOf[ts] inline def customNamesOf[T]: List[String] = Macros.nameOf[T].map(_.name) inline def customFieldNamesOf[T]: Map[String, name] = - Macros.fieldNameOf[T].flatMap({ case(str, nmes) => nmes.map(name => (str, name)) }).toMap + Macros.fieldNameOf[T].flatMap { case (str, nmes) => nmes.map(name => (str, name)) }.toMap inline given derived[T](using m: Mirror.Of[T]): DeriveConfig[T] = inline m match @@ -176,11 +182,11 @@ object DeriveConfig { Macros.defaultValuesOf[T].toMap lazy val fieldNames = - originalFieldNamesList.foldRight(Nil: List[FieldName])((str, list) => { + originalFieldNamesList.foldRight(Nil: List[FieldName]) { (str, list) => val alternativeNames = customFieldNameMap.get(str).map(v => List(v.name)).getOrElse(Nil) - val descriptions = documentations.get(str).map(_.map(_.describe)).getOrElse(Nil) + val descriptions = documentations.get(str).map(_.map(_.describe)).getOrElse(Nil) FieldName(str, alternativeNames.toList, descriptions) :: list - }) + } lazy val fieldConfigs = summonDeriveConfigAll[m.MirroredElemTypes].asInstanceOf[List[DeriveConfig[Any]]] @@ -209,13 +215,15 @@ object DeriveConfig { desc.metadata match { case Some(Metadata.Product(productName, fields)) if (fields.nonEmpty) => tryAllKeys(desc.desc, Some(productName.originalName), productName.alternativeNames) - case Some(_) => desc.desc - case None => desc.desc + case Some(_) => desc.desc + case None => desc.desc } - ).reduce(_ orElse _) + ) + .reduce(_ orElse _) case Some(keyName) => - Config.string(keyName) + Config + .string(keyName) .switch( allDescs.flatMap { desc => desc.metadata match { @@ -237,52 +245,50 @@ object DeriveConfig { defaultValues: Map[String, Any], fieldNames: List[String], descriptors: List[DeriveConfig[Any]] - ): List[DeriveConfig[_]] = { - descriptors.zip(fieldNames).map({ case (desc, fieldName) => + ): List[DeriveConfig[_]] = + descriptors.zip(fieldNames).map { case (desc, fieldName) => defaultValues.get(fieldName) match { case Some(any) => DeriveConfig(desc.desc.withDefault(any), desc.metadata) - case None => desc - }}) - } + case None => desc + } + } def mergeAllFields[T]( allDescs: => List[DeriveConfig[_]], productName: ProductName, fieldNames: => List[FieldName], f: List[Any] => T, - g: T => List[Any], - ): DeriveConfig[T] = - if fieldNames.isEmpty then // if there are no fields in the product then the value is the name of the product itself - val tryAllPaths = - (productName.originalName :: productName.alternativeNames) - .map(n => zio.Config.constant(n)).reduce(_ orElse _) - - DeriveConfig( - tryAllPaths.map[T]( - _ => f(Nil) - ), - Some(Metadata.Object[T](productName, f(Nil))) // We propogate the info that product was actually an object - ) - - else - val listOfDesc = - fieldNames.zip(allDescs).map({ case (fieldName, desc) => { - val fieldDesc = tryAllKeys(desc.desc, Some(fieldName.originalName), fieldName.alternativeNames) - fieldName.descriptions.foldRight(fieldDesc)((doc, desc) => desc ?? doc) - }}) - - val descOfList = - Config.collectAll(listOfDesc.head, listOfDesc.tail: _*) - - DeriveConfig(descOfList.map(f), Some(Metadata.Product(productName, fieldNames))) + g: T => List[Any] + ): DeriveConfig[T] = + if fieldNames.isEmpty then // if there are no fields in the product then the value is the name of the product itself + val tryAllPaths = + (productName.originalName :: productName.alternativeNames) + .map(n => zio.Config.constant(n)) + .reduce(_ orElse _) + + DeriveConfig( + tryAllPaths.map[T](_ => f(Nil)), + Some(Metadata.Object[T](productName, f(Nil))) // We propogate the info that product was actually an object + ) + else + val listOfDesc = + fieldNames.zip(allDescs).map { case (fieldName, desc) => + val fieldDesc = tryAllKeys(desc.desc, Some(fieldName.originalName), fieldName.alternativeNames) + fieldName.descriptions.foldRight(fieldDesc)((doc, desc) => desc ?? doc) + } + + val descOfList = + Config.collectAll(listOfDesc.head, listOfDesc.tail: _*) + + DeriveConfig(descOfList.map(f), Some(Metadata.Product(productName, fieldNames))) def tryAllKeys[A]( desc: Config[A], originalKey: Option[String], - alternativeKeys: List[String], + alternativeKeys: List[String] ): Config[A] = alternativeKeys match { - case Nil => originalKey.fold(desc)(desc.nested(_)) + case Nil => originalKey.fold(desc)(desc.nested(_)) case keys => keys.view.map(desc.nested(_)).reduce(_ orElse _) } diff --git a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/Macros.scala b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/Macros.scala index 78fd53eb3..a176338d8 100644 --- a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/Macros.scala +++ b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/Macros.scala @@ -4,14 +4,16 @@ import scala.quoted.* import zio.config.derivation._ object Macros: - inline def nameOf[T]: List[name] = ${anns[T, name]("zio.config.derivation.name")} - inline def discriminator[T]: List[discriminator] = ${anns[T, discriminator]("zio.config.derivation.discriminator")} - inline def documentationOf[T]: List[describe] = ${anns[T, describe]("zio.config.derivation.describe")} - inline def fieldNameOf[T]: List[(String, List[name])] = ${fieldAnns[T, name]("zio.config.derivation.name")} - inline def fieldDocumentationOf[T]: List[(String, List[describe])] = ${fieldAnns[T, describe]("zio.config.derivation.describe")} - inline def defaultValuesOf[T]: List[(String, Any)] = ${defaultValues[T]} - - def defaultValues[T : Type](using Quotes): Expr[List[(String, Any)]] = + inline def nameOf[T]: List[name] = ${ anns[T, name]("zio.config.derivation.name") } + inline def discriminator[T]: List[discriminator] = ${ anns[T, discriminator]("zio.config.derivation.discriminator") } + inline def documentationOf[T]: List[describe] = ${ anns[T, describe]("zio.config.derivation.describe") } + inline def fieldNameOf[T]: List[(String, List[name])] = ${ fieldAnns[T, name]("zio.config.derivation.name") } + inline def fieldDocumentationOf[T]: List[(String, List[describe])] = ${ + fieldAnns[T, describe]("zio.config.derivation.describe") + } + inline def defaultValuesOf[T]: List[(String, Any)] = ${ defaultValues[T] } + + def defaultValues[T: Type](using Quotes): Expr[List[(String, Any)]] = import quotes.reflect.* val tpe = TypeRepr.of[T] @@ -24,11 +26,12 @@ object Macros: sym.companionClass val defaultRefs = - companionClas.declarations.filter(_.name.startsWith("$lessinit$greater$default")) - .map(Ref(_)) + companionClas.declarations + .filter(_.name.startsWith("$lessinit$greater$default")) + .map(Ref(_)) - Expr.ofList(namesOfFieldsWithDefaultValues.zip(defaultRefs).map { - case (n, ref) => Expr.ofTuple(Expr(n), ref.asExpr) + Expr.ofList(namesOfFieldsWithDefaultValues.zip(defaultRefs).map { case (n, ref) => + Expr.ofTuple(Expr(n), ref.asExpr) }) def anns[T: Type, A: Type](ownerName: String)(using Quotes): Expr[List[A]] = { @@ -37,9 +40,9 @@ object Macros: val tpe = TypeRepr.of[T] Expr.ofList { - tpe.typeSymbol.annotations.filter { a => { - a.tpe.typeSymbol.fullName == ownerName - }}.map(_.asExpr.asInstanceOf[Expr[A]]) + tpe.typeSymbol.annotations.filter { a => + a.tpe.typeSymbol.fullName == ownerName + }.map(_.asExpr.asInstanceOf[Expr[A]]) } } @@ -53,6 +56,6 @@ object Macros: Expr(field.name) -> field.annotations.filter { a => a.tpe.typeSymbol.fullName == ownerName }.map(_.asExpr.asInstanceOf[Expr[A]]) - }.filter(_._2.nonEmpty).map { (name, anns) => Expr.ofTuple(name, Expr.ofList(anns)) } + }.filter(_._2.nonEmpty).map((name, anns) => Expr.ofTuple(name, Expr.ofList(anns))) } end Macros diff --git a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/examples/AutoDerivationSimple.scala b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/examples/AutoDerivationSimple.scala index c876d3ae5..2adb61bd0 100644 --- a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/examples/AutoDerivationSimple.scala +++ b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/examples/AutoDerivationSimple.scala @@ -8,29 +8,29 @@ import zio.Unsafe import zio.IO import zio.config.syntax._ -object AutoDerivationSimple extends App : +object AutoDerivationSimple extends App: // Use of Either is almost prohibited by the looks of it val sourceMap = Map( - "a.b-c" -> "v1", - "a.c-d" -> "C", - "a.d" -> "C,C", + "a.b-c" -> "v1", + "a.c-d" -> "C", + "a.d" -> "C,C", "a.f.g.value" -> "v2", - "a.g" -> "F", + "a.g" -> "F", "a.h.g.value" -> "GValue", - "a.i.p" -> "Q", - "a.j.p.t.u" -> "v3", - "a.z.type" -> "AbcDef", - "a.z.name" -> "hello", - "a.y" -> "HmmAbc" + "a.i.p" -> "Q", + "a.j.p.t.u" -> "v3", + "a.z.type" -> "AbcDef", + "a.z.name" -> "hello", + "a.y" -> "HmmAbc" ) val source = ConfigProvider.fromMap( - sourceMap, - pathDelim = ".", - seqDelim = "," - ) + sourceMap, + pathDelim = ".", + seqDelim = "," + ) val io: IO[String, A] = source.load(deriveConfig[A].toKebabCase).mapError(_.prettyPrint()) @@ -40,5 +40,5 @@ object AutoDerivationSimple extends App : } println(readResult) - // A(B(v1,C(),List(C(), C()),None,G(v2),F,G(GValue),Q,T(v3),Abc(hello))) +// A(B(v1,C(),List(C(), C()),None,G(v2),F,G(GValue),Q,T(v3),Abc(hello))) end AutoDerivationSimple diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index b308b4c79..1534d1ec3 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -1,18 +1,18 @@ -import explicitdeps.ExplicitDepsPlugin.autoImport._ -import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ -import sbt.Keys._ -import sbt._ -import sbtbuildinfo.BuildInfoKeys._ -import sbtbuildinfo._ -import sbtcrossproject.CrossPlugin.autoImport._ -import scalafix.sbt.ScalafixPlugin.autoImport._ +import explicitdeps.ExplicitDepsPlugin.autoImport.* +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport.* +import sbt.* +import sbt.Keys.* +import sbtbuildinfo.* +import sbtbuildinfo.BuildInfoKeys.* +import sbtcrossproject.CrossPlugin.autoImport.* +import scalafix.sbt.ScalafixPlugin.autoImport.* object BuildHelper { private val versions: String => String = { import org.snakeyaml.engine.v2.api.{Load, LoadSettings} - import java.util.{List => JList, Map => JMap} - import scala.jdk.CollectionConverters._ + import java.util.{List as JList, Map as JMap} + import scala.jdk.CollectionConverters.* val doc = new Load(LoadSettings.builder().build()) .loadFromReader(scala.io.Source.fromFile(".github/workflows/ci.yml").bufferedReader()) @@ -205,29 +205,28 @@ object BuildHelper { def stdSettings(prjName: String) = Seq( resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots", - name := s"$prjName", - crossScalaVersions := Seq(Scala212, Scala213), - ThisBuild / scalaVersion := Scala213, - scalacOptions := stdOptions ++ extraOptions(scalaVersion.value, optimize = !isSnapshot.value), + name := s"$prjName", + crossScalaVersions := Seq(Scala212, Scala213), + ThisBuild / scalaVersion := Scala213, + scalacOptions := stdOptions ++ extraOptions(scalaVersion.value, optimize = !isSnapshot.value), libraryDependencies ++= { if (scalaVersion.value == ScalaDotty) Seq.empty else Seq( - compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full) + compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.3" cross CrossVersion.full) ) }, - semanticdbEnabled := scalaVersion.value != ScalaDotty, // enable SemanticDB + semanticdbEnabled := scalaVersion.value != ScalaDotty, // enable SemanticDB semanticdbOptions += "-P:semanticdb:synthetics:on", - semanticdbVersion := scalafixSemanticdb.revision, // use Scalafix compatible version - ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value), + semanticdbVersion := scalafixSemanticdb.revision, // use Scalafix compatible version ThisBuild / scalafixDependencies ++= List( "com.github.liancheng" %% "organize-imports" % "0.6.0", "com.github.vovapolu" %% "scaluzzi" % "0.1.23" ), - Test / parallelExecution := true, + Test / parallelExecution := true, incOptions ~= (_.withLogRecompileOnMacro(false)), - autoAPIMappings := true, + autoAPIMappings := true, unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library") ) diff --git a/project/build.properties b/project/build.properties index 0aa5c39b8..1767a6f85 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.9.8 +sbt.version = 1.10.5 diff --git a/project/plugins.sbt b/project/plugins.sbt index 7550bf7f3..742177624 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,22 +1,23 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.17") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1") -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0") -addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") -addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.3") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.0") +addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0") +addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.7.0") -addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.17.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.5") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.1") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") addSbtPlugin("pl.project13.scala" % "sbt-jcstress" % "0.2.0") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.4") -addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.1") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7") +addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.4.0-alpha.28") +addDependencyTreePlugin -libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "2.6" +libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "2.7" resolvers ++= Resolver.sonatypeOssRepos("public") diff --git a/refined/shared/src/test/scala-2.13/zio/config/refined/NumericTestTypes.scala b/refined/shared/src/test/scala-2.13/zio/config/refined/NumericTestTypes.scala index b16395f4a..73507ea7d 100644 --- a/refined/shared/src/test/scala-2.13/zio/config/refined/NumericTestTypes.scala +++ b/refined/shared/src/test/scala-2.13/zio/config/refined/NumericTestTypes.scala @@ -3,10 +3,10 @@ package zio.config.refined import eu.timepit.refined.numeric.{Divisible, Greater, GreaterEqual, Less, LessEqual, NonDivisible} private[refined] trait NumericTestTypes { - type Less10 = Less[10] - type Greater10 = Greater[10] + type Less10 = Less[10] + type Greater10 = Greater[10] type GreaterOrEqual10 = GreaterEqual[10] - type LessOrEqual10 = LessEqual[10] - type DivisibleBy10 = Divisible[10] + type LessOrEqual10 = LessEqual[10] + type DivisibleBy10 = Divisible[10] type NonDivisibleBy10 = NonDivisible[10] } diff --git a/refined/shared/src/test/scala-3/zio/config/refined/NumericTestTypes.scala b/refined/shared/src/test/scala-3/zio/config/refined/NumericTestTypes.scala index b16395f4a..73507ea7d 100644 --- a/refined/shared/src/test/scala-3/zio/config/refined/NumericTestTypes.scala +++ b/refined/shared/src/test/scala-3/zio/config/refined/NumericTestTypes.scala @@ -3,10 +3,10 @@ package zio.config.refined import eu.timepit.refined.numeric.{Divisible, Greater, GreaterEqual, Less, LessEqual, NonDivisible} private[refined] trait NumericTestTypes { - type Less10 = Less[10] - type Greater10 = Greater[10] + type Less10 = Less[10] + type Greater10 = Greater[10] type GreaterOrEqual10 = GreaterEqual[10] - type LessOrEqual10 = LessEqual[10] - type DivisibleBy10 = Divisible[10] + type LessOrEqual10 = LessEqual[10] + type DivisibleBy10 = Divisible[10] type NonDivisibleBy10 = NonDivisible[10] } diff --git a/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/AnnotationsTest.scala b/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/AnnotationsTest.scala index d7509a051..4500dbf81 100644 --- a/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/AnnotationsTest.scala +++ b/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/AnnotationsTest.scala @@ -3,7 +3,7 @@ package zio.config.magnolia import zio.config.read import zio.config.typesafe.TypesafeConfigProvider import zio.test.Assertion.equalTo -import zio.test.{Spec, ZIOSpecDefault, assertZIO} +import zio.test.{assertZIO, Spec, ZIOSpecDefault} import zio.{Config, IO} object AnnotationsTest extends ZIOSpecDefault { diff --git a/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/CoproductSealedTraitSpec.scala b/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/CoproductSealedTraitSpec.scala index ee82e1a8b..6b9313f1e 100644 --- a/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/CoproductSealedTraitSpec.scala +++ b/typesafe-magnolia-tests/shared/src/test/scala/zio/config/magnolia/CoproductSealedTraitSpec.scala @@ -2,7 +2,7 @@ package zio.config.magnolia import zio.ConfigProvider import zio.config._ -import zio.config.derivation.{ name => derivedName } +import zio.config.derivation.{name => derivedName} import zio.test.Assertion._ import zio.test.{ZIOSpecDefault, _} diff --git a/typesafe-magnolia-tests/shared/src/test/scala/zio/config/typesafe/TypesafeConfigProviderZIOTest.scala b/typesafe-magnolia-tests/shared/src/test/scala/zio/config/typesafe/TypesafeConfigProviderZIOTest.scala index d4416d93c..1be225b42 100644 --- a/typesafe-magnolia-tests/shared/src/test/scala/zio/config/typesafe/TypesafeConfigProviderZIOTest.scala +++ b/typesafe-magnolia-tests/shared/src/test/scala/zio/config/typesafe/TypesafeConfigProviderZIOTest.scala @@ -4,7 +4,7 @@ import zio.Config import zio.config.magnolia.deriveConfig import zio.config.read import zio.test.Assertion.equalTo -import zio.test.{Spec, ZIOSpecDefault, assertZIO} +import zio.test.{assertZIO, Spec, ZIOSpecDefault} object TypesafeConfigProviderZIOTest extends ZIOSpecDefault { diff --git a/yaml/shared/src/test/scala/zio/config/yaml/YamlConfigSpec.scala b/yaml/shared/src/test/scala/zio/config/yaml/YamlConfigSpec.scala index fb2ddfaaa..b32cf92c1 100644 --- a/yaml/shared/src/test/scala/zio/config/yaml/YamlConfigSpec.scala +++ b/yaml/shared/src/test/scala/zio/config/yaml/YamlConfigSpec.scala @@ -61,8 +61,8 @@ object YamlConfigSpec extends ZIOSpecDefault { val configDataBaseConfig: Config[DataBaseConfig] = Config.string("url").to[DataBaseConfig] val yamlConfig: String = s"""url: "some_url"""" - val result = read(configDataBaseConfig from ConfigProvider.fromYamlStringZIO(yamlConfig)) - val expected = DataBaseConfig("some_url") + val result = read(configDataBaseConfig from ConfigProvider.fromYamlStringZIO(yamlConfig)) + val expected = DataBaseConfig("some_url") assertZIO(result)(equalTo(expected)) } ) From 3238fdb84c4f8544ca645a3f97c867fe2ce4b32e Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Tue, 5 Nov 2024 13:12:38 +0530 Subject: [PATCH 2/4] Define versionScheme --- build.sbt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index fabc2d8b9..4495c314b 100644 --- a/build.sbt +++ b/build.sbt @@ -6,10 +6,10 @@ 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", @@ -22,7 +22,8 @@ inThisBuild( "john@degoes.net", url("http://degoes.net") ) - ) + ), + versionScheme := Some("early-semver") ) ) From 14a9b0a279d82d696152f0eac5145603ac398155 Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Tue, 5 Nov 2024 13:18:44 +0530 Subject: [PATCH 3/4] Remove workflow check --- .github/workflows/ci.yml | 6 ------ .github/workflows/site.yml | 2 -- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4013039ba..623669c8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,12 +29,6 @@ jobs: 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 diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 69831efac..769f3fc09 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -27,8 +27,6 @@ jobs: 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: From 9afb89d2b1475267c39645de1b1dd5163d248cb6 Mon Sep 17 00:00:00 2001 From: Kyri Petrou Date: Tue, 5 Nov 2024 13:29:39 +0530 Subject: [PATCH 4/4] Use setup-java for SBT --- .github/workflows/ci.yml | 32 +++++++++++++++++++++----------- .github/workflows/site.yml | 6 +++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 623669c8c..81f936ee7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,12 @@ 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 @@ -34,10 +38,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: - java-version: 'adopt@1.11' + distribution: temurin + java-version: 11 + check-latest: true - name: Cache scala dependencies uses: coursier/cache-action@v6 - name: Check formatting @@ -51,7 +57,7 @@ jobs: strategy: fail-fast: false matrix: - java: ['adopt@1.11', 'adopt@1.21'] + java: ['11', '21'] scala: ['2.12.20', '2.13.15', '3.3.4'] platform: ['JS', 'JVM', 'Native'] steps: @@ -59,10 +65,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: ${{ matrix.java }} + check-latest: true - name: Cache scala dependencies uses: coursier/cache-action@v6 - name: Run JS tests @@ -95,10 +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: - java-version: 'adopt@1.11' + distribution: temurin + java-version: 11 + check-latest: true - name: Cache scala dependencies uses: coursier/cache-action@v6 - name: Release artifacts diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 769f3fc09..4af492966 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -22,7 +22,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 @@ -39,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 @@ -64,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