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

Removed silencer SBT plugin #1171

Merged
merged 6 commits into from
Apr 28, 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
15 changes: 10 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import BuildHelper._

welcomeMessage

inThisBuild(
List(
organization := "dev.zio",
Expand All @@ -24,13 +26,12 @@ inThisBuild(

addCommandAlias("fmt", "; scalafmtSbt; scalafmt; test:scalafmt")
addCommandAlias("fix", "; all compile:scalafix test:scalafix; all scalafmtSbt scalafmtAll")
addCommandAlias("compileAll", "; ++2.12.18; root2-12/compile; ++2.13.12!; root2-13/compile")
addCommandAlias("testAll", "; ++2.12.18; root2-12/test; ++2.13.12!; root2-13/test")
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(
"testJS",
";zioConfigJS/test"
)

addCommandAlias(
"testJVM212",
";zioConfigJVM/test;zioConfigTypesafeJVM/test;zioConfigDerivationJVM/test;zioConfigYamlJVM/test;examplesJVM/test;zioConfigAwsJVM/test;zioConfigZioAwsJVM/test;zioConfigXmlJVM/test"
Expand All @@ -43,6 +44,10 @@ addCommandAlias(
"testJVM3x",
";zioConfigJVM/test;zioConfigTypesafeJVM/test;zioConfigDerivationJVM/test;zioConfigYamlJVM/test;zioConfigMagnoliaJVM/test;zioConfigAwsJVM/test;zioConfigZioAwsJVM/test;zioConfigXmlJVM/test"
)
addCommandAlias(
"testJVM",
";testJVM212;testJVM213;testJVM3x;"
)

val awsVersion = "1.12.709"
val zioAwsVersion = "5.19.33.2"
Expand Down Expand Up @@ -370,7 +375,7 @@ lazy val zioConfigCats = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(crossProjectSettings)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.8.0",
"org.typelevel" %% "cats-core" % "2.9.0",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
Expand All @@ -387,7 +392,7 @@ lazy val zioConfigEnumeratum = crossProject(JSPlatform, JVMPlatform, NativePlatf
.settings(crossProjectSettings)
.settings(
libraryDependencies ++= Seq(
"com.beachape" %% "enumeratum" % "1.7.0",
"com.beachape" %% "enumeratum" % "1.7.2",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ object Prod {

object ReadConfig extends ZIOAppDefault {

val configProvider: ConfigProvider =
private val configProvider: ConfigProvider =
ConfigProvider.fromMap(Map("LDAP" -> "ldap", "PORT" -> "1999", "DB_URL" -> "ddd"))

def run: URIO[Any, ExitCode] =
read(Prod.prodConfig from ConfigProvider.fromMap(Map("LDAP" -> "ldap", "PORT" -> "1999", "DB_URL" -> "ddd")))
read(Prod.prodConfig from configProvider)
.foldZIO[Any, Throwable, Any](
failure => Console.printLine(failure.toString),
value => Console.printLine(value.toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import zio.config.examples.typesafe.EitherImpureOps
import zio.config.magnolia.deriveConfig
import zio.config.typesafe.TypesafeConfigProvider
import zio.{Config, IO}

import examples._

object AutoDerivationCustomKeys extends App with EitherImpureOps {
Expand Down
14 changes: 6 additions & 8 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ object BuildHelper {
)
case Some((2, 13)) =>
Seq(
"-Ywarn-unused:params,-implicits"
"-Wunused:params,-implicits,-nowarn"
) ++ std2xOptions ++ optimizerOptions(optimize)
case Some((2, 12)) =>
Seq(
Expand Down Expand Up @@ -214,16 +214,16 @@ object BuildHelper {
Seq.empty
else
Seq(
compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full)
compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full)
)
},
semanticdbEnabled := scalaVersion.value != ScalaDotty, // enable SemanticDB
semanticdbOptions += "-P:semanticdb:synthetics:on",
semanticdbVersion := scalafixSemanticdb.revision, // use Scalafix compatible version
ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value),
ThisBuild / scalafixDependencies ++= List(
"com.github.liancheng" %% "organize-imports" % "0.5.0",
"com.github.vovapolu" %% "scaluzzi" % "0.1.18"
"com.github.liancheng" %% "organize-imports" % "0.6.0",
"com.github.vovapolu" %% "scaluzzi" % "0.1.23"
),
Test / parallelExecution := true,
incOptions ~= (_.withLogRecompileOnMacro(false)),
Expand Down Expand Up @@ -294,15 +294,13 @@ object BuildHelper {
|${header(s"/____|___\\___/ ${version.value}")}
|
|Useful sbt tasks:
|${item("build")} - Prepares sources, compiles and runs tests.
|${item("prepare")} - Prepares sources by applying both scalafix and scalafmt
|${item("compileAll")} - Prepares sources & compiles.
|${item("testAll")} - Prepares sources & runs all tests.
|${item("fix")} - Fixes sources files using scalafix
|${item("fmt")} - Formats source files using scalafmt
|${item("~compileJVM")} - Compiles all JVM modules (file-watch enabled)
|${item("testJVM")} - Runs all JVM tests
|${item("testJS")} - Runs all ScalaJS tests
|${item("testOnly *.YourSpec -- -t \"YourLabel\"")} - Only runs tests with matching term e.g.
|${subItem("coreTestsJVM/testOnly *.ZIOSpec -- -t \"happy-path\"")}
|${item("docs/docusaurusCreateSite")} - Generates the ZIO microsite
""".stripMargin
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package zio.config.refined

import eu.timepit.refined.W
import eu.timepit.refined.numeric.{Divisible, Greater, GreaterEqual, Less, LessEqual, NonDivisible}

private[refined] trait NumericTestTypes {
type Less10 = Less[W.`10`.T]
type Greater10 = Greater[W.`10`.T]
type GreaterOrEqual10 = GreaterEqual[W.`10`.T]
type LessOrEqual10 = LessEqual[W.`10`.T]
type DivisibleBy10 = Divisible[W.`10`.T]
type NonDivisibleBy10 = NonDivisible[W.`10`.T]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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 GreaterOrEqual10 = GreaterEqual[10]
type LessOrEqual10 = LessEqual[10]
type DivisibleBy10 = Divisible[10]
type NonDivisibleBy10 = NonDivisible[10]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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 GreaterOrEqual10 = GreaterEqual[10]
type LessOrEqual10 = LessEqual[10]
type DivisibleBy10 = Divisible[10]
type NonDivisibleBy10 = NonDivisible[10]
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
package zio.config.refined

import eu.timepit.refined.W
import eu.timepit.refined.api.Refined
import eu.timepit.refined.numeric.{Divisible, Greater, GreaterEqual, Less, LessEqual, NonDivisible}
import zio.config._
import zio.test.Assertion._
import zio.test._
import zio.{Config, ConfigProvider, Scope, ZIO}

object NumericSupportTest extends ZIOSpecDefault {
object NumericSupportTest extends ZIOSpecDefault with RequiredNumericTypes with NumericTestTypes {

override val spec: Spec[Environment with TestEnvironment with Scope, Any] =
suite("Refined Numeric support")(
test("Refined config Less invalid") {
check(Gen.int(10, 100)) { p =>
val cfg = refine[Int, Less[W.`10`.T]]("TEST")
val p2: ZIO[Any, Config.Error, Refined[Int, Less[W.`10`.T]]] =
val cfg = refine[Int, Less10]("TEST")
val p2: ZIO[Any, Config.Error, Refined[Int, Less10]] =
read(cfg from ConfigProvider.fromMap(Map("TEST" -> p.toString), "test"))

assertZIO(p2.either)(isLeft)
}
},
test("Refined config Greater invalid") {
check(Gen.int(1, 10)) { p =>
val cfg = refine[Int, Greater[W.`10`.T]]("TEST")
val p2: ZIO[Any, Config.Error, Refined[Int, Greater[W.`10`.T]]] =
val cfg = refine[Int, Greater10]("TEST")
val p2: ZIO[Any, Config.Error, Refined[Int, Greater10]] =
read(cfg from ConfigProvider.fromMap(Map("TEST" -> p.toString)))

assertZIO(p2.either)(isLeft)
}
},
test("Refined config LessEqual invalid") {
check(Gen.int(11, 100)) { p =>
val cfg = refine[Int, LessEqual[W.`10`.T]]("TEST")
val p2: ZIO[Any, Config.Error, Refined[Int, LessEqual[W.`10`.T]]] =
val cfg = refine[Int, LessOrEqual10]("TEST")
val p2: ZIO[Any, Config.Error, Refined[Int, LessOrEqual10]] =
read(cfg from ConfigProvider.fromMap(Map("TEST" -> p.toString), "test"))

assertZIO(p2.either)(isLeft)
}
},
test("Refined config GreaterEqual invalid") {
check(Gen.int(1, 9)) { p =>
val cfg = refine[Int, GreaterEqual[W.`10`.T]]("TEST")
val cfg = refine[Int, GreaterOrEqual10]("TEST")
val p2 =
read(cfg from ConfigProvider.fromMap(Map("TEST" -> p.toString)))

Expand All @@ -50,7 +48,7 @@ object NumericSupportTest extends ZIOSpecDefault {
},
test("Refined config Divisible invalid") {
check(Gen.int(1, 10).map(_ * 10 + 1)) { p =>
val cfg = refine[Int, Divisible[W.`10`.T]]("TEST")
val cfg = refine[Int, DivisibleBy10]("TEST")
val p2 =
read(cfg from ConfigProvider.fromMap(Map("TEST" -> p.toString), "test"))

Expand All @@ -59,7 +57,7 @@ object NumericSupportTest extends ZIOSpecDefault {
},
test("Refined config NonDivisible invalid") {
check(Gen.int(1, 10).map(_ * 10)) { p =>
val cfg = refine[Int, NonDivisible[W.`10`.T]]("TEST")
val cfg = refine[Int, NonDivisibleBy10]("TEST")
val p2 =
read(cfg from ConfigProvider.fromMap(Map("TEST" -> p.toString), "test"))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package zio.config.refined

private[refined] trait RequiredNumericTypes { this: NumericTestTypes =>
type Less10
type Greater10
type GreaterOrEqual10
type LessOrEqual10
type DivisibleBy10
type NonDivisibleBy10
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package zio.config.magnolia

import zio.ConfigProvider
import zio.config._
import zio.config.derivation.{ name => derivedName }
import zio.test.Assertion._
import zio.test.{ZIOSpecDefault, _}

Expand All @@ -11,7 +12,7 @@ object CoproductSealedTraitSpec extends ZIOSpecDefault {

case object A extends X
case object B extends X
@name("c")
@derivedName("c")
case object C extends X
case class D(detail: Detail) extends X
case class E(detail: Detail) extends X
Expand Down
Loading