From 2883cace88ed3d6c29bbd40fc949f086015eb24f Mon Sep 17 00:00:00 2001 From: Matthew de Detrich Date: Wed, 2 Mar 2022 00:34:12 +0100 Subject: [PATCH] Add coverage --- .github/workflows/ci.yml | 8 +++++++- README.md | 1 + build.sbt | 16 ++++++++++++++++ project/plugins.sbt | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 694c8ca6..026125d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,4 +62,10 @@ jobs: run: sbt ++${{ matrix.scala }} githubWorkflowCheck - name: Build project - run: sbt ++${{ matrix.scala }} test + run: sbt ++${{ matrix.scala }} clean coverage test + + - name: Upload coverage data to Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: Scala ${{ matrix.scala }} + run: sbt ++${{ matrix.scala }} coverageReport coverageAggregate coveralls diff --git a/README.md b/README.md index bdf25042..74d65e93 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Build Status](https://github.com/aiven/guardian-for-apache-kafka/actions/workflows/ci.yml/badge.svg)](https://github.com/aiven/guardian-for-apache-kafka/actions) [![Apache License](https://img.shields.io/badge/license-APACHE_2-green.svg)](https://www.apache.org/licenses/LICENSE-2.0) +[![Coverage](https://coveralls.io/repos/github/aiven/guardian-for-apache-kafka/badge.svg?branch=main)](https://coveralls.io/github/aiven/guardian-for-apache-kafka?branch=main) # Guardian for Apache Kafka® diff --git a/build.sbt b/build.sbt index 6392540e..468d9b00 100644 --- a/build.sbt +++ b/build.sbt @@ -287,6 +287,22 @@ ThisBuild / githubWorkflowEnv ++= Map( ThisBuild / githubWorkflowJavaVersions := List(JavaSpec.temurin("11")) +ThisBuild / githubWorkflowBuild := Seq( + WorkflowStep.Sbt(List("clean", "coverage", "test"), name = Some("Build project")) +) + +ThisBuild / githubWorkflowBuildPostamble ++= Seq( + // See https://github.com/scoverage/sbt-coveralls#github-actions-integration + WorkflowStep.Sbt( + List("coverageReport", "coverageAggregate", "coveralls"), + name = Some("Upload coverage data to Coveralls"), + env = Map( + "COVERALLS_REPO_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}", + "COVERALLS_FLAG_NAME" -> "Scala ${{ matrix.scala }}" + ) + ) +) + import ReleaseTransformations._ releaseCrossBuild := true diff --git a/project/plugins.sbt b/project/plugins.sbt index 88c513fb..38f111ef 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,3 +5,5 @@ addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") +addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.1")