Skip to content

Add codecov integration for code coverage tracking #115

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 21 additions & 13 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest>=7.0.0
pytest-cov>=4.1.0
codecov>=2.1.13
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/rounding.py → tests/test_rounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.