-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from caleb-sitton-inl/coverage-github-action
Added code coverage tracking to github action
- Loading branch information
Showing
5 changed files
with
87 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
SCRIPT_DIRNAME=`dirname $0` | ||
HERON_DIR=`(cd $SCRIPT_DIRNAME/..; pwd)` | ||
cd $HERON_DIR | ||
RAVEN_DIR=`python -c 'from src._utils import get_raven_loc; print(get_raven_loc())'` | ||
|
||
source $HERON_DIR/coverage_scripts/initialize_coverage.sh | ||
|
||
#coverage help run | ||
SRC_DIR=`(cd src && pwd)` | ||
|
||
export COVERAGE_RCFILE="$SRC_DIR/../coverage_scripts/.coveragerc" | ||
SOURCE_DIRS=($SRC_DIR,$SRC_DIR/../templates/) | ||
OMIT_FILES=($SRC_DIR/dispatch/twin_pyomo_test.py,$SRC_DIR/dispatch/twin_pyomo_test_rte.py,$SRC_DIR/dispatch/twin_pyomo_limited_ramp.py,$SRC_DIR/ArmaBypass.py) | ||
EXTRA="--source=${SOURCE_DIRS[@]} --omit=${OMIT_FILES[@]} --parallel-mode " | ||
export COVERAGE_FILE=`pwd`/.coverage | ||
|
||
coverage erase | ||
($RAVEN_DIR/run_tests "$@" --re=HERON/tests --python-command="coverage run $EXTRA " || echo run_tests done but some tests failed) | ||
|
||
## Prepare data and generate the html documents | ||
coverage combine | ||
coverage html | ||
|
||
# See report_py_coverage.sh file for explanation of script separation | ||
(bash $HERON_DIR/coverage_scripts/report_py_coverage.sh --data-file=$COVERAGE_FILE --coverage-rc-file=$COVERAGE_RCFILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# To be run after a run of check_py_coverage.sh | ||
# This script has been separated from check_py_coverage.sh for the github action, so that | ||
# the output of run_tests within check_py_coverage.sh can be printed, but the report | ||
# value can be caught and put in an annotation. This is necessary because calling | ||
# "coverage report --format=total" directly in the yaml does not work | ||
|
||
SCRIPT_DIRNAME=`dirname $0` | ||
HERON_DIR=`(cd $SCRIPT_DIRNAME/..; pwd)` | ||
cd $HERON_DIR | ||
|
||
source coverage_scripts/initialize_coverage.sh > /dev/null 2>&1 | ||
|
||
# read command-line arguments | ||
ARGS=() | ||
for A in "$@" | ||
do | ||
case $A in | ||
--data-file=*) | ||
export COVERAGE_FILE="${A#--data-file=}" # Removes "--data-file=" and puts path into env variable | ||
;; | ||
--coverage-rc-file=*) | ||
export COVERAGE_RCFILE="${A#--coverage-rc-file=}" # See above | ||
;; | ||
*) | ||
ARGS+=("$A") | ||
;; | ||
esac | ||
done | ||
|
||
COV_VAL=`coverage report --format=total "${ARGS[@]}"` | ||
if [[ $COV_VAL = "No data to report." ]] | ||
then | ||
echo "Could not find data file with coverage results." | ||
exit 0 | ||
fi | ||
|
||
echo "Coverage for this repository is now $COV_VAL%." |