Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommunitySuite: add tests for spark versions #4358

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
matrix:
java: [ '11' ]
os: [windows-latest, ubuntu-latest]
group: [Scala2, Scala3, Other]
group: [Scala2, Scala3, Spark, Other]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ lazy val communityTestsScala3 = project
.in(file("scalafmt-tests-community/scala3")).settings(communityTestsSettings)
.enablePlugins(BuildInfoPlugin).dependsOn(communityTestsCommon)

lazy val communityTestsSpark = project
.in(file("scalafmt-tests-community/spark")).settings(communityTestsSettings)
.enablePlugins(BuildInfoPlugin).dependsOn(communityTestsCommon)

lazy val communityTestsOther = project
.in(file("scalafmt-tests-community/other")).settings(communityTestsSettings)
.enablePlugins(BuildInfoPlugin).dependsOn(communityTestsCommon)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.scalafmt.community.common

import org.scalafmt.config._
import org.scalafmt.sysops.OsSpecific

import java.nio.file._

import scala.collection.mutable.ListBuffer
import scala.concurrent.duration
import scala.sys.process._

Expand Down Expand Up @@ -60,22 +62,35 @@ abstract class CommunitySuite extends FunSuite {
try Files.createDirectories(communityProjectsDirectory)
catch { case _: FileAlreadyExistsException => }

val log = new StringBuilder
val logger = ProcessLogger(s => log.append(s).append('\n'))
val log = new ListBuffer[String]
val logger = ProcessLogger(log += _)

def runCmdRaw(cmd: String): Int = {
log.clear()
Console.err.println(s"Invoking command: $cmd")
cmd.!(logger)
}

def runCmd(cmd: String, what: => String): Unit = {
val result: Int = cmd.!(logger)
val result: Int = runCmdRaw(cmd)
assertEquals(
clue(result),
0,
s"Community build ${build.name}: $what failed:\n$log",
log.mkString(
s"Community build ${build.name}: $what failed:\n",
"\n",
"\n",
),
)
log.clear()
}

val folderPath = communityProjectsDirectory.resolve(build.name)
val folder = folderPath.toString

if (OsSpecific.isWindows)
if (0 != runCmdRaw("git config --global core.longpaths true"))
runCmd("git config --system core.longpaths true", "setting long paths")

if (!Files.exists(folderPath)) runCmd(
s"git clone --depth=1 --no-single-branch ${build.giturl} $folder",
"cloning",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.scalafmt.community.spark

import org.scalafmt.community.common.CommunityRepoSuite

import scala.meta._

abstract class CommunitySparkSuite(name: String)
extends CommunityRepoSuite("https://github.com/apache/spark.git", name)

class CommunitySpark3_4Suite extends CommunitySparkSuite("spark-3.4") {

override protected def builds =
Seq(getBuild("v3.4.1", dialects.Scala213, 2585))

}
Loading