Skip to content

Commit 3314164

Browse files
committed
Fix coverage report
1 parent 7a04132 commit 3314164

File tree

2 files changed

+70
-11
lines changed

2 files changed

+70
-11
lines changed

.github/workflows/ci.yml

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ jobs:
5757
run: |
5858
uv sync --group testing --all-extras
5959
60+
- run: mkdir coverage
61+
6062
- name: test
6163
run: make test
6264
env:
63-
COVERAGE_FILE: .coverage.${{ runner.os }}-py${{ matrix.python }}
65+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python }}
6466
CONTEXT: ${{ runner.os }}-py${{ matrix.python }}
6567

6668
- name: uninstall deps
@@ -69,20 +71,64 @@ jobs:
6971
- name: test without deps
7072
run: make test
7173
env:
72-
COVERAGE_FILE: .coverage.${{ runner.os }}-py${{ matrix.python }}-without-deps
74+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python }}-without-deps
7375
CONTEXT: ${{ runner.os }}-py${{ matrix.python }}-without-deps
7476

75-
- run: uv run coverage combine
76-
- run: uv run coverage xml
77-
78-
- uses: codecov/codecov-action@v4
77+
- name: store coverage files
78+
uses: actions/upload-artifact@v4
7979
with:
80-
file: ./coverage.xml
81-
env_vars: PYTHON,OS
80+
name: coverage-${{ matrix.python }}-${{ runner.os }}
81+
path: coverage
82+
include-hidden-files: true
83+
84+
coverage:
85+
runs-on: ubuntu-latest
86+
needs: [test]
87+
steps:
88+
- uses: actions/checkout@v4
89+
with:
90+
# needed for diff-cover
91+
fetch-depth: 0
92+
93+
- name: get coverage files
94+
uses: actions/download-artifact@v4
95+
with:
96+
merge-multiple: true
97+
path: coverage
98+
99+
- uses: astral-sh/setup-uv@v5
100+
with:
101+
enable-cache: true
102+
103+
- run: uv sync --group testing --all-extras
104+
105+
- run: uv run coverage combine coverage
106+
107+
- run: uv run coverage html --show-contexts --title "Pydantic Settings coverage for ${{ github.sha }}"
108+
109+
- name: Store coverage html
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: coverage-html
113+
path: htmlcov
114+
include-hidden-files: true
115+
116+
- run: uv run coverage xml
117+
118+
- run: uv run diff-cover coverage.xml --html-report index.html
119+
120+
- name: Store diff coverage html
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: diff-coverage-html
124+
path: index.html
125+
126+
- run: uv run coverage report --fail-under 95
127+
- run: uv run diff-cover coverage.xml --fail-under 100
82128

83129
check: # This job does nothing and is only used for the branch protection
84130
if: always()
85-
needs: [lint, test]
131+
needs: [lint, test, coverage]
86132
runs-on: ubuntu-latest
87133

88134
outputs:

pyproject.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,32 @@ filterwarnings = [
8989
'ignore::DeprecationWarning:botocore.*:',
9090
]
9191

92+
# https://coverage.readthedocs.io/en/latest/config.html#run
9293
[tool.coverage.run]
9394
source = ['pydantic_settings']
9495
branch = true
95-
context = '${CONTEXT}'
9696

97+
# https://coverage.readthedocs.io/en/latest/config.html#report
9798
[tool.coverage.report]
99+
skip_covered = true
100+
show_missing = true
101+
ignore_errors = true
98102
precision = 2
99103
exclude_lines = [
100104
'pragma: no cover',
101105
'raise NotImplementedError',
102-
'raise NotImplemented',
103106
'if TYPE_CHECKING:',
107+
'if typing.TYPE_CHECKING:',
104108
'@overload',
109+
'@deprecated',
110+
'@typing.overload',
111+
'@abstractmethod',
112+
'\(Protocol\):$',
113+
'typing.assert_never',
114+
'$\s*assert_never\(',
115+
'if __name__ == .__main__.:',
116+
'except ImportError as _import_error:',
117+
'$\s*pass$',
105118
]
106119

107120
[tool.coverage.paths]

0 commit comments

Comments
 (0)