Skip to content

Commit

Permalink
setup coverage (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored Apr 27, 2024
1 parent d770cf3 commit eedb090
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
37 changes: 35 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Ensure requests to production domains fail
Expand All @@ -63,12 +65,44 @@ jobs:
- run: rye config --set-bool behavior.use-uv=true
- run: rye sync --no-lock
- run: rye show
- run: mkdir coverage
- run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
- name: store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: coverage

coverage:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: get coverage files
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: coverage
- run: pip install coverage[toml]
- run: ls -lh coverage
- run: coverage combine coverage
- run: coverage xml
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
env_vars: PYTHON
- run: coverage report --precision=2 --fail-under=99

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [lint, docs, test]
needs: [lint, docs, test, coverage]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand All @@ -77,7 +111,6 @@ jobs:
jobs: ${{ toJSON(needs) }}

release:
name: Release
needs: [check]
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
__pycache__
*.env
/scratch/
/.coverage
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ lint:

.PHONY: test # Run the tests
test:
rye test
rye run coverage run -m pytest

.PHONY: testcov # Run tests and generate a coverage report
testcov: test
@echo "building coverage html"
@rye run coverage html

.PHONY: docs # Build the documentation
docs:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Pydantic Logfire — Uncomplicated Observability

[![CI](https://github.com/pydantic/logfire/actions/workflows/main.yml/badge.svg?event=push)](https://github.com/pydantic/logfire/actions?query=event%3Apush+branch%3Amain+workflow%3ACI)
[![codecov](https://codecov.io/gh/pydantic/logfire/graph/badge.svg?token=735CNGCGFD)](https://codecov.io/gh/pydantic/logfire)
[![pypi](https://img.shields.io/pypi/v/logfire.svg)](https://pypi.python.org/pypi/logfire)
[![license](https://img.shields.io/github/license/pydantic/logfire.svg)](https://github.com/pydantic/logfire/blob/main/LICENSE)
[![versions](https://img.shields.io/pypi/pyversions/logfire.svg)](https://github.com/pydantic/logfire)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ dev-dependencies = [
"loguru",
"ruff",
"pyright",
"pip>=24.0",
"pre-commit>=3.7.0",
"mkdocs>=1.5.0",
"mkdocs-material>=9.5.17",
"mkdocs-glightbox>=0.3.7",
"mkdocstrings-python>=1.8.0",
"coverage[toml]>=7.5.0",
]

[tool.rye.scripts]
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ click==8.1.7
colorama==0.4.6
# via griffe
# via mkdocs-material
coverage==7.5.0
deprecated==1.2.14
# via opentelemetry-api
# via opentelemetry-exporter-otlp-proto-http
Expand Down Expand Up @@ -224,7 +225,6 @@ pandas==2.2.2
pathspec==0.12.1
# via black
# via mkdocs
pip==24.0
platformdirs==4.2.1
# via black
# via mkdocs
Expand Down

0 comments on commit eedb090

Please sign in to comment.