diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..3a86d292 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,32 @@ + +comment: + layout: "reach, diff, flags, files" + behavior: default + require_changes: false + require_base: no + require_head: yes + +coverage: + status: + project: + default: + # basic + target: auto + threshold: 1% + patch: + default: + # basic + target: auto + threshold: 1% + +# Separate flags for C++ and Python coverage +flags: + cpp: + paths: + - volesti/ + carryforward: true + python: + paths: + - dingo/ + - tests/ + carryforward: true \ No newline at end of file diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 17bd6bda..479cdf60 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -46,17 +46,25 @@ jobs: source $(poetry env info --path)/bin/activate poetry install; pip3 install numpy scipy; - - name: Run tests + pip3 install pytest pytest-cov codecov; + - name: Run tests with coverage run: | - poetry run python3 tests/fba.py; - poetry run python3 tests/full_dimensional.py; - poetry run python3 tests/max_ball.py; - poetry run python3 tests/scaling.py; - poetry run python3 tests/sampling.py; - poetry run python3 tests/sampling_no_multiphase.py; - # currently we do not test with gurobi - # python3 tests/fast_implementation_test.py; - - #run all tests - #python -m unittest discover test - #TODO: use pytest + # Legacy way - keep for compatibility + poetry run python3 tests/test_fba.py; + poetry run python3 tests/test_full_dimensional.py; + poetry run python3 tests/test_max_ball.py; + poetry run python3 tests/test_scaling.py; + poetry run python3 tests/test_sampling.py; + poetry run python3 tests/test_sampling_no_multiphase.py; + + # New way - using pytest with coverage + poetry run pytest --cov=dingo --cov-report=xml --cov-report=term + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + flags: python + fail_ci_if_error: false + name: codecov-umbrella + verbose: true \ No newline at end of file diff --git a/README.md b/README.md index 9e122771..c93aa212 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,7 @@ metabolic network, namely Flux Balance Analysis and Flux Variability Analysis. [![unit-tests](https://github.com/GeomScale/dingo/workflows/dingo-ubuntu/badge.svg)](https://github.com/GeomScale/dingo/actions?query=workflow%3Adingo-ubuntu) [![Tutorial In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/GeomScale/dingo/blob/develop/tutorials/dingo_tutorial.ipynb) [![Chat](https://badges.gitter.im/geomscale.png)](https://gitter.im/GeomScale/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link) - - +[![codecov](https://codecov.io/gh/GeomScale/dingo/branch/develop/graph/badge.svg)](https://codecov.io/gh/GeomScale/dingo) ## Installation **Note:** Python version should be 3.8.x. You can check this by running the following command in your terminal: diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..e74735be --- /dev/null +++ b/pytest.ini @@ -0,0 +1,10 @@ + +[pytest] +testpaths = tests +python_files = test_*.py +python_functions = test_* +addopts = + --cov=dingo + --cov-report=xml:coverage.xml + --cov-report=term + --verbose \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..e342048c --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +pytest>=7.0.0 +pytest-cov>=4.1.0 +codecov>=2.1.13 \ No newline at end of file diff --git a/tests/correlation.py b/tests/test_correlation.py similarity index 100% rename from tests/correlation.py rename to tests/test_correlation.py diff --git a/tests/fba.py b/tests/test_fba.py similarity index 100% rename from tests/fba.py rename to tests/test_fba.py diff --git a/tests/full_dimensional.py b/tests/test_full_dimensional.py similarity index 100% rename from tests/full_dimensional.py rename to tests/test_full_dimensional.py diff --git a/tests/max_ball.py b/tests/test_max_ball.py similarity index 100% rename from tests/max_ball.py rename to tests/test_max_ball.py diff --git a/tests/preprocess.py b/tests/test_preprocess.py similarity index 100% rename from tests/preprocess.py rename to tests/test_preprocess.py diff --git a/tests/rounding.py b/tests/test_rounding.py similarity index 94% rename from tests/rounding.py rename to tests/test_rounding.py index e3d97c62..4bcffc57 100644 --- a/tests/rounding.py +++ b/tests/test_rounding.py @@ -15,7 +15,7 @@ from dingo import MetabolicNetwork, PolytopeSampler from dingo.pyoptinterface_based_impl import set_default_solver -def test_rounding(self, method_str): +def rounding_test(self, method_str): input_file_json = os.getcwd() + "/ext_data/e_coli_core.json" model = MetabolicNetwork.from_json( input_file_json ) @@ -59,10 +59,10 @@ def test_rounding(self, method_str): class TestSampling(unittest.TestCase): def test_rounding_min_ellipsoid(self): - test_rounding(self, "min_ellipsoid") + rounding_test(self, "min_ellipsoid") def test_rounding_john_position(self): - test_rounding(self, "john_position") + rounding_test(self, "john_position") if __name__ == "__main__": if len(sys.argv) > 1: diff --git a/tests/sampling.py b/tests/test_sampling.py similarity index 100% rename from tests/sampling.py rename to tests/test_sampling.py diff --git a/tests/sampling_no_multiphase.py b/tests/test_sampling_no_multiphase.py similarity index 100% rename from tests/sampling_no_multiphase.py rename to tests/test_sampling_no_multiphase.py diff --git a/tests/scaling.py b/tests/test_scaling.py similarity index 100% rename from tests/scaling.py rename to tests/test_scaling.py