Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Codecoverage Upload (Jacoco/Codecov) #1981

Merged
merged 6 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max age is 1h? seems like maybe that should be longer no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with whatever. Although github also does their own caching so it's probably a bit irrelevant

[![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\""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no references to this variable while searching through the codebase. I don't think it's used anymore


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)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have the bash flags that print out commands before they are run so this isn't really needed

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"
Comment on lines -40 to +30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have bash flags to fail-fast so we don't explicitly need to collect exit codes