Skip to content

Commit

Permalink
Enable Codecoverage Upload (Jacoco/Codecov) (#1981)
Browse files Browse the repository at this point in the history
* (squash) draft implementation

another miscopy typo

typo in dirname

feed cobertura.xml into codecov instead of scoverage.xml

specify files due to autodetect failure

use coverageAggregate instead of coverageReport

load default codecov behaviour into codecov.yml

typo

draft impl

* add changes to codecov.yml

* (squash) don't upload to codecov when there is nothing to upload

* (squash) use jacoco instead of scoverage

autodetect on codecov uploader seems to work

new bash features not supported on CI

try using jacoco

* update README with codecov link

* try adding some retry to the codecov uploader
  • Loading branch information
daniel-sudz authored Mar 26, 2022
1 parent 525321c commit 3d63170
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 22 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,34 @@ jobs:
run: |
mkdir -p /home/runner/.ivy2/cache/ # some scripts assume that this folder exists
${{ matrix.script }}
# this is a poor man's retry since apparently github actions does not support this in 2022
# https://git.luolix.topmunity/t/how-to-retry-a-failed-step-in-github-actions-workflow/125880
# we give the codecov uploader 3 attempts before aborting since it's sometimes flaky
# https://github.com/codecov/codecov-action/issues/598 maybe this will be fixed in the action itself sometime
- uses: codecov/codecov-action@v2.1.0
if: ${{ matrix.TEST_TARGET != null && matrix.TEST_TARGET != '' }} # for some external tests like scald.rb repl we are not able to easily collect coverage info
continue-on-error: true
id: code-cov-attempt-1
with:
name: codecov
verbose: true
version: "v0.1.15" # some people claim 0.1.15 is more stable (https://github.com/codecov/codecov-action/issues/598#issuecomment-1030074427)
fail_ci_if_error: true
- uses: codecov/codecov-action@v2.1.0
id: code-cov-attempt-2
continue-on-error: true
if: ${{ matrix.TEST_TARGET != null && matrix.TEST_TARGET != '' && steps.code-cov-attempt-1.outcome=='failure' }}
with:
name: codecov
verbose: true
version: "v0.1.15"
fail_ci_if_error: true
- uses: codecov/codecov-action@v2.1.0
id: code-cov-attempt-3
if: ${{ matrix.TEST_TARGET != null && matrix.TEST_TARGET != '' && steps.code-cov-attempt-2.outcome=='failure' }}
with:
name: codecov
verbose: true
version: "v0.1.15"
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Scalding

[![Build status](https://github.com/twitter/scalding/actions/workflows/CI.yml/badge.svg?branch=develop)](https://github.com/twitter/scalding/actions)
[![Coverage Status](https://coveralls.io/repos/twitter/scalding/badge.png?branch=develop)](https://coveralls.io/r/twitter/scalding?branch=develop)
[![Coverage Status](https://img.shields.io/codecov/c/github/twitter/scalding/develop.svg?maxAge=3600)](https://codecov.io/github/twitter/scalding)
[![Latest version](https://index.scala-lang.org/twitter/scalding/scalding-core/latest.svg?color=orange)](https://index.scala-lang.org/twitter/scalding/scalding-core)
[![Chat](https://badges.gitter.im/twitter/scalding.svg)](https://gitter.im/twitter/scalding?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
8 changes: 8 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ val sharedSettings = Seq(
case _ => Seq()
},

// Code coverage options
jacocoReportSettings := JacocoReportSettings(
"Jacoco Coverage Report",
None,
JacocoThresholds(),
Seq(JacocoReportFormats.ScalaHTML, JacocoReportFormats.XML),
"utf-8"),

// Enables full stack traces in scalatest
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oF"),

Expand Down
25 changes: 25 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# note that if an org-wide global config is configured, it will be merged (with duplicate settings taking priority from this file)
# it's better to explicitly set all configs if you want consistency

codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "0...100" # acceptable coverage range

# default behaviour
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

# can be configured in https://docs.codecov.com/docs/pull-request-comments
comment:
layout: "reach,diff,flags,files,footer"
behavior: default
require_changes: no
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2")
addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.16")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.22")
26 changes: 6 additions & 20 deletions scripts/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,27 @@
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
cd $BASE_DIR

export JVM_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:ReservedCodeCacheSize=96m -XX:+TieredCompilation -XX:MaxPermSize=256m -Xms256m -Xmx512m -Xss2m"


INNER_JAVA_OPTS="set javaOptions += \"-Dlog4j.configuration=file://$TRAVIS_BUILD_DIR/project/travis-log4j.properties\""

withCmd() {
CMD=$1
for t in $TEST_TARGET; do echo -n "; $t/$CMD "; done
}

bash -c "while true; do echo -n .; sleep 5; done" &

echo "running..."

echo time ./sbt -Dhttp.keepAlive=false -Dsbt.repository.secure=true ++$TRAVIS_SCALA_VERSION "$(withCmd "test:compile")"
export JVM_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:ReservedCodeCacheSize=168m -XX:+TieredCompilation -XX:MaxPermSize=256m -Xms512m -Xmx1500m -Xss8m"
# collecting code coverage has a fairly high memory pressure
export JVM_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:ReservedCodeCacheSize=128m -XX:+TieredCompilation -XX:MaxPermSize=256m -Xms512m -Xmx2g -Xss8m"

echo "Running test compilation..."
time ./sbt -Dhttp.keepAlive=false -Dsbt.repository.secure=true ++$TRAVIS_SCALA_VERSION "$(withCmd "test:compile")"

export JVM_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:ReservedCodeCacheSize=128m -XX:+TieredCompilation -XX:MaxPermSize=256m -Xms256m -Xmx768m -Xss2m"
echo "calling ... "
echo "time ./sbt ++$TRAVIS_SCALA_VERSION $(withCmd test)"
time ./sbt -Dhttp.keepAlive=false -Dsbt.repository.secure=true ++$TRAVIS_SCALA_VERSION "$(withCmd test)"
echo "Running test suite"
time ./sbt -Dhttp.keepAlive=false -Dsbt.repository.secure=true ++$TRAVIS_SCALA_VERSION "$(withCmd test)" jacocoReport
TST_EXIT_CODE=$?

echo "Running mima checks ... "
echo "time ./sbt ++$TRAVIS_SCALA_VERSION $(withCmd mimaReportBinaryIssues)"
time ./sbt -Dhttp.keepAlive=false -Dsbt.repository.secure=true ++$TRAVIS_SCALA_VERSION "$(withCmd mimaReportBinaryIssues)"
MIMA_EXIT_CODE=$?

echo "Running compile:doc ... "
echo "time ./sbt ++$TRAVIS_SCALA_VERSION $(withCmd compile:doc)"
time ./sbt -Dhttp.keepAlive=false -Dsbt.repository.secure=true ++$TRAVIS_SCALA_VERSION "$(withCmd compile:doc)"
COMPILE_DOC_EXIT_CODE=$?

echo "all done"

exit $(( $TST_EXIT_CODE || $MIMA_EXIT_CODE || $COMPILE_DOC_EXIT_CODE ))
echo "all test checks done"

0 comments on commit 3d63170

Please sign in to comment.