Skip to content

Commit 36498a0

Browse files
committed
Try tricking code coverage another way
1 parent 4840c80 commit 36498a0

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,10 @@ jobs:
9797
uv-dependency-install-flags: "--all-extras --group tests"
9898
- name: Run tests
9999
run: |
100-
rm -r src/example_fgen_basic
101-
ln -s .venv/lib/python3.11/site-packages/example_fgen_basic src/example_fgen_basic
102-
uv run --no-sync pytest -r a -v tests src --doctest-modules --doctest-report ndiff --cov=src --cov-report=term-missing --cov-report=xml
100+
101+
COV_DIR=`uv run --no-sync python -c 'from pathlib import Path; import example_fgen_basic; print(Path(example_fgen_basic.__file__).parent)'`
102+
uv run --no-sync pytest -r a -v tests src --doctest-modules --doctest-report ndiff --cov=${COV_DIR} --cov-report=term-missing --cov-report=xml
103103
uv run --no-sync coverage report
104-
# Just in case, undo the changes to `src`
105-
rm -r src/example_fgen_basic
106-
git restore --staged . && git restore .
107104
- name: Upload coverage reports to Codecov with GitHub Action
108105
uses: codecov/codecov-action@v4.2.0
109106
env:

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
TEMP_FILE := $(shell mktemp)
77
# Directory in which to build the Fortran when using a standalone build
88
BUILD_DIR := build
9+
# Coverage directory - needed to trick code cov to look in the right place
10+
COV_DIR := $(shell uv run --no-sync python -c 'from pathlib import Path; import example_fgen_basic; print(Path(example_fgen_basic.__file__).parent)')
911

1012
# A helper script to get short descriptions of each target in the Makefile
1113
define PRINT_HELP_PYSCRIPT
@@ -49,7 +51,7 @@ test: ## run the tests (re-installs the package every time so you might want to
4951
# because it is looking for lines in `src` to be run,
5052
# but they're not because lines in `.venv` are run instead.
5153
# We don't have a solution to this yet.
52-
uv run --no-editable --reinstall-package example-fgen-basic pytest -r a -v -tests src -doctest-modules --doctest-report ndiff --cov=src
54+
uv run --no-editable --reinstall-package example-fgen-basic pytest -r a -v tests src --doctest-modules --doctest-report ndiff --cov=$(COV_DIR)
5355

5456
# Note on code coverage and testing:
5557
# You must specify cov=src.

0 commit comments

Comments
 (0)