diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 7515958b..844e0789 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -4,10 +4,6 @@ on: - master workflow_dispatch: - inputs: - branch: - description: 'Branch name' - required: true name: codecov @@ -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 diff --git a/tests/find_package_path.py b/tests/find_package_path.py new file mode 100644 index 00000000..23b3e253 --- /dev/null +++ b/tests/find_package_path.py @@ -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 '') \ No newline at end of file diff --git a/tests/run_tests.sh b/tests/run_tests.sh index fa6c947c..a43cdb2f 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -3,10 +3,12 @@ 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 @@ -14,7 +16,7 @@ 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 @@ -50,6 +52,7 @@ $PYCMD test_bugs.py $@ if [[ $COVERAGE -eq 1 ]]; then coverage combine coverage html + coverage xml fi