From 57909f2630c376900022a19a3cdce61b20ad9abd Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Nov 2023 18:58:16 -0500 Subject: [PATCH 1/5] ci: add c++ coverage --- .github/workflows/ci.yaml | 12 +++++++++--- .gitignore | 1 + coverage_cpp.xml | 3 +++ setup.py | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 coverage_cpp.xml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3652df8..5484b7a 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 -g -r . --xml coverage_cpp.xml 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..15ca8d0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ ilpy/wrapper.cpp build dist .vscode +coverage.xml diff --git a/coverage_cpp.xml b/coverage_cpp.xml new file mode 100644 index 0000000..5b3ab84 --- /dev/null +++ b/coverage_cpp.xml @@ -0,0 +1,3 @@ + + +. \ No newline at end of file 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"] From 5c483ac4388371964d1a7b173274042ffec6444d Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Nov 2023 19:11:50 -0500 Subject: [PATCH 2/5] ci: add c++ coverage --- .github/workflows/ci.yaml | 2 +- tests/test_constraint.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/test_constraint.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5484b7a..31649c9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -78,7 +78,7 @@ jobs: - name: run tests run: | pytest --color yes -v --cov ilpy --cov-report=xml - gcovr -g -r . --xml coverage_cpp.xml + gcovr --xml coverage_cpp.xml env: GRB_LICENSE_FILE: ${{ steps.write-license.outputs.grb_license_file }} 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) From 36040a34b3ce26876552d592a19dbbfaf71c3fa9 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Nov 2023 19:13:36 -0500 Subject: [PATCH 3/5] add gitignore --- .github/workflows/ci.yaml | 2 +- .gitignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 31649c9..84f830f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -78,7 +78,7 @@ jobs: - name: run tests run: | pytest --color yes -v --cov ilpy --cov-report=xml - gcovr --xml coverage_cpp.xml + gcovr --xml coverage_cpp.xml # generate C coverage report env: GRB_LICENSE_FILE: ${{ steps.write-license.outputs.grb_license_file }} diff --git a/.gitignore b/.gitignore index 15ca8d0..24b06bf 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ build dist .vscode coverage.xml +coverage_cpp.xml From c45da349f9ab309ac8fc925e3f46a464359843f1 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Nov 2023 19:17:09 -0500 Subject: [PATCH 4/5] remove coverage --- coverage_cpp.xml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 coverage_cpp.xml diff --git a/coverage_cpp.xml b/coverage_cpp.xml deleted file mode 100644 index 5b3ab84..0000000 --- a/coverage_cpp.xml +++ /dev/null @@ -1,3 +0,0 @@ - - -. \ No newline at end of file From 4fc1056c7938592aef73dbdb31c58b4c4a9db263 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Nov 2023 19:30:00 -0500 Subject: [PATCH 5/5] force