Skip to content

Commit

Permalink
ci: add c++ coverage (#45)
Browse files Browse the repository at this point in the history
* ci: add c++ coverage

* ci: add c++ coverage

* add gitignore

* remove coverage

* force
  • Loading branch information
tlambert03 authored Nov 9, 2023
1 parent d1fb38d commit 3385d84
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ ilpy/wrapper.cpp
build
dist
.vscode
coverage.xml
coverage_cpp.xml
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
7 changes: 7 additions & 0 deletions tests/test_constraint.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 3385d84

Please sign in to comment.