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

Generate code coverage reports locally #537

Merged
merged 9 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
25 changes: 25 additions & 0 deletions bin/gencovg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
johnrandolph marked this conversation as resolved.
Show resolved Hide resolved

function emitfileurl() {
johnrandolph marked this conversation as resolved.
Show resolved Hide resolved
local report="$1"
local path="$2"
local fullpath=$(realpath ${ROOT})
echo "Coverage Report"
echo " ${name}"
if [[ -f "${fullpath}/${path}" ]]; then
echo " file://${fullpath}/${path}"
else
echo " Missing ${path}"
fi
echo
}

ROOT=$(dirname $0)/..
BASE=..
cd $ROOT

pubber/bin/build covg
validator/bin/build covg

emitfileurl pubber pubber/build/jacocoHtml/index.html
emitfileurl validator validator/build/jacocoHtml/index.html
15 changes: 11 additions & 4 deletions pubber/bin/build
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
#!/bin/bash -e

if [[ $1 == check ]]; then
while [[ $# -gt 0 ]]; do
if [[ "$1" == "check" ]]; then
check=check
shift
fi
elif [[ "$1" == "covg" ]]; then
covg=jacocoTestReport
shift
else
break
fi
done

rundir=$(dirname $0)
cd $rundir/..

newest=$(ls -rt `find src/ ../gencode/java -type f` | tail -n 1)
jarfile=build/libs/pubber-1.0-SNAPSHOT-all.jar
if [[ -z $check && -f $jarfile && $jarfile -nt $newest ]]; then
if [[ -z $check && -z $covg && -f $jarfile && $jarfile -nt $newest ]]; then
echo $jarfile up to date, skipping build.
exit 0
fi

echo Building pubber in $PWD

rm -rf build
./gradlew shadow $check
./gradlew shadow $check $covg

ls -l $jarfile

Expand Down
12 changes: 12 additions & 0 deletions pubber/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.adarshr.test-logger' version '3.2.0'
id 'java'
id 'jacoco'
id 'checkstyle'
}

Expand All @@ -36,6 +37,17 @@ sourceSets {
}
}

jacocoTestReport {
dependsOn test
reports {
xml.required = true
csv.required = false
html.outputLocation = layout.BuildDirectory.dir('jacocoHtml')
}
}

// TODO(future): jacocoTestCoverageVerification

checkstyle {
ignoreFailures = false
maxWarnings = 0
Expand Down
15 changes: 11 additions & 4 deletions validator/bin/build
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/bash -e

if [[ $1 == check ]]; then
while [[ $# -gt 0 ]]; do
if [[ "$1" == "check" ]]; then
check=check
shift
fi
elif [[ "$1" == "covg" ]]; then
covg=jacocoTestReport
shift
else
break
fi
done

ROOT=$(dirname $0)/..
BASE=..
Expand All @@ -12,7 +19,7 @@ cd $ROOT
jarfile=build/libs/validator-1.0-SNAPSHOT-all.jar

newest=$(ls -rt `find src/ $BASE/gencode/java -type f` | tail -n 1)
if [[ -z $check && -f $jarfile && $jarfile -nt $newest ]]; then
if [[ -z $check && -z $covg && -f $jarfile && $jarfile -nt $newest ]]; then
echo $jarfile up-to-date, skipping build.
exit 0
fi
Expand All @@ -22,7 +29,7 @@ export JAVA_HOME=$JAVA_HOME_11_X64
echo Building validator in $PWD

rm -rf build
./gradlew shadow $check $*
./gradlew shadow $check $covg $*

ls -l $jarfile

Expand Down
16 changes: 16 additions & 0 deletions validator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.adarshr.test-logger' version '3.2.0'
id 'java'
id 'jacoco'
id 'checkstyle'
}

Expand All @@ -36,6 +37,21 @@ sourceSets {
}
}

test {
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.required = true
csv.required = false
html.outputLocation = layout.BuildDirectory.dir('jacocoHtml')
}
}

// TODO(future): jacocoTestCoverageVerification

checkstyle {
ignoreFailures = false
maxWarnings = 0
Expand Down