From b69bd45fd8c9c694eeaa04591787d1e4c0c2486d Mon Sep 17 00:00:00 2001 From: Michal Bednarz Date: Fri, 30 Oct 2020 11:18:33 +0100 Subject: [PATCH 1/2] Enable examples in CI --- .github/workflows/release.yml | 17 +++ .github/workflows/test.yml | 21 ++++ .travis.yml | 33 ------ build.sbt | 1 - examples/src/test/resources/ideprobe.conf | 6 +- .../src/test/resources/projects/dokka.conf | 2 +- .../org/virtuslab/ideprobe/ModuleTest.scala | 101 ++++++++---------- project/CI.scala | 4 +- project/Dependencies.scala | 5 - 9 files changed, 91 insertions(+), 99 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..a419c539 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,17 @@ +name: Release + +on: + push: + branches: + - master + - 2020.3 + tags: + - '**' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: release + run: sbt ci-release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..98ad349f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test + +on: pull_request + +jobs: + test: + timeout-minutes: 120 + runs-on: ubuntu-latest + name: test-${{ matrix.type }} + strategy: + matrix: + type: [probe 2.12.10, probe 2.13.1, scala 2.13.1, examples 2.13.1] + + steps: + - uses: actions/checkout@v2 + - name: generate scripts + run: sbt ci/generateScripts + - name: build image + run: sh ci/tests/build_image + - name: test + run: sh ci/tests/run ${{ matrix.type }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index becb9e4d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -before_install: - - git fetch --tags - - sbt ci/generateScripts - - ci/tests/build_image - -if: (type = push AND fork = false) OR (type = pull_request AND fork = true) - -stages: - - name: Test - - name: Release - if: ((branch = master) OR (branch = 2020.3) OR (tag IS present)) AND NOT fork - -services: - - docker - -os: linux -dist: trusty -language: scala -jdk: openjdk11 -scala: - - 2.13.1 - -jobs: - include: - - name: test-probe @ scala-2.12 - script: ci/tests/run probe 2.12.10 - - name: test-probe @ scala-2.13 - script: ci/tests/run probe 2.13.1 - - name: test-scala @ scala-2.13 - script: ci/tests/run scala 2.13.1 - - stage: Release - name: Release - script: sbt ci-release diff --git a/build.sbt b/build.sbt index 7cf80643..ab93beba 100644 --- a/build.sbt +++ b/build.sbt @@ -202,7 +202,6 @@ lazy val scalaTests213 = scalaTests(scala213) .usesIdeaPlugin(scalaProbePlugin213) lazy val examples = testModule("examples", "examples") - .settings(libraryDependencies ++= Dependencies.junit5) .cross .dependsOn(driver, robotDriver, scalaProbeDriver) diff --git a/examples/src/test/resources/ideprobe.conf b/examples/src/test/resources/ideprobe.conf index e20619a5..26413981 100644 --- a/examples/src/test/resources/ideprobe.conf +++ b/examples/src/test/resources/ideprobe.conf @@ -5,9 +5,9 @@ probe { ] } endpoints.awaitIdle { - initialWait = "0 seconds" - newTaskWait = "1 second" - checkFrequency = "100 millis" + initialWait = "5 seconds" + newTaskWait = "2 second" + checkFrequency = "50 millis" } paths.screenshots = ${?IDEPROBE_SCREENSHOTS_DIR} } diff --git a/examples/src/test/resources/projects/dokka.conf b/examples/src/test/resources/projects/dokka.conf index a85dbca6..8e064a68 100644 --- a/examples/src/test/resources/projects/dokka.conf +++ b/examples/src/test/resources/projects/dokka.conf @@ -6,5 +6,5 @@ probe { modules { verify = ["dokka.core.main", "dokka.kotlin-analysis.main", "dokka.plugins.javadoc.main"] - test = ["dokka.integration-tests.gradle.integrationTest", "dokka.plugins.javadoc.test"] + test = ["dokka.integration-tests.cli.integrationTest", "dokka.plugins.javadoc.test"] } diff --git a/examples/src/test/scala/org/virtuslab/ideprobe/ModuleTest.scala b/examples/src/test/scala/org/virtuslab/ideprobe/ModuleTest.scala index 805e3c0b..1455f91c 100644 --- a/examples/src/test/scala/org/virtuslab/ideprobe/ModuleTest.scala +++ b/examples/src/test/scala/org/virtuslab/ideprobe/ModuleTest.scala @@ -1,73 +1,64 @@ package org.virtuslab.ideprobe -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.ValueSource +import org.junit.runner.RunWith +import org.junit.runners.Parameterized +import org.junit.runners.Parameterized.Parameters import org.junit.{Assert, Test} import org.virtuslab.ideprobe.Extensions._ +import org.virtuslab.ideprobe.dependencies.{IntelliJVersion, Plugin} import org.virtuslab.ideprobe.protocol._ import org.virtuslab.ideprobe.robot.RobotPluginExtension import org.virtuslab.ideprobe.scala.ScalaPluginExtension import org.virtuslab.ideprobe.scala.protocol.SbtProjectSettingsChangeRequest -class ModuleTest extends IdeProbeFixture with ScalaPluginExtension with RobotPluginExtension { +@RunWith(classOf[Parameterized]) +class ModuleTest(configName: String) extends IdeProbeFixture with ScalaPluginExtension with RobotPluginExtension { + registerFixtureTransformer(_.withAfterIntelliJStartup((fixture, intelliJ) => { + deleteIdeaSettings(intelliJ) + intelliJ.probe.withRobot.openProject(intelliJ.workspace) + useSbtShell(intelliJ) + })) - registerFixtureTransformer(_.withAfterIntelliJStartup((fixture, intelliJ) => { - deleteIdeaSettings(intelliJ) - intelliJ.probe.withRobot.openProject(intelliJ.workspace) - useSbtShell(intelliJ) - })) - - @ParameterizedTest - @ValueSource( - strings = Array( - "projects/io.conf", - "projects/librarymanagement.conf", - "projects/dokka.conf" - ) - ) - @Test def runTestsInDifferentScopes(configName: String): Unit = fixtureFromConfig(configName).run { intelliJ => - val runnerToSelect = intelliJ.config.get[String]("runner") - val modulesToTest = intelliJ.config[Seq[String]]("modules.test") - intelliJ.probe.build().assertSuccess() - modulesToTest.foreach { moduleName => - val scope = TestScope.Module(ModuleRef(moduleName)) - val result = intelliJ.probe.runTestsFromGenerated(scope, runnerToSelect) - Assert.assertTrue(s"Test result $result should not be empty", result.suites.nonEmpty) + @Test def verifyModulesPresent: Unit = fixtureFromConfig(configName).run { intelliJ => + val project = intelliJ.probe.projectModel() + val expectedModules = intelliJ.config[Seq[String]]("modules.verify") + val missingModules = expectedModules.diff(project.moduleNames) + Assert.assertTrue(s"Modules $missingModules are missing", missingModules.isEmpty) } - } - @ParameterizedTest - @ValueSource( - strings = Array( - "projects/io.conf", - "projects/librarymanagement.conf", - "projects/dokka.conf" - ) - ) - def verifyModulesPresent(configName: String): Unit = fixtureFromConfig(configName).run { intelliJ => - val project = intelliJ.probe.projectModel() - val expectedModules = intelliJ.config[Seq[String]]("modules.verify") - val missingModules = expectedModules.diff(project.moduleNames) - Assert.assertTrue(s"Modules $missingModules are missing", missingModules.isEmpty) - } + @Test def runTestsInDifferentScopes: Unit = fixtureFromConfig(configName).run { intelliJ => + val runnerToSelect = intelliJ.config.get[String]("runner") + val modulesToTest = intelliJ.config[Seq[String]]("modules.test") + intelliJ.probe.build().assertSuccess() + modulesToTest.foreach { moduleName => + val scope = TestScope.Module(ModuleRef(moduleName)) + val result = intelliJ.probe.runTestsFromGenerated(scope, runnerToSelect) + Assert.assertTrue(s"Test result $result should not be empty", result.suites.nonEmpty) + } + } - protected def useSbtShell(intelliJ: RunningIntelliJFixture): Unit = { - if (intelliJ.workspace.resolve("build.sbt").isFile) { - intelliJ.probe.setSbtProjectSettings( - SbtProjectSettingsChangeRequest( - useSbtShellForImport = Setting.Changed(true), - useSbtShellForBuild = Setting.Changed(true) + protected def useSbtShell(intelliJ: RunningIntelliJFixture): Unit = { + if (intelliJ.workspace.resolve("build.sbt").isFile) { + intelliJ.probe.setSbtProjectSettings( + SbtProjectSettingsChangeRequest( + useSbtShellForImport = Setting.Changed(true), + useSbtShellForBuild = Setting.Changed(true) + ) ) - ) + } } - } - /** - * The presence of .idea can prevent automatic import of gradle project - */ - private def deleteIdeaSettings(intelliJ: RunningIntelliJFixture): Unit = { - val path = intelliJ.workspace.resolve(".idea") - if (path.isDirectory) path.delete() - } + /** + * The presence of .idea can prevent automatic import of gradle project + */ + private def deleteIdeaSettings(intelliJ: RunningIntelliJFixture): Unit = { + val path = intelliJ.workspace.resolve(".idea") + if (path.isDirectory) path.delete() + } +} +object ModuleTest { + @Parameters(name = "{0}") def data: java.util.Collection[String] = { + java.util.Arrays.asList("projects/io.conf", "projects/librarymanagement.conf", "projects/dokka.conf") + } } diff --git a/project/CI.scala b/project/CI.scala index c3085638..cde1b7e4 100644 --- a/project/CI.scala +++ b/project/CI.scala @@ -4,7 +4,7 @@ import sbt.Keys.loadedBuild import sbt.{Def, ProjectRef, _} object CI { - private val excluded = Set("ci", "ide-probe", "ideprobe", "probe", "examples") + private val excluded = Set("ci", "ide-probe", "ideprobe", "probe") lazy val generateScripts = taskKey[Seq[File]]("Generate CI scripts") private def scalaVersionToModulePostfix(scalaVersion: String): String = @@ -12,6 +12,7 @@ object CI { def groupedProjects(scalaVersions: List[String]): Def.Initialize[Task[Map[String, Seq[ProjectRef]]]] = Def.task { val extensionDir = Paths.get(loadedBuild.value.root).resolve("extensions") + val examplesDir = Paths.get(loadedBuild.value.root).resolve("examples") val excludedCross = for { version <- scalaVersions module <- excluded @@ -23,6 +24,7 @@ object CI { case (_, project) => val projectPath = project.base.toPath if (projectPath.startsWith(extensionDir)) extensionDir.relativize(projectPath).getName(0).toString + else if (projectPath.startsWith(examplesDir)) "examples" else "probe" } .mapValues(_.map(_._1)) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index e48ce0d8..c76c54f1 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -29,11 +29,6 @@ object Dependencies { } ++ Seq(typesafeConfig, shapeless) } - val junit5 = Seq( - "org.junit.jupiter" % "junit-jupiter-params" % "5.4.2", - "net.aichler" % "jupiter-interface" % "0.8.3" % Test - ) - val intellijScala = "org.intellij.scala:2020.2.753:nightly" } From 82d84aebc75aa2f9b92d6b8b4145049898d69966 Mon Sep 17 00:00:00 2001 From: Michal Bednarz Date: Fri, 13 Nov 2020 13:52:14 +0100 Subject: [PATCH 2/2] Change timeout for test suites --- .github/workflows/release.yml | 1 - .github/workflows/test.yml | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a419c539..c9fc7c4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - 2020.3 tags: - '**' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 98ad349f..bb72c520 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,13 +4,25 @@ on: pull_request jobs: test: - timeout-minutes: 120 + timeout-minutes: 50 runs-on: ubuntu-latest name: test-${{ matrix.type }} strategy: matrix: - type: [probe 2.12.10, probe 2.13.1, scala 2.13.1, examples 2.13.1] + type: [probe 2.12.10, probe 2.13.1, scala 2.13.1] + steps: + - uses: actions/checkout@v2 + - name: generate scripts + run: sbt ci/generateScripts + - name: build image + run: sh ci/tests/build_image + - name: test + run: sh ci/tests/run ${{ matrix.type }} + examples: + timeout-minutes: 120 + runs-on: ubuntu-latest + name: test-examples 2.13.1 steps: - uses: actions/checkout@v2 - name: generate scripts @@ -18,4 +30,4 @@ jobs: - name: build image run: sh ci/tests/build_image - name: test - run: sh ci/tests/run ${{ matrix.type }} \ No newline at end of file + run: sh ci/tests/run examples 2.13.1 \ No newline at end of file