Skip to content

Commit

Permalink
Enable examples in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bednarz committed Nov 23, 2020
1 parent e1ef66b commit 6dc14a5
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 99 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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 }}
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions examples/src/test/resources/ideprobe.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
2 changes: 1 addition & 1 deletion examples/src/test/resources/projects/dokka.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
101 changes: 46 additions & 55 deletions examples/src/test/scala/org/virtuslab/ideprobe/ModuleTest.scala
Original file line number Diff line number Diff line change
@@ -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")
}
}
4 changes: 3 additions & 1 deletion project/CI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ 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 =
scalaVersion.split("\\.").dropRight(1).mkString("_")

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
Expand All @@ -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))
Expand Down
5 changes: 0 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

0 comments on commit 6dc14a5

Please sign in to comment.