Skip to content

Commit

Permalink
Add test coverage via CC
Browse files Browse the repository at this point in the history
  • Loading branch information
maldoinc committed Nov 29, 2023
1 parent 2d0b12b commit d638326
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test Coverage

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Create venv
run: python -m venv .venv

- name: Install dependencies
run: make install

- name: Run tests
run: .venv/bin/coverage run -m unittest discover -s test

- name: Generate coverage report
run: |
.venv/bin/coverage xml
- name: Upload coverage to CodeClimate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TOKEN }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t coverage.py coverage.xml
./cc-test-reporter upload-coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dist
docs/site
__pycache__
.mypy_cache
.coverage
coverage.xml
66 changes: 65 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mike = "^1.1.2"
typing-extensions = "^4.7.1"
mypy = "^1.5.1"
flask = "^3.0.0"
coverage = "^7.3.2"

[tool.ruff]
target-version = "py38"
Expand Down Expand Up @@ -85,3 +86,19 @@ ignore = [
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

# Taken from https://coverage.readthedocs.io/en/latest/excluding.html
[tool.coverage.report]
omit = ["test/*"]
exclude_also = [
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]

0 comments on commit d638326

Please sign in to comment.