From cee3d4862d3c766fd0bd08d4c17584dec245bb41 Mon Sep 17 00:00:00 2001 From: adamw Date: Mon, 29 Aug 2022 16:38:04 +0200 Subject: [PATCH] Split CI tests by scala version & platform --- .github/workflows/ci.yml | 25 ++++++++----------------- README.md | 2 +- build.sbt | 37 ++++++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d54f55a5fe..29a31aec14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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: @@ -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 diff --git a/README.md b/README.md index 6c15981f85..a27f5faa12 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sbt b/build.sbt index 612b5fab65..041e46e051 100644 --- a/build.sbt +++ b/build.sbt @@ -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))): _*)) @@ -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, @@ -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("").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() )