Skip to content

Commit

Permalink
Merge pull request #46 from http4s/pr/js-native
Browse files Browse the repository at this point in the history
Cross-build for JS and Native
  • Loading branch information
armanbilge authored Sep 23, 2022
2 parents 0e345ee + 8af7d59 commit e5b2c4b
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 30 deletions.
113 changes: 95 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-Xms1G
-Xmx4G
-XX:+UseG1GC
8 changes: 6 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -28,3 +29,6 @@ lazy val scalatags = project
"org.http4s" %%% "http4s-laws" % http4sVersion % Test,
),
)
.nativeSettings(
unusedCompileDependenciesTest := {}
)
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")
17 changes: 7 additions & 10 deletions scalatags/src/test/scala/org/http4s/scalatags/ScalatagsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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() = {
Expand Down

0 comments on commit e5b2c4b

Please sign in to comment.