Skip to content

Commit

Permalink
Move coverage out of default ci pipeline (#872)
Browse files Browse the repository at this point in the history
* Move coverage out of default ci pipeline

Coverage should not ge in default build pipline as the produced artifact
is published directly. Published library MUST not contain instrumented
bytecode.

* Remove coverage filtering

* Use binary scala versions only

* Alter githubWorkflowBuild instead of override

* Add missing header file

* Disable scala3 mima check

* Disable mima for non scala3

* Disable doc for not scala3

* Remove useless steps
  • Loading branch information
RustedBones authored Dec 6, 2023
1 parent ec35739 commit 0c6d347
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 55 deletions.
64 changes: 44 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
92 changes: 57 additions & 35 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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._

Expand Down Expand Up @@ -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",
Expand All @@ -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)
)
)
Expand Down

0 comments on commit 0c6d347

Please sign in to comment.