diff --git a/bin/gencovg b/bin/gencovg new file mode 100755 index 0000000000..7d606b0b5a --- /dev/null +++ b/bin/gencovg @@ -0,0 +1,25 @@ +#!/bin/bash -e + +function emit_file_url() { + 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 + +emit_file_url pubber pubber/build/jacocoHtml/index.html +emit_file_url validator validator/build/jacocoHtml/index.html diff --git a/pubber/bin/build b/pubber/bin/build index 7eef9b55fc..8c81eae180 100755 --- a/pubber/bin/build +++ b/pubber/bin/build @@ -1,16 +1,23 @@ #!/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 @@ -18,7 +25,7 @@ fi echo Building pubber in $PWD rm -rf build -./gradlew shadow $check +./gradlew shadow $check $covg ls -l $jarfile diff --git a/pubber/build.gradle b/pubber/build.gradle index 143464553a..b11a5b372a 100644 --- a/pubber/build.gradle +++ b/pubber/build.gradle @@ -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' } @@ -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 diff --git a/validator/bin/build b/validator/bin/build index 9d2874d3ea..2b39aa394c 100755 --- a/validator/bin/build +++ b/validator/bin/build @@ -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=.. @@ -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 @@ -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 diff --git a/validator/build.gradle b/validator/build.gradle index 36b4a64062..98cfe31dc1 100644 --- a/validator/build.gradle +++ b/validator/build.gradle @@ -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' } @@ -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