From 8da4d62824cd4b8248cf1f5e7b1300bb95420e48 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 10:04:04 -1000 Subject: [PATCH 01/17] Try to update to sbt-typelevel --- .github/workflows/ci.yml | 221 ++++++++++++++---- .scalafmt.conf | 4 +- build.sbt | 212 ++--------------- .../scala/org/typelevel/paiges/Chunk.scala | 4 +- project/plugins.sbt | 15 +- 5 files changed, 202 insertions(+), 254 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11381aca..63272558 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,14 @@ on: branches: ['**'] push: branches: ['**'] + tags: [v*] env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: @@ -23,11 +29,8 @@ jobs: matrix: os: [ubuntu-latest] scala: [2.13.8, 2.12.15, 3.1.0] - java: [adopt@1.11] - platform: [jvm, js, native] - exclude: - - platform: native - scala: 3.1.0 + java: [temurin@8] + project: [rootJS, rootJVM, rootNative] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -35,10 +38,21 @@ jobs: with: fetch-depth: 0 - - name: Setup Java and Scala - uses: olafurpg/setup-scala@v13 + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 with: - java-version: ${{ matrix.java }} + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} - name: Cache sbt uses: actions/cache@v2 @@ -53,49 +67,55 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Check that workflows are up to date - run: sbt ++${{ matrix.scala }} githubWorkflowCheck + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'project /' githubWorkflowCheck - - name: Validate JavaScript - if: matrix.platform == 'js' - run: sbt ++${{ matrix.scala }} js/checkCI + - name: Check headers and formatting + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck - - name: Validate Native - if: matrix.platform == 'native' - run: sbt ++${{ matrix.scala }} native/checkCI + - name: scalaJSLink + if: matrix.project == 'rootJS' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult - - name: Validate JVM - if: matrix.platform == 'jvm' && matrix.scala != '2.12.15' - run: sbt ++${{ matrix.scala }} jvm/checkCI + - name: nativeLink + if: matrix.project == 'rootNative' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink - - name: Setup Python - if: matrix.platform == 'jvm' && matrix.scala == '2.12.15' - uses: actions/setup-python@v2 - with: - python-version: 3.x + - name: Test + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test - - name: Setup codecov - if: matrix.platform == 'jvm' && matrix.scala == '2.12.15' - run: pip install codecov + - name: Check binary compatibility + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues - - name: Validate JVM (scala 2) - if: matrix.platform == 'jvm' && matrix.scala == '2.12.15' - run: sbt ++${{ matrix.scala }} coverage jvm/checkCI docs/mdoc coverageReport + - name: Generate API documentation + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc - - name: Upload Codecov Results - if: matrix.platform == 'jvm' && matrix.scala == '2.12.15' - run: codecov + - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: mkdir -p target cats/native/target .js/target core/.native/target docs/target core/.js/target core/.jvm/target .jvm/target .native/target cats/js/target cats/jvm/target benchmark/target project/target - - name: Binary compatibility ${{ matrix.scala }} - if: matrix.platform == 'jvm' && matrix.scala == '2.12.15' - run: sbt ++${{ matrix.scala }} mimaReportBinaryIssues + - name: Compress target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: tar cf targets.tar target cats/native/target .js/target core/.native/target docs/target core/.js/target core/.jvm/target .jvm/target .native/target cats/js/target cats/jvm/target benchmark/target project/target + + - name: Upload target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + uses: actions/upload-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} + path: targets.tar - checks: - name: Format Scala code + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') strategy: matrix: os: [ubuntu-latest] - scala: [2.13.8, 2.12.15, 3.1.0] - java: [adopt@1.8] + scala: [2.13.8] + java: [temurin@8] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -103,10 +123,21 @@ jobs: with: fetch-depth: 0 - - name: Setup Java and Scala - uses: olafurpg/setup-scala@v13 + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 with: - java-version: ${{ matrix.java }} + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} - name: Cache sbt uses: actions/cache@v2 @@ -120,8 +151,106 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - if: matrix.platform == 'jvm' && matrix.scala == '2.12.15' - run: sbt ++${{ matrix.scala }} scalafmtCheckAll + - name: Download target directories (2.13.8, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS + + - name: Inflate target directories (2.13.8, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM + + - name: Inflate target directories (2.13.8, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative + + - name: Inflate target directories (2.13.8, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS + + - name: Inflate target directories (2.12.15, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM + + - name: Inflate target directories (2.12.15, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootNative + + - name: Inflate target directories (2.12.15, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.1.0, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.0-rootJS + + - name: Inflate target directories (3.1.0, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.1.0, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.0-rootJVM + + - name: Inflate target directories (3.1.0, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.1.0, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.0-rootNative + + - name: Inflate target directories (3.1.0, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' + run: echo $PGP_SECRET | base64 -di | gpg --import + + - name: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' + run: | + echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg + echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg + (echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1) - - if: matrix.platform == 'jvm' && matrix.scala == '2.12.15' - run: sbt ++${{ matrix.scala }} scalafmtSbtCheck + - name: Publish + run: sbt '++${{ matrix.scala }}' tlRelease diff --git a/.scalafmt.conf b/.scalafmt.conf index 2a94dc26..b4cb4fb0 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -6,4 +6,6 @@ continuationIndent.defnSite = 2 assumeStandardLibraryStripMargin = true danglingParentheses.preset = true rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, SortModifiers] -docstrings = JavaDoc +docstrings.style = Asterisk +docstrings.wrap = no +runner.dialect = scala213 diff --git a/build.sbt b/build.sbt index 0e49b781..62905764 100644 --- a/build.sbt +++ b/build.sbt @@ -1,72 +1,20 @@ -import sbtcrossproject.{crossProject, CrossType} - val Scala212 = "2.12.15" val Scala213 = "2.13.8" -ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, "3.1.0") -ThisBuild / scalaVersion := Scala213 - -ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.11") - -ThisBuild / githubWorkflowBuildMatrixAdditions += "platform" -> List("jvm", "js", "native") +ThisBuild / tlBaseVersion := "0.4" -ThisBuild / githubWorkflowBuildMatrixExclusions ++= - (ThisBuild / crossScalaVersions).value.filter(_.startsWith("3.")).map { dottyVersion => - MatrixExclude(Map("platform" -> "native", "scala" -> dottyVersion)) - } - -val JvmCond = s"matrix.platform == 'jvm'" -val JsCond = s"matrix.platform == 'js'" -val NativeCond = s"matrix.platform == 'native'" - -val Scala212Cond = s"matrix.scala == '$Scala212'" +ThisBuild / scalaVersion := Scala213 +ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, "3.1.0") -ThisBuild / githubWorkflowBuild := Seq( - WorkflowStep.Sbt(List("js/checkCI"), name = Some("Validate JavaScript"), cond = Some(JsCond)), - WorkflowStep.Sbt(List("native/checkCI"), name = Some("Validate Native"), cond = Some(NativeCond)), - WorkflowStep.Sbt(List("jvm/checkCI"), - name = Some("Validate JVM"), - cond = Some(JvmCond + " && " + s"matrix.scala != '$Scala212'") - ), - WorkflowStep.Use(UseRef.Public("actions", "setup-python", "v2"), - name = Some("Setup Python"), - params = Map("python-version" -> "3.x"), - cond = Some(JvmCond + " && " + Scala212Cond) - ), - WorkflowStep.Run(List("pip install codecov"), - name = Some("Setup codecov"), - cond = Some(JvmCond + " && " + Scala212Cond) - ), - WorkflowStep.Sbt(List("coverage", "jvm/checkCI", "docs/mdoc", "coverageReport"), - name = Some("Validate JVM (scala 2)"), - cond = Some(JvmCond + " && " + Scala212Cond) - ), - WorkflowStep.Run(List("codecov"), - name = Some("Upload Codecov Results"), - cond = Some(JvmCond + " && " + Scala212Cond) - ), - WorkflowStep.Sbt(List("mimaReportBinaryIssues"), - name = Some("Binary compatibility ${{ matrix.scala }}"), - cond = Some(JvmCond + " && " + Scala212Cond) - ) -) +lazy val root = tlCrossRootProject.aggregate(core, cats) -ThisBuild / githubWorkflowAddedJobs ++= Seq( - WorkflowJob( - "checks", - "Format Scala code", - githubWorkflowJobSetup.value.toList ::: List( - WorkflowStep.Sbt(List("scalafmtCheckAll"), cond = Some(JvmCond + " && " + Scala212Cond)), - WorkflowStep.Sbt(List("scalafmtSbtCheck"), cond = Some(JvmCond + " && " + Scala212Cond)) - ), - scalas = crossScalaVersions.value.toList - ) +ThisBuild / developers := List( + // your GitHub handle and name + tlGitHubDev("johnynek", "Oscar Boykin"), + tlGitHubDev("coltfred", "Colt Frederickson"), + tlGitHubDev("non", "Erik Osheim") ) -ThisBuild / githubWorkflowArtifactUpload := false - -ThisBuild / githubWorkflowPublish := Seq() -ThisBuild / githubWorkflowPublishTargetBranches := Seq() def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scalaVersion: String) = { def extraDirs(suffix: String) = @@ -83,57 +31,7 @@ def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scala } } -inThisBuild( - List( - organization := "org.typelevel", - scalaVersion := Scala213, - licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), - homepage := Some(url("https://github.com/typelevel/paiges")), - pomExtra := ( - - - johnynek - Oscar Boykin - http://github.com/johnynek/ - - - coltfred - Colt Frederickson - http://github.com/coltfred/ - - - non - Erik Osheim - http://github.com/non/ - - - - https://github.com/typelevel/paiges - scm:git:git://github.com/typelevel/paiges.git - - ), - coverageMinimum := 60, - coverageFailOnMinimum := false - ) -) - -noPublish - -// Aggregate for JVM projects, for example run `jvm/test` to run only JVM tests. -lazy val jvm = project - .in(file(".jvm")) - .settings(noPublish) - .aggregate(coreJVM, catsJVM) - -lazy val js = project - .in(file(".js")) - .settings(noPublish) - .aggregate(coreJS, catsJS) - -lazy val native = project - .in(file(".native")) - .settings(noPublish) - .aggregate(coreNative, catsNative) +//noPublish lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) .crossType(CrossType.Pure) @@ -142,10 +40,6 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) commonSettings, name := "paiges-core", moduleName := "paiges-core", - mimaPreviousArtifacts := { - if (scalaVersion.value.startsWith("3")) Set.empty - else previousArtifact(version.value, "core") - }, libraryDependencies ++= Seq( "org.scalatestplus" %%% "scalacheck-1-15" % "3.2.10.0" % Test, "org.scalatest" %%% "scalatest-funsuite" % "3.2.11" % Test @@ -173,10 +67,6 @@ lazy val cats = crossProject(JSPlatform, JVMPlatform, NativePlatform) "org.typelevel" %%% "cats-laws" % "2.7.0" % Test, "org.typelevel" %%% "discipline-scalatest" % "2.1.5" % Test ), - mimaPreviousArtifacts := { - if (scalaVersion.value.startsWith("3")) Set.empty - else previousArtifact(version.value, "cats") - } ) .disablePlugins(JmhPlugin) .jsSettings(commonJsSettings) @@ -205,51 +95,10 @@ lazy val docs = project noPublish, crossScalaVersions := List(Scala212), name := "paiges-docs", - mdocIn := baseDirectory.in(LocalRootProject).value / "docs" / "src" / "main" / "mdoc", - scalacOptions in mdoc := { - val testOptions = scalacOptions.in(test).value - val unwantedOptions = Set("-Xlint", "-Xfatal-warnings") - testOptions.filterNot(unwantedOptions) - } + mdocIn := (LocalRootProject / baseDirectory).value / "docs" / "src" / "main" / "mdoc" ) lazy val commonSettings = Seq( - publishTo := { - if ((ThisBuild / isVersionStable).value) - Some("Releases".at("https://oss.sonatype.org/service/local/staging/deploy/maven2")) - else - None - }, - // The validation steps that we run in CI. - TaskKey[Unit]("checkCI") := Def - .sequential( - test.in(Test), - doc.in(Compile), - mimaReportBinaryIssues - ) - .value, - // scalac options are defined in commonSettings instead of inThisBuild - // because we customize the settings based on scalaVersion. - scalacOptions ++= Seq( - "-deprecation", - "-encoding", - "UTF-8", - "-feature", - "-language:existentials", - "-language:higherKinds", - "-language:implicitConversions", - "-language:experimental.macros", - "-unchecked", - "-Xlint", - "-Ywarn-dead-code", - "-Ywarn-numeric-widen", - "-Ywarn-value-discard" - ), - // HACK: without these lines, the console is basically unusable, - // since all imports are reported as being unused (and then become - // fatal errors). - scalacOptions in (Compile, console) ~= { _.filterNot("-Xlint" == _) }, - scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value, scalacOptions ++= ( CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, n)) if n <= 12 => @@ -267,52 +116,25 @@ lazy val commonSettings = Seq( ) lazy val commonJvmSettings = Seq( - testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF") + Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oDF") ) lazy val commonJsSettings = Seq( - scalaJSStage in Global := FastOptStage, + Global / scalaJSStage := FastOptStage, parallelExecution := false, jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), coverageEnabled := false ) lazy val commonNativeSettings = Seq( - crossScalaVersions := crossScalaVersions.value.filter(_.startsWith("2.")), + crossScalaVersions := (ThisBuild / crossScalaVersions).value.filter(_.startsWith("2.")), + // Remove when native is published for the default previous versions + tlVersionIntroduced := List("2.12", "2.13").map(_ -> "0.4.1").toMap, coverageEnabled := false ) -def previousArtifact(version: String, proj: String) = { - def mod(x: Int, y: Int, z: Int): ModuleID = - "org.typelevel" %% s"paiges-$proj" % s"$x.$y.$z" - - // the "-dbuild..." part is for Scala community build friendliness - val regex = "([0-9]+)\\.([0-9]+)\\.([0-9]+)(-SNAPSHOT|-dbuild[a-z0-9]*|\\+.*)?".r - version match { - case regex(smajor, sminor, spatch, suffix) => - val (major, minor, patch) = (smajor.toInt, sminor.toInt, spatch.toInt) - - // unless we're in a 0.x release, we need to ensure that our - // minor version is compatible with previous minor versions. - // - // for example, 4.1.1 should be compatible with 4.1.0 and also - // with 4.0.0. - // - // ideally we'd want to ensure that 4.1.1 was compatible with - // the latest 4.0.x release (e.g. 4.0.13) but that would require - // parsing our full release history; currently the algorithm is - // only based on the current version. - val minors = if (major > 0) (0 until minor).toSet else Set.empty - val patches = (0 until patch).toSet - val current = if (suffix != null && suffix.startsWith("+")) Set(mod(major, minor, patch)) else Set.empty[ModuleID] - minors.map(mod(major, _, 0)) | patches.map(mod(major, minor, _)) | current - case _ => - throw new RuntimeException(s"Could not parse Paiges version: $version") - } -} - lazy val noPublish = commonSettings ++ Seq( - skip in publish := true, + publish / skip := true, mimaPreviousArtifacts := Set.empty, coverageEnabled := false ) diff --git a/core/src/main/scala/org/typelevel/paiges/Chunk.scala b/core/src/main/scala/org/typelevel/paiges/Chunk.scala index da1b1766..1f8c9efb 100644 --- a/core/src/main/scala/org/typelevel/paiges/Chunk.scala +++ b/core/src/main/scala/org/typelevel/paiges/Chunk.scala @@ -133,11 +133,11 @@ private[paiges] object Chunk { if (trim) new TrimChunkIterator(stream) else new ChunkIterator(stream) } - //$COVERAGE-OFF$ + // $COVERAGE-OFF$ // code of the form `final val x = ...` is inlined. we never // access this field at runtime, but it is still used. final private[this] val indentMax = 100 - //$COVERAGE-ON$ + // $COVERAGE-ON$ private[this] def makeIndentStr(i: Int): String = "\n" + (" " * i) diff --git a/project/plugins.sbt b/project/plugins.sbt index 9a4cd7dc..c76e3281 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,8 @@ -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.1" ) -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.12") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0") -addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") -addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.1") -addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") +addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.6") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") \ No newline at end of file From 66f2798c98431bcf82ba30a0de5dec7e09ba87f1 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 10:07:56 -1000 Subject: [PATCH 02/17] add headers --- .../scala/org/typelevel/paiges/Platform.scala | 16 ++++++++++++++++ .../scala/org/typelevel/paiges/Platform.scala | 16 ++++++++++++++++ .../scala/org/typelevel/paiges/Platform.scala | 16 ++++++++++++++++ .../org/typelevel/paiges/CatsDocument.scala | 16 ++++++++++++++++ .../scala/org/typelevel/paiges/instances.scala | 16 ++++++++++++++++ .../typelevel/paiges/ScalaVersionCompat.scala | 16 ++++++++++++++++ .../typelevel/paiges/ScalaVersionCompat.scala | 16 ++++++++++++++++ .../main/scala/org/typelevel/paiges/Chunk.scala | 16 ++++++++++++++++ .../main/scala/org/typelevel/paiges/Doc.scala | 16 ++++++++++++++++ .../scala/org/typelevel/paiges/Document.scala | 16 ++++++++++++++++ .../main/scala/org/typelevel/paiges/Style.scala | 16 ++++++++++++++++ .../scala/org/typelevel/paiges/package.scala | 16 ++++++++++++++++ 12 files changed, 192 insertions(+) diff --git a/cats/js/src/main/scala/org/typelevel/paiges/Platform.scala b/cats/js/src/main/scala/org/typelevel/paiges/Platform.scala index 7aa94419..68be4354 100644 --- a/cats/js/src/main/scala/org/typelevel/paiges/Platform.scala +++ b/cats/js/src/main/scala/org/typelevel/paiges/Platform.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges private[paiges] object Platform { diff --git a/cats/jvm/src/main/scala/org/typelevel/paiges/Platform.scala b/cats/jvm/src/main/scala/org/typelevel/paiges/Platform.scala index 12455f1b..fe4d87a9 100644 --- a/cats/jvm/src/main/scala/org/typelevel/paiges/Platform.scala +++ b/cats/jvm/src/main/scala/org/typelevel/paiges/Platform.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges private[paiges] object Platform { diff --git a/cats/native/src/main/scala/org/typelevel/paiges/Platform.scala b/cats/native/src/main/scala/org/typelevel/paiges/Platform.scala index dd0d77d9..9eaf3c10 100644 --- a/cats/native/src/main/scala/org/typelevel/paiges/Platform.scala +++ b/cats/native/src/main/scala/org/typelevel/paiges/Platform.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges private[paiges] object Platform { diff --git a/cats/shared/src/main/scala/org/typelevel/paiges/CatsDocument.scala b/cats/shared/src/main/scala/org/typelevel/paiges/CatsDocument.scala index 5a2c9839..d96cdba8 100644 --- a/cats/shared/src/main/scala/org/typelevel/paiges/CatsDocument.scala +++ b/cats/shared/src/main/scala/org/typelevel/paiges/CatsDocument.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import cats.{Contravariant, Defer, Semigroupal} diff --git a/cats/shared/src/main/scala/org/typelevel/paiges/instances.scala b/cats/shared/src/main/scala/org/typelevel/paiges/instances.scala index 7981b52a..ef10ed6b 100644 --- a/cats/shared/src/main/scala/org/typelevel/paiges/instances.scala +++ b/cats/shared/src/main/scala/org/typelevel/paiges/instances.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import cats.kernel.{Eq, Monoid} diff --git a/core/src/main/scala-2.12-/org/typelevel/paiges/ScalaVersionCompat.scala b/core/src/main/scala-2.12-/org/typelevel/paiges/ScalaVersionCompat.scala index 416a97f1..b8f03dee 100644 --- a/core/src/main/scala-2.12-/org/typelevel/paiges/ScalaVersionCompat.scala +++ b/core/src/main/scala-2.12-/org/typelevel/paiges/ScalaVersionCompat.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges object ScalaVersionCompat { diff --git a/core/src/main/scala-2.13+/org/typelevel/paiges/ScalaVersionCompat.scala b/core/src/main/scala-2.13+/org/typelevel/paiges/ScalaVersionCompat.scala index 40dd5390..282434b6 100644 --- a/core/src/main/scala-2.13+/org/typelevel/paiges/ScalaVersionCompat.scala +++ b/core/src/main/scala-2.13+/org/typelevel/paiges/ScalaVersionCompat.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges object ScalaVersionCompat { diff --git a/core/src/main/scala/org/typelevel/paiges/Chunk.scala b/core/src/main/scala/org/typelevel/paiges/Chunk.scala index 1f8c9efb..194b2da8 100644 --- a/core/src/main/scala/org/typelevel/paiges/Chunk.scala +++ b/core/src/main/scala/org/typelevel/paiges/Chunk.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import scala.annotation.tailrec diff --git a/core/src/main/scala/org/typelevel/paiges/Doc.scala b/core/src/main/scala/org/typelevel/paiges/Doc.scala index cc261fd6..cf6d9287 100644 --- a/core/src/main/scala/org/typelevel/paiges/Doc.scala +++ b/core/src/main/scala/org/typelevel/paiges/Doc.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import java.io.PrintWriter diff --git a/core/src/main/scala/org/typelevel/paiges/Document.scala b/core/src/main/scala/org/typelevel/paiges/Document.scala index 37d18d04..36d18bd9 100644 --- a/core/src/main/scala/org/typelevel/paiges/Document.scala +++ b/core/src/main/scala/org/typelevel/paiges/Document.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges trait Document[A] { self => diff --git a/core/src/main/scala/org/typelevel/paiges/Style.scala b/core/src/main/scala/org/typelevel/paiges/Style.scala index 240002c4..b48305d9 100644 --- a/core/src/main/scala/org/typelevel/paiges/Style.scala +++ b/core/src/main/scala/org/typelevel/paiges/Style.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges /** diff --git a/core/src/main/scala/org/typelevel/paiges/package.scala b/core/src/main/scala/org/typelevel/paiges/package.scala index c52fb509..e385d25f 100644 --- a/core/src/main/scala/org/typelevel/paiges/package.scala +++ b/core/src/main/scala/org/typelevel/paiges/package.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel package object paiges { From 735483c976e20f713efb2a8b0d419ab7d00f57df Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 10:10:31 -1000 Subject: [PATCH 03/17] do headerCheckAll --- .../scala/org/typelevel/paiges/LawTests.scala | 16 ++++++++++ .../org/typelevel/paiges/ColorTest.scala | 16 ++++++++++ .../org/typelevel/paiges/DocumentTests.scala | 16 ++++++++++ .../org/typelevel/paiges/Generators.scala | 31 +++++++++++++++++++ .../scala/org/typelevel/paiges/JsonTest.scala | 16 ++++++++++ .../paiges/PaigesScalacheckTest.scala | 16 ++++++++++ .../org/typelevel/paiges/PaigesTest.scala | 16 ++++++++++ 7 files changed, 127 insertions(+) diff --git a/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala b/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala index 3cf3d3b1..b85cc7bf 100644 --- a/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala +++ b/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import cats.Semigroupal diff --git a/core/src/test/scala/org/typelevel/paiges/ColorTest.scala b/core/src/test/scala/org/typelevel/paiges/ColorTest.scala index 54f05eeb..7309de43 100644 --- a/core/src/test/scala/org/typelevel/paiges/ColorTest.scala +++ b/core/src/test/scala/org/typelevel/paiges/ColorTest.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import org.scalatest.funsuite.AnyFunSuite diff --git a/core/src/test/scala/org/typelevel/paiges/DocumentTests.scala b/core/src/test/scala/org/typelevel/paiges/DocumentTests.scala index 3583345a..cabc20dc 100644 --- a/core/src/test/scala/org/typelevel/paiges/DocumentTests.scala +++ b/core/src/test/scala/org/typelevel/paiges/DocumentTests.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import org.scalatest.funsuite.AnyFunSuite diff --git a/core/src/test/scala/org/typelevel/paiges/Generators.scala b/core/src/test/scala/org/typelevel/paiges/Generators.scala index 809507ea..bc10c301 100644 --- a/core/src/test/scala/org/typelevel/paiges/Generators.scala +++ b/core/src/test/scala/org/typelevel/paiges/Generators.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import org.scalacheck.Shrink.shrink @@ -248,3 +264,18 @@ object Generators { } } } +, sb), sa.flatMap(x => sb.map(y => f(x, y)))) + } + Shrink { + case FlatAlt(_, b) => b #:: shrinkDoc.shrink(b) + case Union(a, b) => combine2(a, b)(Union) + case Concat(a, b) => combine2(a, b)(_ + _) + case Text(s) => shrink(s).map(text) + case ZeroWidth(s) => shrink(s).map(zeroWidth) + case Nest(i, d) => interleave(shrink(d), combine(d)(_.nested(i))) + case Align(d) => interleave(shrink(d), combine(d)(_.aligned)) + case Line | Empty => Stream.empty + case d @ LazyDoc(_) => d.evaluated #:: shrink(d.evaluated) + } + } +} diff --git a/core/src/test/scala/org/typelevel/paiges/JsonTest.scala b/core/src/test/scala/org/typelevel/paiges/JsonTest.scala index 13266639..f508e727 100644 --- a/core/src/test/scala/org/typelevel/paiges/JsonTest.scala +++ b/core/src/test/scala/org/typelevel/paiges/JsonTest.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import org.scalatest.funsuite.AnyFunSuite diff --git a/core/src/test/scala/org/typelevel/paiges/PaigesScalacheckTest.scala b/core/src/test/scala/org/typelevel/paiges/PaigesScalacheckTest.scala index f8484247..3f794677 100644 --- a/core/src/test/scala/org/typelevel/paiges/PaigesScalacheckTest.scala +++ b/core/src/test/scala/org/typelevel/paiges/PaigesScalacheckTest.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import org.scalacheck.Gen diff --git a/core/src/test/scala/org/typelevel/paiges/PaigesTest.scala b/core/src/test/scala/org/typelevel/paiges/PaigesTest.scala index 6b985e58..c0e88fcf 100644 --- a/core/src/test/scala/org/typelevel/paiges/PaigesTest.scala +++ b/core/src/test/scala/org/typelevel/paiges/PaigesTest.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2022 Typelevel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.typelevel.paiges import scala.annotation.tailrec From 3f388e18f6b2399bfdd4602e31fff32806464314 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 10:18:28 -1000 Subject: [PATCH 04/17] fix weird Generators broken code, remove warnings --- .../main/scala/org/typelevel/paiges/Doc.scala | 18 +++++++++--------- .../org/typelevel/paiges/Generators.scala | 17 +---------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/core/src/main/scala/org/typelevel/paiges/Doc.scala b/core/src/main/scala/org/typelevel/paiges/Doc.scala index cf6d9287..1f532844 100644 --- a/core/src/main/scala/org/typelevel/paiges/Doc.scala +++ b/core/src/main/scala/org/typelevel/paiges/Doc.scala @@ -250,7 +250,7 @@ sealed abstract class Doc extends Product with Serializable { // minor optimization to short circuit sooner s.isEmpty && loop(a, stack) case Concat(a, b) => loop(a, b :: stack) - case Nest(i, d) => loop(d, stack) + case Nest(_, d) => loop(d, stack) case Align(d) => loop(d, stack) case Text(s) => // shouldn't be empty by construction, but defensive @@ -334,13 +334,13 @@ sealed abstract class Doc extends Product with Serializable { def loop(pos: Int, lst: List[(Int, Doc)]): LazyList[String] = lst match { case Nil => LazyList.empty - case (i, Empty) :: z => loop(pos, z) + case (_, Empty) :: z => loop(pos, z) case (i, FlatAlt(a, _)) :: z => loop(pos, (i, a) :: z) case (i, Concat(a, b)) :: z => loop(pos, (i, a) :: (i, b) :: z) case (i, Nest(j, d)) :: z => loop(pos, ((i + j), d) :: z) - case (i, Align(d)) :: z => loop(pos, (pos, d) :: z) - case (i, Text(s)) :: z => s #:: cheat(pos + s.length, z) - case (i, ZeroWidth(s)) :: z => s #:: cheat(pos, z) + case (_, Align(d)) :: z => loop(pos, (pos, d) :: z) + case (_, Text(s)) :: z => s #:: cheat(pos + s.length, z) + case (_, ZeroWidth(s)) :: z => s #:: cheat(pos, z) case (i, Line) :: z => Chunk.lineToStr(i) #:: cheat(i, z) case (i, d @ LazyDoc(_)) :: z => loop(pos, (i, d.evaluated) :: z) case (i, Union(a, _)) :: z => @@ -615,13 +615,13 @@ sealed abstract class Doc extends Product with Serializable { def loop(pos: Int, lst: List[(Int, Doc)], max: Int): Int = lst match { case Nil => math.max(max, pos) - case (i, Empty) :: z => loop(pos, z, max) + case (_, Empty) :: z => loop(pos, z, max) case (i, FlatAlt(default, _)) :: z => loop(pos, (i, default) :: z, max) case (i, Concat(a, b)) :: z => loop(pos, (i, a) :: (i, b) :: z, max) case (i, Nest(j, d)) :: z => loop(pos, ((i + j), d) :: z, max) - case (i, Align(d)) :: z => loop(pos, (pos, d) :: z, max) - case (i, Text(s)) :: z => loop(pos + s.length, z, max) - case (i, ZeroWidth(_)) :: z => loop(pos, z, max) + case (_, Align(d)) :: z => loop(pos, (pos, d) :: z, max) + case (_, Text(s)) :: z => loop(pos + s.length, z, max) + case (_, ZeroWidth(_)) :: z => loop(pos, z, max) case (i, Line) :: z => loop(i, z, math.max(max, pos)) case (i, d @ LazyDoc(_)) :: z => loop(pos, (i, d.evaluated) :: z, max) case (i, Union(a, _)) :: z => diff --git a/core/src/test/scala/org/typelevel/paiges/Generators.scala b/core/src/test/scala/org/typelevel/paiges/Generators.scala index bc10c301..2c21b54f 100644 --- a/core/src/test/scala/org/typelevel/paiges/Generators.scala +++ b/core/src/test/scala/org/typelevel/paiges/Generators.scala @@ -263,19 +263,4 @@ object Generators { case d @ LazyDoc(_) => d.evaluated #:: shrink(d.evaluated) } } -} -, sb), sa.flatMap(x => sb.map(y => f(x, y)))) - } - Shrink { - case FlatAlt(_, b) => b #:: shrinkDoc.shrink(b) - case Union(a, b) => combine2(a, b)(Union) - case Concat(a, b) => combine2(a, b)(_ + _) - case Text(s) => shrink(s).map(text) - case ZeroWidth(s) => shrink(s).map(zeroWidth) - case Nest(i, d) => interleave(shrink(d), combine(d)(_.nested(i))) - case Align(d) => interleave(shrink(d), combine(d)(_.aligned)) - case Line | Empty => Stream.empty - case d @ LazyDoc(_) => d.evaluated #:: shrink(d.evaluated) - } - } -} +} \ No newline at end of file From 2b5f8781794469504682cb1e404013e2a9b42a6e Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 10:23:35 -1000 Subject: [PATCH 05/17] format, remove noPublish --- build.sbt | 14 +++----------- .../scala/org/typelevel/paiges/Generators.scala | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/build.sbt b/build.sbt index 62905764..767e3b81 100644 --- a/build.sbt +++ b/build.sbt @@ -31,8 +31,6 @@ def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scala } } -//noPublish - lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) .crossType(CrossType.Pure) .in(file("core")) @@ -80,8 +78,8 @@ lazy val catsNative = cats.native lazy val benchmark = project .in(file("benchmark")) .dependsOn(coreJVM, catsJVM) + .enablePlugins(NoPublishPlugin) .settings( - noPublish, crossScalaVersions := List(Scala212), name := "paiges-benchmark" ) @@ -91,8 +89,8 @@ lazy val docs = project .in(file("docs")) .dependsOn(coreJVM, catsJVM) .enablePlugins(MdocPlugin) + .enablePlugins(NoPublishPlugin) .settings( - noPublish, crossScalaVersions := List(Scala212), name := "paiges-docs", mdocIn := (LocalRootProject / baseDirectory).value / "docs" / "src" / "main" / "mdoc" @@ -131,10 +129,4 @@ lazy val commonNativeSettings = Seq( // Remove when native is published for the default previous versions tlVersionIntroduced := List("2.12", "2.13").map(_ -> "0.4.1").toMap, coverageEnabled := false -) - -lazy val noPublish = commonSettings ++ Seq( - publish / skip := true, - mimaPreviousArtifacts := Set.empty, - coverageEnabled := false -) +) \ No newline at end of file diff --git a/core/src/test/scala/org/typelevel/paiges/Generators.scala b/core/src/test/scala/org/typelevel/paiges/Generators.scala index 2c21b54f..5924eb24 100644 --- a/core/src/test/scala/org/typelevel/paiges/Generators.scala +++ b/core/src/test/scala/org/typelevel/paiges/Generators.scala @@ -263,4 +263,4 @@ object Generators { case d @ LazyDoc(_) => d.evaluated #:: shrink(d.evaluated) } } -} \ No newline at end of file +} From 01acd3ad4b68f6a2dd7cc8216503900131acb142 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 10:48:16 -1000 Subject: [PATCH 06/17] format build.sbt, clean a few things --- build.sbt | 8 ++------ project/plugins.sbt | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 767e3b81..300c63cb 100644 --- a/build.sbt +++ b/build.sbt @@ -15,7 +15,6 @@ ThisBuild / developers := List( tlGitHubDev("non", "Erik Osheim") ) - def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scalaVersion: String) = { def extraDirs(suffix: String) = List(CrossType.Pure, CrossType.Full) @@ -64,7 +63,7 @@ lazy val cats = crossProject(JSPlatform, JVMPlatform, NativePlatform) "org.typelevel" %%% "cats-core" % "2.7.0", "org.typelevel" %%% "cats-laws" % "2.7.0" % Test, "org.typelevel" %%% "discipline-scalatest" % "2.1.5" % Test - ), + ) ) .disablePlugins(JmhPlugin) .jsSettings(commonJsSettings) @@ -118,9 +117,6 @@ lazy val commonJvmSettings = Seq( ) lazy val commonJsSettings = Seq( - Global / scalaJSStage := FastOptStage, - parallelExecution := false, - jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(), coverageEnabled := false ) @@ -129,4 +125,4 @@ lazy val commonNativeSettings = Seq( // Remove when native is published for the default previous versions tlVersionIntroduced := List("2.12", "2.13").map(_ -> "0.4.1").toMap, coverageEnabled := false -) \ No newline at end of file +) diff --git a/project/plugins.sbt b/project/plugins.sbt index c76e3281..e13b3492 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,8 +1,8 @@ addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.1" ) +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.6") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") \ No newline at end of file +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") From d468770a7a324d94ac6300e2a88b59853fe7f44b Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 14:10:56 -1000 Subject: [PATCH 07/17] try to disable native on scala3 --- build.sbt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 300c63cb..094d104e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,13 @@ val Scala212 = "2.12.15" val Scala213 = "2.13.8" +val Scala3Version = "3.1.0" ThisBuild / tlBaseVersion := "0.4" ThisBuild / scalaVersion := Scala213 -ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, "3.1.0") +ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, Scala3Version) +ThisBuild / githubWorkflowBuildMatrixExclusions += + MatrixExclude(Map("project" -> "rootNative", "scala" -> Scala3Version)) lazy val root = tlCrossRootProject.aggregate(core, cats) From 34834684bc5b829d58206834a641e2d1eabde292 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 15:16:50 -1000 Subject: [PATCH 08/17] generate workflow --- .github/workflows/ci.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63272558..952343c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,9 @@ jobs: scala: [2.13.8, 2.12.15, 3.1.0] java: [temurin@8] project: [rootJS, rootJVM, rootNative] + exclude: + - project: rootNative + scala: 3.1.0 runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -231,16 +234,6 @@ jobs: tar xf targets.tar rm targets.tar - - name: Download target directories (3.1.0, rootNative) - uses: actions/download-artifact@v2 - with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.0-rootNative - - - name: Inflate target directories (3.1.0, rootNative) - run: | - tar xf targets.tar - rm targets.tar - - name: Import signing key if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' run: echo $PGP_SECRET | base64 -di | gpg --import From db9355bdb9056e94c72f2777a6d55e4fdb41c61e Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 15:28:32 -1000 Subject: [PATCH 09/17] disable warning in CI :( --- build.sbt | 3 +++ core/src/test/scala/org/typelevel/paiges/Generators.scala | 1 + 2 files changed, 4 insertions(+) diff --git a/build.sbt b/build.sbt index 094d104e..6740ccbc 100644 --- a/build.sbt +++ b/build.sbt @@ -9,6 +9,9 @@ ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, Scala3Version) ThisBuild / githubWorkflowBuildMatrixExclusions += MatrixExclude(Map("project" -> "rootNative", "scala" -> Scala3Version)) +// TODO: 2.13 has warnings for using Stream, but scalacheck Shrink +ThisBuild / tlFatalWarningsInCi := false + lazy val root = tlCrossRootProject.aggregate(core, cats) ThisBuild / developers := List( diff --git a/core/src/test/scala/org/typelevel/paiges/Generators.scala b/core/src/test/scala/org/typelevel/paiges/Generators.scala index 5924eb24..2f7014ce 100644 --- a/core/src/test/scala/org/typelevel/paiges/Generators.scala +++ b/core/src/test/scala/org/typelevel/paiges/Generators.scala @@ -243,6 +243,7 @@ object Generators { if (xs.isEmpty) ys else if (ys.isEmpty) xs else xs.head #:: ys.head #:: interleave(xs.tail, ys.tail) + def combine[A](a: A)(f: A => A)(implicit F: Shrink[A]): Stream[A] = { val sa = shrink(a) a #:: interleave(sa, sa.map(f)) From c783cb7cef5692cf1c8795fdf2ba357ab7e9c399 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 15:39:26 -1000 Subject: [PATCH 10/17] try once again... --- build.sbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 6740ccbc..59967139 100644 --- a/build.sbt +++ b/build.sbt @@ -5,13 +5,11 @@ val Scala3Version = "3.1.0" ThisBuild / tlBaseVersion := "0.4" ThisBuild / scalaVersion := Scala213 +ThisBuild / tlVersionIntroduced := Map("3" -> "0.4.2") ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, Scala3Version) ThisBuild / githubWorkflowBuildMatrixExclusions += MatrixExclude(Map("project" -> "rootNative", "scala" -> Scala3Version)) -// TODO: 2.13 has warnings for using Stream, but scalacheck Shrink -ThisBuild / tlFatalWarningsInCi := false - lazy val root = tlCrossRootProject.aggregate(core, cats) ThisBuild / developers := List( @@ -46,7 +44,9 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) libraryDependencies ++= Seq( "org.scalatestplus" %%% "scalacheck-1-15" % "3.2.10.0" % Test, "org.scalatest" %%% "scalatest-funsuite" % "3.2.11" % Test - ) + ), + // TODO: 2.13 has warnings for using Stream, but scalacheck Shrink + Test / tlFatalWarningsInCi := false ) .disablePlugins(JmhPlugin) .jsSettings(commonJsSettings) From de3b86969cf63676db89a91c4c2a58aa92211443 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 15:45:17 -1000 Subject: [PATCH 11/17] address scala 3 warning --- core/src/test/scala/org/typelevel/paiges/Generators.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/test/scala/org/typelevel/paiges/Generators.scala b/core/src/test/scala/org/typelevel/paiges/Generators.scala index 2f7014ce..5f6ac010 100644 --- a/core/src/test/scala/org/typelevel/paiges/Generators.scala +++ b/core/src/test/scala/org/typelevel/paiges/Generators.scala @@ -163,7 +163,7 @@ object Generators { n <- Gen.choose(1, max) start <- genDoc front <- Gen.listOfN(n, genDoc) - } yield front.foldLeft(start)(Doc.Concat) + } yield front.foldLeft(start)(Doc.Concat(_, _)) def fill(max: Int): Gen[Doc] = { // we start at 1 because fill(d, Nil) == Empty @@ -254,7 +254,7 @@ object Generators { } Shrink { case FlatAlt(_, b) => b #:: shrinkDoc.shrink(b) - case Union(a, b) => combine2(a, b)(Union) + case Union(a, b) => combine2(a, b)(Union(_, _)) case Concat(a, b) => combine2(a, b)(_ + _) case Text(s) => shrink(s).map(text) case ZeroWidth(s) => shrink(s).map(zeroWidth) From 892c9b2e56055a867d1897e1b2928c0d834da098 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 15:53:51 -1000 Subject: [PATCH 12/17] keep on trying --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 59967139..60a09b54 100644 --- a/build.sbt +++ b/build.sbt @@ -46,7 +46,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) "org.scalatest" %%% "scalatest-funsuite" % "3.2.11" % Test ), // TODO: 2.13 has warnings for using Stream, but scalacheck Shrink - Test / tlFatalWarningsInCi := false + tlFatalWarningsInCi := scalaVersion.value.startsWith("2.12.") ) .disablePlugins(JmhPlugin) .jsSettings(commonJsSettings) From dd9f0f6c01d22df2ee7210c08de2b243e87b1f5e Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 16:01:26 -1000 Subject: [PATCH 13/17] fix another warning --- cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala b/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala index b85cc7bf..9c7b3ff0 100644 --- a/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala +++ b/cats/shared/src/test/scala/org/typelevel/paiges/LawTests.scala @@ -36,7 +36,7 @@ class LawTests extends LawChecking with CatsDocument { implicit val docEq: Eq[Doc] = Eq.instance((x: Doc, y: Doc) => PaigesTest.docEquiv.equiv(x, y)) - implicit def monoidTests[A: Eq: Arbitrary: Monoid]: MonoidTests[A] = MonoidTests[A] + implicit def monoidTests[A: Monoid]: MonoidTests[A] = MonoidTests[A] implicit def arbitraryForDocument[A]: Arbitrary[Document[A]] = Arbitrary(Document.useToString[A]) From c51b0708004b0db1247a8289a9d174a6b6aee3ac Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 16:09:48 -1000 Subject: [PATCH 14/17] Add jvmopts --- .jvmopts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .jvmopts diff --git a/.jvmopts b/.jvmopts new file mode 100644 index 00000000..6f8a1a39 --- /dev/null +++ b/.jvmopts @@ -0,0 +1,3 @@ +-Xms1G +-Xmx4G +-XX:+UseG1GC \ No newline at end of file From 7565797adea41d1d57afa2e0ff5f5323c9856567 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 16:51:19 -1000 Subject: [PATCH 15/17] add typelevel-set, coverage --- README.md | 2 +- build.sbt | 19 +++++++++++++++++-- docs/src/main/mdoc/{intro.md => index.md} | 0 project/plugins.sbt | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) rename docs/src/main/mdoc/{intro.md => index.md} (100%) diff --git a/README.md b/README.md index abdbfa7a..b21d8171 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ c.render(60) // ) ``` -For more examples, see the [tutorial](docs/src/main/mdoc/intro.md). +For more examples, see the [tutorial](docs/src/main/mdoc/index.md). ## Benchmarks diff --git a/build.sbt b/build.sbt index 60a09b54..f0396069 100644 --- a/build.sbt +++ b/build.sbt @@ -10,6 +10,22 @@ ThisBuild / crossScalaVersions := Seq(Scala213, Scala212, Scala3Version) ThisBuild / githubWorkflowBuildMatrixExclusions += MatrixExclude(Map("project" -> "rootNative", "scala" -> Scala3Version)) +// Setup coverage +ThisBuild / githubWorkflowAddedJobs += + WorkflowJob( + id = "coverage", + name = "Generate coverage report", + scalas = List("2.13.8"), + steps = List(WorkflowStep.Checkout) ++ WorkflowStep.SetupJava( + githubWorkflowJavaVersions.value.toList + ) ++ githubWorkflowGeneratedCacheSteps.value ++ List( + WorkflowStep.Sbt(List("coverage", "rootJVM/test", "coverageAggregate")), + WorkflowStep.Run(List("bash <(curl -s https://codecov.io/bash)")) + ) + ) + +ThisBuild / tlCiReleaseBranches := Seq("master") + lazy val root = tlCrossRootProject.aggregate(core, cats) ThisBuild / developers := List( @@ -93,8 +109,7 @@ lazy val benchmark = project lazy val docs = project .in(file("docs")) .dependsOn(coreJVM, catsJVM) - .enablePlugins(MdocPlugin) - .enablePlugins(NoPublishPlugin) + .enablePlugins(TypelevelSitePlugin) .settings( crossScalaVersions := List(Scala212), name := "paiges-docs", diff --git a/docs/src/main/mdoc/intro.md b/docs/src/main/mdoc/index.md similarity index 100% rename from docs/src/main/mdoc/intro.md rename to docs/src/main/mdoc/index.md diff --git a/project/plugins.sbt b/project/plugins.sbt index e13b3492..13a39b35 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,4 +5,5 @@ addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.1") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.6") +addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.4.6") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") From 272493e08a32491d0937a7f16eeeb9d2e0cc6fe4 Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 16:52:30 -1000 Subject: [PATCH 16/17] update github ci --- .github/workflows/ci.yml | 105 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 952343c4..ab50ddf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,15 +96,15 @@ jobs: run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc - name: Make target directories - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') run: mkdir -p target cats/native/target .js/target core/.native/target docs/target core/.js/target core/.jvm/target .jvm/target .native/target cats/js/target cats/jvm/target benchmark/target project/target - name: Compress target directories - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') run: tar cf targets.tar target cats/native/target .js/target core/.native/target docs/target core/.js/target core/.jvm/target .jvm/target .native/target cats/js/target cats/jvm/target benchmark/target project/target - name: Upload target directories - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') uses: actions/upload-artifact@v2 with: name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} @@ -113,7 +113,7 @@ jobs: publish: name: Publish Artifacts needs: [build] - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') strategy: matrix: os: [ubuntu-latest] @@ -247,3 +247,100 @@ jobs: - name: Publish run: sbt '++${{ matrix.scala }}' tlRelease + + coverage: + name: Generate coverage report + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.8] + java: [temurin@11] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (fast) + uses: actions/checkout@v2 + + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - run: sbt '++${{ matrix.scala }}' coverage rootJVM/test coverageAggregate + + - run: 'bash <(curl -s https://codecov.io/bash)' + + site: + name: Generate Site + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.8] + java: [temurin@8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Generate site + run: sbt '++${{ matrix.scala }}' docs/tlSite + + - name: Publish site + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: peaceiris/actions-gh-pages@v3.8.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/target/docs/site + keep_files: true From 28a15c7de6683d8659bac4d95974cd606ec446ce Mon Sep 17 00:00:00 2001 From: Patrick Oscar Boykin Date: Sat, 5 Mar 2022 17:02:09 -1000 Subject: [PATCH 17/17] keep on hacking --- .github/workflows/ci.yml | 2 +- build.sbt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab50ddf2..c4536357 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -338,7 +338,7 @@ jobs: run: sbt '++${{ matrix.scala }}' docs/tlSite - name: Publish site - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' uses: peaceiris/actions-gh-pages@v3.8.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.sbt b/build.sbt index f0396069..410cda3b 100644 --- a/build.sbt +++ b/build.sbt @@ -25,6 +25,7 @@ ThisBuild / githubWorkflowAddedJobs += ) ThisBuild / tlCiReleaseBranches := Seq("master") +ThisBuild / tlSitePublishBranch := Some("master") lazy val root = tlCrossRootProject.aggregate(core, cats) @@ -101,7 +102,6 @@ lazy val benchmark = project .dependsOn(coreJVM, catsJVM) .enablePlugins(NoPublishPlugin) .settings( - crossScalaVersions := List(Scala212), name := "paiges-benchmark" ) .enablePlugins(JmhPlugin) @@ -111,7 +111,6 @@ lazy val docs = project .dependsOn(coreJVM, catsJVM) .enablePlugins(TypelevelSitePlugin) .settings( - crossScalaVersions := List(Scala212), name := "paiges-docs", mdocIn := (LocalRootProject / baseDirectory).value / "docs" / "src" / "main" / "mdoc" )