diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..a12cb5f --- /dev/null +++ b/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True +source = cellxgene_gateway + +[report] +exclude_lines = + if self.debug: + pragma: no cover + raise NotImplementedError + if __name__ == .__main__.: +ignore_errors = True +omit = + tests/* \ No newline at end of file diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 9b68582..68539ce 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -45,5 +45,16 @@ jobs: run: | eval "$(conda shell.bash hook)" conda activate cellxgene-gateway - python -m unittest discover tests - bash <(curl -s https://codecov.io/bash) + coverage run -m unittest discover tests + + - name: Check coverage + run: | + eval "$(conda shell.bash hook)" + conda activate cellxgene-gateway + coverage report --fail-under 41 + coverage xml -i + + - name: "Upload coverage to Codecov" + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: true diff --git a/.gitignore b/.gitignore index 4f3c841..1e16908 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ htmlcov/ .nox/ .coverage .coverage.* +htmlcov .cache nosetests.xml coverage.xml diff --git a/README.md b/README.md index 58d6981..ab79351 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,12 @@ pre-commit install python -m unittest discover tests ``` +## Code Coverage +```bash + coverage run -m unittest discover tests + coverage html +``` + ## Running Linters pip install isort flake8 black diff --git a/environment.yml b/environment.yml index 51db748..0282a56 100644 --- a/environment.yml +++ b/environment.yml @@ -7,6 +7,7 @@ dependencies: - flask - psutil - black +- coverage - pip - pip: - flask-api