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

ci: add c++ coverage #45

Merged
merged 5 commits into from
Nov 9, 2023
Merged
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
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)
Loading