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"),