Skip to content

Commit

Permalink
project reorganization + testkit
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiaggio committed Nov 16, 2023
1 parent 1ceb657 commit c86918e
Show file tree
Hide file tree
Showing 43 changed files with 113 additions and 74 deletions.
24 changes: 24 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,27 @@ pull_request_rules:
- status-success=Build and Test (ubuntu-latest, 3, temurin@17, rootJVM)
actions:
merge: {}
- name: Label core PRs
conditions:
- files~=^modules/core/
actions:
label:
add:
- core
remove: []
- name: Label testkit PRs
conditions:
- files~=^modules/testkit/
actions:
label:
add:
- testkit
remove: []
- name: Label tests PRs
conditions:
- files~=^modules/tests/
actions:
label:
add:
- tests
remove: []
48 changes: 32 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
Global / onChangedBuildSource := ReloadOnSourceChanges

ThisBuild / crossScalaVersions := List("3.3.1")
ThisBuild / tlBaseVersion := "0.35"
ThisBuild / tlBaseVersion := "0.36"

ThisBuild / tlCiReleaseBranches := Seq("master")

lazy val root = tlCrossRootProject.aggregate(crystal)
lazy val root = tlCrossRootProject.aggregate(core, testkit, tests)

lazy val crystal = crossProject(JVMPlatform, JSPlatform)
.in(file("."))
lazy val core = crossProject(JVMPlatform, JSPlatform)
.in(file("modules/core"))
.settings(
name := "crystal",
scalacOptions += "-language:implicitConversions",
libraryDependencies ++=
Settings.Libraries.CatsJS.value ++
Settings.Libraries.CatsEffectJS.value ++
Settings.Libraries.Fs2JS.value ++
Settings.Libraries.Monocle.value ++
Settings.Libraries.Log4Cats.value ++
(
Settings.Libraries.MUnit.value ++
Settings.Libraries.Discipline.value ++
Settings.Libraries.DisciplineMUnit.value ++
Settings.Libraries.CatsLaws.value ++
Settings.Libraries.MonocleMacro.value ++
Settings.Libraries.MonocleLaw.value
).map(_ % Test)
Settings.Libraries.Log4Cats.value
)
.jsSettings(
libraryDependencies ++= {
Settings.Libraries.ScalaJSReact.value ++ (if (scalaBinaryVersion.value == "3")
Settings.Libraries.LucumaReact.value
else Settings.Libraries.ReactCommon.value)
Settings.Libraries.ScalaJSReact.value ++
Settings.Libraries.LucumaReact.value
}
)

lazy val testkit = crossProject(JVMPlatform, JSPlatform)
.in(file("modules/testkit"))
.settings(
name := "crystal-testkit",
libraryDependencies ++=
Settings.Libraries.ScalaCheck.value
)
.dependsOn(core)

