From 219228b7c3c4aabab1b2bf9f2474229f97752175 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Tue, 26 May 2026 12:54:12 +0200 Subject: [PATCH] Enforce scalafmt in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a dedicated GitHub Actions job that runs scalafmtCheckAll + scalafmtSbtCheck on every PR, modeled on the existing mima job. Without enforcement, formatter drift accumulates silently — increasingly relevant as AI-assisted edits land in the repo. Bundles supersedes of scala-steward PRs #845 (sbt-scalafmt 2.6.0 -> 2.6.1) and #846 (scalafmt-core 3.11.0 -> 3.11.1), since the new check would otherwise fail on master against the one file #846 reformats. --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++++++ project/Commons.scala | 10 +++++++++ 2 files changed, 54 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbde23912..b0ae9f9d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,3 +169,47 @@ jobs: - name: Check binary compatibility run: sbt mimaReportBinaryIssues + + scalafmt: + name: Scalafmt Check + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.18] + java: [temurin@21] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 17 + cache: sbt + + - name: Setup Java (temurin@21) + if: matrix.java == 'temurin@21' + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 21 + cache: sbt + + - name: Setup Java (temurin@25) + if: matrix.java == 'temurin@25' + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 25 + cache: sbt + + - name: Setup sbt + uses: sbt/setup-sbt@v1 + + - name: Check Scala formatting + run: sbt scalafmtCheckAll scalafmtSbtCheck diff --git a/project/Commons.scala b/project/Commons.scala index 1f214995d..ec5db4e41 100644 --- a/project/Commons.scala +++ b/project/Commons.scala @@ -85,6 +85,16 @@ object Commons extends ProjectGroup("commons") { name = Some("Check binary compatibility"), ), ), + githubWorkflowAddedJobs += WorkflowJob( + id = "scalafmt", + name = "Scalafmt Check", + scalas = List(scalaVersion.value), + javas = List(JavaSpec.temurin("21")), + steps = githubWorkflowJobSetup.value.toList :+ WorkflowStep.Sbt( + List("scalafmtCheckAll", "scalafmtSbtCheck"), + name = Some("Check Scala formatting"), + ), + ), githubWorkflowBuildPreamble ++= Seq( WorkflowStep.Use( UseRef.Public("actions", "setup-node", "v4"),