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

ENH: Set path to source for coverage tests #544

Closed
wants to merge 3 commits into from
Closed
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
11 changes: 6 additions & 5 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ on:
- master

workflow_dispatch:
inputs:
branch:
description: 'Branch name'
required: true

name: codecov

Expand All @@ -24,8 +20,13 @@ jobs:
- name: Install coverage
run: python -m pip install coverage

- name: Find installed package path
id: find_package_path
run: |
echo "PACKAGE_PATH=$(python tests/find_package_path.py)" >> $GITHUB_ENV

- name: Unit tests
run: tests/run_tests.sh -c
run: tests/run_tests.sh -c -s ${PACKAGE_PATH}

- name: Coveralls
uses: coverallsapp/github-action@v2
7 changes: 7 additions & 0 deletions tests/find_package_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import importlib.util

# This is used for CI scripts to find the location of the installed package

package_name = 'ants'
package_spec = importlib.util.find_spec(package_name)
print(package_spec.submodule_search_locations[0] if package_spec else '')
5 changes: 4 additions & 1 deletion tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ set -e

PYCMD=${PYCMD:="python3"}
COVERAGE=0
SOURCE="ants"
while [[ "$#" -gt 0 ]]; do
case "$1" in
-p|--python) PYCMD=$2; shift 2 ;;
-c|--coverage) COVERAGE=1; shift 1;;
-s|--source) SOURCE=$2; shift 2 ;;
--) shift; break ;;
*) echo "Invalid argument: $1!" ; exit 1 ;;
esac
done

if [[ $COVERAGE -eq 1 ]]; then
coverage erase
PYCMD="coverage run --parallel-mode --source ants "
PYCMD="coverage run --parallel-mode --source $SOURCE "
echo "coverage flag found. Setting command to: \"$PYCMD\""
fi

Expand Down Expand Up @@ -50,6 +52,7 @@ $PYCMD test_bugs.py $@
if [[ $COVERAGE -eq 1 ]]; then
coverage combine
coverage html
coverage xml
fi


Expand Down
Loading