lazy val tests = crossProject(JVMPlatform, JSPlatform)
.in(file("modules/tests"))
.enablePlugins(NoPublishPlugin)
.settings(
name := "crystal-tests",
libraryDependencies ++=
(Settings.Libraries.MUnit.value ++
Settings.Libraries.Discipline.value ++
Settings.Libraries.DisciplineMUnit.value ++
Settings.Libraries.CatsLaws.value ++
Settings.Libraries.MonocleMacro.value ++
Settings.Libraries.MonocleLaw.value).map(_ % Test)
)
.dependsOn(testkit)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait EqInstances {
private[this] def arbitraryValues[A](using A: Arbitrary[A]): LazyList[A] =
LazyList.continually(A.arbitrary.sample).flatten

given viewEq[A: Eq: Arbitrary: Cogen]: Eq[ViewF[Id, A]] = Eq.instance { (v1, v2) =>
given [A: Eq: Arbitrary: Cogen]: Eq[ViewF[Id, A]] = Eq.instance { (v1, v2) =>
Eq[A].eqv(v1.get, v2.get) && arbitraryValues[(A => A)].take(functionEqualityCheckCount).forall {
f =>
var newA1: A | Null = null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA)
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause

package crystal.arb

import cats.Id
import crystal.Pot
import crystal.PotOption
import crystal.ViewF
import org.scalacheck.*

import scala.annotation.targetName

import Arbitrary.*
import Gen.*

given [A: Arbitrary]: Arbitrary[Pot[A]] =
Arbitrary(
oneOf(
Gen.const(Pot.Pending),
arbitrary[Throwable].map(Pot.Error.apply),
arbitrary[A].map(Pot.Ready.apply)
)
)

given [A](using Arbitrary[A => A]): Arbitrary[Pot[A] => Pot[A]] =
Arbitrary(arbitrary[A => A].map(f => _.map(f)))

given [A: Arbitrary]: Arbitrary[PotOption[A]] =
Arbitrary(
oneOf(
Gen.const(PotOption.Pending),
arbitrary[Throwable].map(PotOption.Error.apply),
Gen.const(PotOption.ReadyNone),
arbitrary[A].map(PotOption.ReadySome.apply)
)
)

given viewFArb[A: Arbitrary]: Arbitrary[ViewF[Id, A]] = Arbitrary(
arbitrary[A].map(a => ViewF.apply[Id, A](a, (f, cb) => cb(f(a))))
)

@targetName("potOptionFnArbitrary")
given [A](using fArb: Arbitrary[A => A]): Arbitrary[PotOption[A] => PotOption[A]] =
Arbitrary(arbitrary[A => A].map(f => _.map(f)))
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import japgolly.scalajs.react.Reusability
import munit.ScalaCheckSuite
import org.scalacheck.Prop.*

import scala.language.implicitConversions

final class ReuseSpec extends ScalaCheckSuite {

test("Reuse(function).by(value) syntax") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.laws.discipline.*
import cats.laws.discipline.arbitrary.*
import cats.syntax.all.*
import crystal.arb.given
import crystal.throwable.given
import monocle.law.discipline.PrismTests
import munit.DisciplineSuite
Expand All @@ -18,8 +19,6 @@ import scala.util.Failure
import scala.util.Success
import scala.util.Try

import arbitraries.given

class PotOptionSpec extends DisciplineSuite {
given Isomorphisms[PotOption] = Isomorphisms.invariant[PotOption]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import cats.laws.discipline.SemigroupalTests.Isomorphisms
import cats.laws.discipline.*
import cats.laws.discipline.arbitrary.*
import cats.syntax.all.*
import crystal.arb.given
import crystal.throwable.given
import monocle.law.discipline.PrismTests
import munit.DisciplineSuite
Expand All @@ -18,8 +19,6 @@ import scala.util.Failure
import scala.util.Success
import scala.util.Try

import arbitraries.given

class PotSpec extends DisciplineSuite {
given Isomorphisms[Pot] = Isomorphisms.invariant[Pot]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import cats.Eq
import cats.Id
import cats.Invariant
import cats.laws.discipline.InvariantSemigroupalTests
import crystal.arb.given
import munit.DisciplineSuite

import arbitraries.given

class ViewFLawsSpec extends DisciplineSuite with EqInstances {

checkAll(
Expand Down
File renamed without changes.
13 changes: 6 additions & 7 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ object Settings {
val disciplineMUnit = "1.0.9"
val fs2 = "3.9.3"
val log4Cats = "2.6.0"
val lucumaReact = "0.47.0"
val monocle = "3.2.0"
val mUnit = "0.7.29"
val mUnitCatsEffect = "1.0.7"
val reactCommon = "0.24.0"
val lucumaReact = "0.47.0"
val scalaCheck = "1.17.0"
val scalajsReact = "2.1.1"
}

Expand Down Expand Up @@ -90,16 +90,15 @@ object Settings {
)
)

val ReactCommon = Def.setting(
val LucumaReact = Def.setting(
Seq[ModuleID](
"io.github.cquiroz.react" %%% "common" % reactCommon,
"io.github.cquiroz.react" %%% "cats" % reactCommon
"edu.gemini" %%% "lucuma-react-common" % lucumaReact
)
)

val LucumaReact = Def.setting(
val ScalaCheck = Def.setting(
Seq[ModuleID](
"edu.gemini" %%% "lucuma-react-common" % lucumaReact
"org.scalacheck" %%% "scalacheck" % scalaCheck
)
)

Expand Down
44 changes: 0 additions & 44 deletions shared/src/test/scala/crystal/arbitraries.scala

This file was deleted.

0 comments on commit c86918e

Please sign in to comment.