diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 737db55..8e4b925 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: os: [ubuntu-latest] scala: [2.12.17, 2.13.9, 3.1.3] java: [temurin@8, temurin@11, temurin@17] + project: [rootJS, rootJVM, rootNative] exclude: - scala: 2.12.17 java: temurin@11 @@ -40,6 +41,14 @@ jobs: java: temurin@11 - scala: 3.1.3 java: temurin@17 + - project: rootJS + java: temurin@11 + - project: rootJS + java: temurin@17 + - project: rootNative + java: temurin@11 + - project: rootNative + java: temurin@17 runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -112,40 +121,48 @@ jobs: - name: Check headers and formatting if: matrix.java == 'temurin@8' - run: sbt '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck + + - name: scalaJSLink + if: matrix.project == 'rootJS' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult + + - name: nativeLink + if: matrix.project == 'rootNative' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink - name: Test - run: sbt '++${{ matrix.scala }}' test + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test - name: Check binary compatibility if: matrix.java == 'temurin@8' - run: sbt '++${{ matrix.scala }}' mimaReportBinaryIssues + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues - name: Generate API documentation if: matrix.java == 'temurin@8' - run: sbt '++${{ matrix.scala }}' doc + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc - name: Check scalafix lints if: matrix.java == 'temurin@8' && !startsWith(matrix.scala, '3.') - run: sbt '++${{ matrix.scala }}' 'scalafixAll --check' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'scalafixAll --check' - name: Check unused compile dependencies if: matrix.java == 'temurin@8' - run: sbt '++${{ matrix.scala }}' unusedCompileDependenciesTest + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' unusedCompileDependenciesTest - 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 scalatags/target project/target + run: mkdir -p target .js/target scalatags/.js/target .jvm/target .native/target scalatags/.native/target scalatags/.jvm/target project/target - 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 scalatags/target project/target + run: tar cf targets.tar target .js/target scalatags/.js/target .jvm/target .native/target scalatags/.native/target scalatags/.jvm/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 }} + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} path: targets.tar publish: @@ -224,32 +241,92 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Download target directories (2.12.17) + - name: Download target directories (2.12.17, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.17-rootJS + + - name: Inflate target directories (2.12.17, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.17, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.17-rootJVM + + - name: Inflate target directories (2.12.17, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.17, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.17-rootNative + + - name: Inflate target directories (2.12.17, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.9, rootJS) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.9-rootJS + + - name: Inflate target directories (2.13.9, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.9, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.9-rootJVM + + - name: Inflate target directories (2.13.9, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.9, rootNative) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.9-rootNative + + - name: Inflate target directories (2.13.9, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.1.3, rootJS) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.17 + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootJS - - name: Inflate target directories (2.12.17) + - name: Inflate target directories (3.1.3, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.13.9) + - name: Download target directories (3.1.3, rootJVM) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.9 + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootJVM - - name: Inflate target directories (2.13.9) + - name: Inflate target directories (3.1.3, rootJVM) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (3.1.3) + - name: Download target directories (3.1.3, rootNative) uses: actions/download-artifact@v2 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3 + name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootNative - - name: Inflate target directories (3.1.3) + - name: Inflate target directories (3.1.3, rootNative) run: | tar xf targets.tar rm targets.tar diff --git a/.jvmopts b/.jvmopts new file mode 100644 index 0000000..3f0aee1 --- /dev/null +++ b/.jvmopts @@ -0,0 +1,3 @@ +-Xms1G +-Xmx4G +-XX:+UseG1GC diff --git a/build.sbt b/build.sbt index c822773..770049b 100644 --- a/build.sbt +++ b/build.sbt @@ -7,14 +7,15 @@ val Scala213 = "2.13.9" ThisBuild / crossScalaVersions := Seq("2.12.17", Scala213, "3.1.3") ThisBuild / scalaVersion := Scala213 -lazy val root = project.in(file(".")).aggregate(scalatags).enablePlugins(NoPublishPlugin) +lazy val root = tlCrossRootProject.aggregate(scalatags) val http4sVersion = "0.23.16" val scalatagsVersion = "0.12.0" val munitVersion = "1.0.0-M6" val munitCatsEffectVersion = "2.0.0-M3" -lazy val scalatags = project +lazy val scalatags = crossProject(JVMPlatform, JSPlatform, NativePlatform) + .crossType(CrossType.Pure) .in(file("scalatags")) .settings( name := "http4s-scalatags", @@ -28,3 +29,6 @@ lazy val scalatags = project "org.http4s" %%% "http4s-laws" % http4sVersion % Test, ), ) + .nativeSettings( + unusedCompileDependenciesTest := {} + ) diff --git a/project/plugins.sbt b/project/plugins.sbt index c70624f..bb43098 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1,4 @@ addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.6") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") diff --git a/scalatags/src/test/scala/org/http4s/scalatags/ScalatagsSuite.scala b/scalatags/src/test/scala/org/http4s/scalatags/ScalatagsSuite.scala index cedc46f..812f3f0 100644 --- a/scalatags/src/test/scala/org/http4s/scalatags/ScalatagsSuite.scala +++ b/scalatags/src/test/scala/org/http4s/scalatags/ScalatagsSuite.scala @@ -20,22 +20,19 @@ package scalatags import _root_.scalatags.Text import cats.data.NonEmptyList import cats.effect.IO -import cats.syntax.all._ import munit.CatsEffectSuite import org.http4s.Status.Ok import org.http4s.headers.`Content-Type` class ScalatagsSuite extends CatsEffectSuite { - implicit class ParseResultSyntax[A](self: ParseResult[A]) { - def yolo: A = self.valueOr(e => sys.error(e.toString)) - } - - private val testCharsets = NonEmptyList.of( + private val testCharsets = NonEmptyList( Charset.`ISO-8859-1`, - Charset.fromString("Windows-1251").yolo, - Charset.fromString("GB2312").yolo, - Charset.fromString("Shift-JIS").yolo, - Charset.fromString("Windows-1252").yolo, + List( + Charset.fromString("Windows-1251").toOption, + Charset.fromString("GB2312").toOption, + Charset.fromString("Shift-JIS").toOption, + Charset.fromString("Windows-1252").toOption, + ).flatten, ) private def testBody() = {