File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5454 run : python -m pip install -e ".[dev]"
5555
5656 - name : Run tests
57- run : python -m pytest tests/ -v
57+ run : python -m pytest tests/ -v --cov --cov-report=term --cov-report=json
58+
59+ # Coverage badge: the percentage is written to a gist that shields.io
60+ # renders in README. Only from main and from a single matrix entry so
61+ # PRs and duplicate uploads never overwrite the number.
62+ - name : Read coverage percentage
63+ if : github.ref == 'refs/heads/main' && matrix.python-version == '3.12'
64+ id : coverage
65+ run : |
66+ percent=$(python -c 'import json; print(round(json.load(open("coverage.json"))["totals"]["percent_covered"]))')
67+ echo "percent=$percent" >> "$GITHUB_OUTPUT"
68+
69+ - name : Update coverage badge
70+ if : github.ref == 'refs/heads/main' && matrix.python-version == '3.12'
71+ uses : schneegans/dynamic-badges-action@v1.9.0
72+ with :
73+ auth : ${{ secrets.GIST_SECRET }}
74+ gistID : 77b084ed0d46c740183f89ec66af8a95
75+ filename : python-sdk-coverage.json
76+ label : coverage
77+ message : ${{ steps.coverage.outputs.percent }}%
78+ valColorRange : ${{ steps.coverage.outputs.percent }}
79+ minColorRange : 50
80+ maxColorRange : 90
5881
5982 - name : Verify package builds
6083 run : |
Original file line number Diff line number Diff line change 2424# Testing
2525.pytest_cache /
2626.coverage
27+ coverage.json
28+ coverage.xml
2729htmlcov /
2830
2931# Type checkers
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ dev = [
4848 " ruff>=0.6" ,
4949 " mypy>=1.10" ,
5050 " types-requests>=2.28" ,
51+ " pytest-cov>=4" ,
5152]
5253
5354[project .urls ]
@@ -67,6 +68,13 @@ captcha_solver_api = ["py.typed"]
6768[tool .pytest .ini_options ]
6869asyncio_mode = " auto"
6970
71+ [tool .coverage .run ]
72+ source = [" captcha_solver_api" ]
73+ branch = true
74+
75+ [tool .coverage .report ]
76+ show_missing = true
77+
7078[tool .mypy ]
7179# mypy 2.x cannot target 3.9; 3.10 is the lowest it accepts. Runtime
7280# compatibility with 3.9 is still covered by the CI test matrix.
You can’t perform that action at this time.
0 commit comments