From af039d94c722347bec8840c9ed0388d02b6ad411 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sat, 28 Sep 2024 07:23:55 -0700 Subject: [PATCH 1/2] CommunitySuite: set longpaths for git on Windows --- .../community/common/CommunitySuite.scala | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala b/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala index 5871b2614..ee15e447c 100644 --- a/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala +++ b/scalafmt-tests-community/common/src/main/scala/org/scalafmt/community/common/CommunitySuite.scala @@ -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._ @@ -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", From 7768c333e4da8485c38ca0bd8fffe2198c10b9d7 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:00:47 -0700 Subject: [PATCH 2/2] CommunitySuite: add test for spark version 3.4.1 --- .github/workflows/ci.yml | 2 +- build.sbt | 4 ++++ .../community/spark/CommunitySparkSuite.scala | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e19cc014f..0197fb912 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/build.sbt b/build.sbt index f9ebc8285..fbc0d143b 100644 --- a/build.sbt +++ b/build.sbt @@ -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) diff --git a/scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala b/scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala new file mode 100644 index 000000000..0ac2da99b --- /dev/null +++ b/scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala @@ -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)) + +}