diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3652df8..84f830f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,7 +55,7 @@ jobs: channel-priority: true - name: install build deps - run: mamba install scip gurobi + run: mamba install scip gurobi gcovr - name: add gurobi license shell: bash @@ -70,17 +70,23 @@ jobs: run: | python -m pip install -U pip python -m pip install -e .[dev] + python setup.py build_ext --inplace # required for C coverage env: CYTHON_TRACE: 1 # enable coverage of cython code + CFLAGS: '-coverage' # enable coverage of C code - name: run tests - run: pytest --color yes -v --cov ilpy --cov-report=xml + run: | + pytest --color yes -v --cov ilpy --cov-report=xml + gcovr --xml coverage_cpp.xml # generate C coverage report env: GRB_LICENSE_FILE: ${{ steps.write-license.outputs.grb_license_file }} - name: upload coverage uses: codecov/codecov-action@v3 - + with: + files: ./coverage.xml,./coverage_cpp.xml + # we only deploy the sdist to PyPI, the wheel is still complicated deploy-sdist: if: startsWith(github.ref, 'refs/tags') diff --git a/.gitignore b/.gitignore index 95ae813..24b06bf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ ilpy/wrapper.cpp build dist .vscode +coverage.xml +coverage_cpp.xml diff --git a/setup.py b/setup.py index 306cdd3..0a7e311 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools.extension import Extension # enable test coverage tracing if CYTHON_TRACE is set to a non-zero value -CYTHON_TRACE = int(os.getenv("CYTHON_TRACE", "0") not in ("0", "False")) +CYTHON_TRACE = int(os.getenv("CYTHON_TRACE") in ("1", "True")) libraries = ["libscip"] if os.name == "nt" else ["scip"] include_dirs = ["ilpy/impl"] diff --git a/tests/test_constraint.py b/tests/test_constraint.py new file mode 100644 index 0000000..a05bcfc --- /dev/null +++ b/tests/test_constraint.py @@ -0,0 +1,7 @@ +import ilpy + + +def test_constraint() -> None: + constraint = ilpy.Constraint() + constraint.set_coefficient(0, 1) + constraint.set_quadratic_coefficient(1, 1, 1)