Skip to content

Commit

Permalink
Split CI tests by scala version & platform
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Aug 29, 2022
1 parent cde430e commit cee3d48
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 29 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
scala-version: [ "2.12", "2.13", "3" ]
target-platform: [ "JVM", "JS", "Native" ]
steps:
- name: Checkout
Expand All @@ -35,29 +36,20 @@ jobs:
sudo apt-get update
sudo apt-get install libidn11-dev
echo "STTP_NATIVE=1" >> $GITHUB_ENV
- name: Compile
run: sbt -v Test/compile compileDocumentation
- name: Test JVM 2.12
- name: Compile documentation
if: matrix.target-platform == 'JVM'
run: sbt -v testJVM_2_12
- name: Test JVM 2.13
if: matrix.target-platform == 'JVM'
run: sbt -v testJVM_2_13
- name: Test JVM 3
if: matrix.target-platform == 'JVM'
run: sbt -v testJVM_3
run: sbt -v compileDocumentation
- name: Test
run: sbt -v testScoped ${matrix.scala-version} ${matrix.target-platform}
# The finatra tests take a really long time (1/3 of the build duration); hence, they are disabled and need to be run separately
#- name: Test finatra
# if: matrix.target-platform != 'JS'
# run: sbt -v testFinatra
# Temporarily call JS tests for each subproject explicitly as a workaround until
# https://github.com/scala-js/scala-js/issues/4317 has a solution
- name: Test Scala.js
if: matrix.target-platform == 'JS'
run: sbt coreJS/test coreJS2_12/test catsJS/test catsJS2_12/test enumeratumJS/test enumeratumJS2_12/test refinedJS/test refinedJS2_12/test circeJsonJS/test circeJsonJS2_12/test playJsonJS/test playJsonJS2_12/test uPickleJsonJS/test uPickleJsonJS2_12/test jsoniterScalaJS/test jsoniterScalaJS2_12/test sttpClientJS/test sttpClientJS2_12/test
- name: Test Native
if: matrix.target-platform == 'Native'
run: sbt -v testNative
# - name: Test Scala.js
# if: matrix.target-platform == 'JS'
# run: sbt coreJS/test coreJS2_12/test catsJS/test catsJS2_12/test enumeratumJS/test enumeratumJS2_12/test refinedJS/test refinedJS2_12/test circeJsonJS/test circeJsonJS2_12/test playJsonJS/test playJsonJS2_12/test uPickleJsonJS/test uPickleJsonJS2_12/test jsoniterScalaJS/test jsoniterScalaJS2_12/test sttpClientJS/test sttpClientJS2_12/test
- name: Prepare release notes
uses: release-drafter/release-drafter@v5
with:
Expand Down Expand Up @@ -100,7 +92,6 @@ jobs:
java-version: 11
cache: 'sbt'
- name: Install libidn11-dev
if: matrix.target-platform == 'Native'
run: |
sudo apt-get update
sudo apt-get install libidn11-dev
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ code is unclear and be improved for the benefit of all.
The JS tests use [Gecko instead of Chrome](https://github.com/scala-js/scala-js-env-selenium/issues/119), although this
causes another problem: out of memory when running JS tests for multiple modules. Work-arounds:

* run only JVM tests for a specific Scala version using `testJVM2_13`
* run only tests for a specific Scala version and platform using `testScoped 2.13 JS` (supported versions: 2.12, 2.13, 3; supported platforms: JVM, JS, Native)
* test single JS projects
* use CI (GitHub Actions) to test all projects - the `.github/workflows/ci.yml` enumerates them one by one

Expand Down
37 changes: 26 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ val testClients = taskKey[Unit]("Test client projects")
val testOther = taskKey[Unit]("Test other projects")
val testFinatra = taskKey[Unit]("Test Finatra projects")

val testScoped = inputKey[Unit](
"Run tests in the given scope. Usage: testScoped [scala version] [platform]. Scala version can be: 2.12, 2.13, 3; platform: JVM, JS, Native"
)

def filterProject(p: String => Boolean) =
ScopeFilter(inProjects(allAggregates.filter(pr => p(display(pr.project))): _*))

Expand Down Expand Up @@ -243,17 +247,6 @@ lazy val rootProject = (project in file("."))
.settings(
publishArtifact := false,
name := "tapir",
testJVM_2_12 := (Test / test)
.all(filterProject(p => !p.contains("JS") && !p.contains("Native") && !p.contains("finatra") && p.contains("2_12")))
.value,
testJVM_2_13 := (Test / test)
.all(
filterProject(p => !p.contains("JS") && !p.contains("Native") && !p.contains("finatra") && !p.contains("2_12") && !p.contains("3"))
)
.value,
testJVM_3 := (Test / test)
.all(filterProject(p => !p.contains("JS") && !p.contains("Native") && !p.contains("finatra") && p.contains("3")))
.value,
testJS := (Test / test).all(filterProject(_.contains("JS"))).value,
testNative := (Test / test).all(filterProject(_.contains("Native"))).value,
testDocs := (Test / test).all(filterProject(p => p.contains("Docs") || p.contains("openapi") || p.contains("asyncapi"))).value,
Expand All @@ -267,6 +260,28 @@ lazy val rootProject = (project in file("."))
)
.value,
testFinatra := (Test / test).all(filterProject(p => p.contains("finatra"))).value,
testScoped := Def.inputTaskDyn {
import complete.DefaultParsers._
val args = spaceDelimited("<arg>").parsed
val scalaVersionFilter = args.head
val platformFilter = args(1)

Def.taskDyn {
(Test / test)
.all(filterProject { projectName =>
val byPlatform =
if (platformFilter == "JVM") !projectName.contains("JS") && !projectName.contains("Native")
else projectName.contains(platformFilter)
val byVersion = scalaVersionFilter match {
case "2.13" => !projectName.contains("2_12") && !projectName.contains("3")
case "2.12" => projectName.contains("2_12")
case "3" => projectName.contains("3")
}

byPlatform && byVersion
})
}
}.evaluated,
ideSkipProject := false,
generateMimeByExtensionDB := GenerateMimeByExtensionDB()
)
Expand Down

0 comments on commit cee3d48

Please sign in to comment.