Skip to content

Commit

Permalink
Add coverage checks to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonwillard committed Jun 20, 2023
1 parent a466221 commit 9eb1a4b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
53 changes: 52 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,55 @@ jobs:
pip install .[test]
- name: Run tests
run: |
pytest
pytest --cov=outlines
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage*
if-no-files-found: ignore

coverage:
name: Combine & check coverage.
needs: tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
cache: pip
python-version: "3.11"

- name: Set up environment
run: |
pip install --upgrade coverage[toml]
- uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Fetch master for coverage diff
run: |
git fetch --no-tags --prune origin main
- name: Combine coverage & fail if it's <100%.
run: |
# python -m coverage combine
python -m coverage html --skip-covered --skip-empty
# Report and write to summary.
python -m coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 100%.
python -m coverage report --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
if: ${{ failure() }}
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test = [
"diffusers",
"pre-commit",
"pytest",
"pytest-cov",
"torch",
"transformers"
]
Expand Down Expand Up @@ -84,3 +85,20 @@ module = [
"transformers",
]
ignore_missing_imports = true

[tool.coverage.run]
omit = [
"outlines/_version.py",
"tests/*",
]
branch = true

[tool.coverage.report]
omit = [
"tests/*",
]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
]
show_missing = true

0 comments on commit 9eb1a4b

Please sign in to comment.