Skip to content

Commit

Permalink
Merge 488edbf into 0b0fec6
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMartins committed Mar 27, 2021
2 parents 0b0fec6 + 488edbf commit f004496
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ jobs:
apps: bloop
- run: ./.github/scripts/setup.sh
- run: sbt runExamples
communityTests:
name: Community projects tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
- uses: laughedelic/coursier-setup@v1
with:
jvm: adopt:8
apps: bloop
- run: ./.github/scripts/setup.sh
- run: sbt "runCommunityProjects spire"
scalaTests:
name: Run Tests Matrix
runs-on: ubuntu-latest
Expand Down
15 changes: 13 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ lazy val docs =
)
.dependsOn(core)

lazy val runCurrent = inputKey[Unit]("Run current blinky version on itself")
lazy val runExamples = inputKey[Unit]("Run examples tests")
lazy val runCurrent =
inputKey[Unit]("Run current blinky version on itself")
lazy val runExamples =
inputKey[Unit]("Run example projects to test blinky")
lazy val runCommunityProjects =
inputKey[Unit]("Run community scala projects to test blinky regressions")

runCurrent := {
val a = (core / publishLocal).value
Expand All @@ -157,3 +161,10 @@ runExamples := {
val args: Array[String] = spaceDelimited("<arg>").parsed.toArray
RunExamples.run(version.value, args)
}

runCommunityProjects := {
val a = (core / publishLocal).value
val b = (cli / publishLocal).value
val args: Array[String] = spaceDelimited("<arg>").parsed.toArray
RunCommunityProjects.run(version.value, args)
}
55 changes: 55 additions & 0 deletions project/RunCommunityProjects.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import ammonite.ops._
import os.copy

object RunCommunityProjects {

private case class Project(url: String, folderName: String, blinkyConf: String)

private def defaultBlinkyConf(projectName: String): String =
s"""projectPath = "."
|projectName = "$projectName"
|filesToMutate = "core/src/main"
|""".stripMargin

private val pluginsText = """addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.8")"""

private val projects: Map[String, Project] =
Map(
"spire" -> Project(
"https://github.com/typelevel/spire.git",
"spire",
defaultBlinkyConf("testsJVM")
)
)

def run(versionNumber: String, projectsToRun: Array[String]): Unit =
projectsToRun.foreach { projectToRun =>
projects.get(projectToRun) match {
case None =>
Console.err.println(s"Project not found: $projectToRun")
case Some(project) =>
println(s"Testing $projectToRun project:")
testProject(versionNumber, project)
}
}

private def testProject(versionNumber: String, project: Project): Unit = {
val tempPath: Path = tmp.dir()
%("git", "clone", project.url)(tempPath)
val projectPath = tempPath / project.folderName

write(projectPath / ".blinky.conf", project.blinkyConf)

write.append(projectPath / "project" / "plugins.sbt", pluginsText)

%(
"cs",
"launch",
s"com.github.rcmartins:blinky-cli_2.12:$versionNumber",
"--",
"--verbose=true",
"--dryRun=true"
)(projectPath)
}

}
5 changes: 1 addition & 4 deletions project/RunExamples.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,12 @@ object RunExamples {
println(msg)
println("-" * msg.length)

val confPath = examplePath / ".blinky.conf"
val result = %%(
"cs",
"launch",
s"com.github.rcmartins:blinky-cli_2.12:$versionNumber",
"--",
confPath,
"--verbose",
"true"
"--verbose=true"
)(examplePath)
println(result.out.string)

Expand Down

0 comments on commit f004496

Please sign in to comment.