diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21cad3e57..20b5d0436 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,22 +73,26 @@ jobs: - name: Check that workflows are up to date run: sbt githubWorkflowCheck - - name: Build project - if: matrix.scala == '2.13' && matrix.java == 'corretto@11' - run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' coverage test coverageAggregate + - name: Check headers and formatting + if: matrix.java == 'corretto@17' && matrix.os == 'ubuntu-latest' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck - - name: Upload coverage report - if: matrix.scala == '2.13' && matrix.java == 'corretto@11' - run: 'bash <(curl -s https://codecov.io/bash)' - - - name: Build project - if: '!(matrix.scala == ''2.13'' && matrix.java == ''corretto@11'' || matrix.scala == ''3'')' + - name: Test + if: '!(matrix.scala == ''3'')' run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' test - - name: Build project + - name: Test if: matrix.scala == '3' run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' shared/test test/test + - name: Check binary compatibility + if: '!(matrix.scala == ''3'')' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' mimaReportBinaryIssues + + - name: Generate API documentation + if: '!(matrix.scala == ''3'')' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc + - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') run: mkdir -p refined/target shared/target tensorflow/target parquet/target tools/target protobuf/target jmh/target bigquery/target avro/target scalacheck/target datastore/target neo4j/target cats/target bigtable/target guava/target project/target @@ -270,13 +274,13 @@ jobs: - run: scala-steward validate-repo-config .scala-steward.conf - avro-legacy: - name: Test with legacy avro + coverage: + name: Test coverage strategy: matrix: os: [ubuntu-latest] - scala: [2.13.12] - java: [corretto@11] + scala: [2.13] + java: [corretto@17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -297,20 +301,40 @@ jobs: if: matrix.java == 'corretto@17' && steps.setup-java-corretto-17.outputs.cache-hit == 'false' run: sbt +update - - name: Setup Java (corretto@11) - id: setup-java-corretto-11 - if: matrix.java == 'corretto@11' + - name: Test coverage + run: sbt '++ ${{ matrix.scala }}' coverage test coverageAggregate + + - name: Upload coverage report + run: 'bash <(curl -s https://codecov.io/bash)' + + avro-legacy: + name: Test with legacy avro + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13] + java: [corretto@17] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Java (corretto@17) + id: setup-java-corretto-17 + if: matrix.java == 'corretto@17' uses: actions/setup-java@v3 with: distribution: corretto - java-version: 11 + java-version: 17 cache: sbt - name: sbt update - if: matrix.java == 'corretto@11' && steps.setup-java-corretto-11.outputs.cache-hit == 'false' + if: matrix.java == 'corretto@17' && steps.setup-java-corretto-17.outputs.cache-hit == 'false' run: sbt +update - - name: Build project + - name: Test env: JAVA_OPTS: '-Davro.version=1.8.2' run: sbt '++ ${{ matrix.scala }}' avro/test diff --git a/bigquery/src/test/scala/magnolify/bigquery/TimestampConverterSuite.scala b/bigquery/src/test/scala/magnolify/bigquery/TimestampConverterSuite.scala index fe943ebb1..e7ffa8dee 100644 --- a/bigquery/src/test/scala/magnolify/bigquery/TimestampConverterSuite.scala +++ b/bigquery/src/test/scala/magnolify/bigquery/TimestampConverterSuite.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2023 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package magnolify.bigquery import scala.util.control.NonFatal diff --git a/build.sbt b/build.sbt index dc33ee164..66fc224ba 100644 --- a/build.sbt +++ b/build.sbt @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import sbt._ import sbtprotoc.ProtocPlugin.ProtobufConfig import com.typesafe.tools.mima.core._ @@ -108,11 +109,8 @@ val scalaDefault = scala213 // github actions val java17 = JavaSpec.corretto("17") val java11 = JavaSpec.corretto("11") -val javaDefault = java11 -val coverageCond = Seq( - s"matrix.scala == '${CrossVersion.binaryScalaVersion(scalaDefault)}'", - s"matrix.java == '${javaDefault.render}'" -).mkString(" && ") +val javaDefault = java17 + val scala3Cond = "matrix.scala == '3'" val scala3Projects = List( "shared", @@ -122,40 +120,64 @@ ThisBuild / scalaVersion := scalaDefault ThisBuild / crossScalaVersions := Seq(scala3, scala213, scala212) ThisBuild / githubWorkflowTargetBranches := Seq("main") ThisBuild / githubWorkflowJavaVersions := Seq(java17, java11) -ThisBuild / githubWorkflowBuild := Seq( - WorkflowStep.Sbt( - List("coverage", "test", "coverageAggregate"), - name = Some("Build project"), - cond = Some(coverageCond) - ), - WorkflowStep.Run( - List("bash <(curl -s https://codecov.io/bash)"), - name = Some("Upload coverage report"), - cond = Some(coverageCond) - ), - WorkflowStep.Sbt( - List("test"), - name = Some("Build project"), - cond = Some(s"!($coverageCond || $scala3Cond)") - ), - WorkflowStep.Sbt( - scala3Projects.map(p => s"$p/test"), - name = Some("Build project"), - cond = Some(scala3Cond) - ) -) +ThisBuild / tlCiHeaderCheck := true +ThisBuild / tlCiScalafmtCheck := true +ThisBuild / tlCiDocCheck := true +ThisBuild / tlCiMimaBinaryIssueCheck := true +ThisBuild / githubWorkflowBuild ~= { steps: Seq[WorkflowStep] => + steps.flatMap { + case s if s.name.contains("Test") => + Seq( + s.withCond(Some(s"!($scala3Cond)")), + WorkflowStep.Sbt( + scala3Projects.map(p => s"$p/test"), + name = Some("Test"), + cond = Some(scala3Cond) + ) + ) + case s => + if ( + s.name.contains("Check binary compatibility") || + s.name.contains("Generate API documentation") + ) { + Seq(s.withCond(Some(s"!($scala3Cond)"))) + } else { + Seq(s) + } + } +} ThisBuild / githubWorkflowAddedJobs ++= Seq( + WorkflowJob( + "coverage", + "Test coverage", + WorkflowStep.CheckoutFull :: + WorkflowStep.SetupJava(List(javaDefault)) ::: + List( + WorkflowStep.Sbt( + List("coverage", "test", "coverageAggregate"), + name = Some("Test coverage") + ), + WorkflowStep.Run( + List("bash <(curl -s https://codecov.io/bash)"), + name = Some("Upload coverage report") + ) + ), + scalas = List(CrossVersion.binaryScalaVersion(scalaDefault)), + javas = List(javaDefault) + ), WorkflowJob( "avro-legacy", "Test with legacy avro", - githubWorkflowJobSetup.value.toList ::: List( - WorkflowStep.Sbt( - List("avro/test"), - env = Map("JAVA_OPTS" -> "-Davro.version=1.8.2"), - name = Some("Build project") - ) - ), - scalas = List(scalaDefault), + WorkflowStep.CheckoutFull :: + WorkflowStep.SetupJava(List(javaDefault)) ::: + List( + WorkflowStep.Sbt( + List("avro/test"), + env = Map("JAVA_OPTS" -> "-Davro.version=1.8.2"), + name = Some("Test") + ) + ), + scalas = List(CrossVersion.binaryScalaVersion(scalaDefault)), javas = List(javaDefault) ) )