ci: add test artifacts and coverage threshold
- pytest-html for HTML test reports - coverage HTML report - 90% coverage threshold check - Upload test results and coverage as artifacts - Artifacts available in PR for review
This commit is contained in:
parent
8a018e4e6d
commit
ee7c5b7933
@ -21,7 +21,41 @@ jobs:
|
|||||||
run: uv sync --group dev
|
run: uv sync --group dev
|
||||||
|
|
||||||
- name: Run tests with coverage
|
- name: Run tests with coverage
|
||||||
run: uv run pytest tests/unit/ -v --tb=short --cov=src/kwork_api --cov-report=term-missing
|
run: |
|
||||||
|
uv run pytest tests/unit/ \
|
||||||
|
-v \
|
||||||
|
--tb=short \
|
||||||
|
--cov=src/kwork_api \
|
||||||
|
--cov-report=term-missing \
|
||||||
|
--cov-report=html:coverage-html \
|
||||||
|
--html=test-results/report.html \
|
||||||
|
--self-contained-html
|
||||||
|
|
||||||
|
- name: Check coverage threshold (90%)
|
||||||
|
run: |
|
||||||
|
COVERAGE=$(uv run coverage report | grep TOTAL | awk '{print $NF}' | tr -d '%')
|
||||||
|
echo "Coverage: ${COVERAGE}%"
|
||||||
|
if (( $(echo "$COVERAGE < 90" | bc -l) )); then
|
||||||
|
echo "❌ Coverage ${COVERAGE}% is below 90% threshold"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✅ Coverage ${COVERAGE}% meets 90% threshold"
|
||||||
|
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: test-results
|
||||||
|
path: test-results/
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
|
- name: Upload coverage report
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: coverage-report
|
||||||
|
path: coverage-html/
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
- name: Run linting
|
- name: Run linting
|
||||||
run: uv run ruff check src/kwork_api tests/
|
run: uv run ruff check src/kwork_api tests/
|
||||||
|
|||||||
@ -32,6 +32,7 @@ dev = [
|
|||||||
"pytest>=8.0.0",
|
"pytest>=8.0.0",
|
||||||
"pytest-cov>=4.0.0",
|
"pytest-cov>=4.0.0",
|
||||||
"pytest-asyncio>=0.23.0",
|
"pytest-asyncio>=0.23.0",
|
||||||
|
"pytest-html>=4.0.0",
|
||||||
"respx>=0.20.0",
|
"respx>=0.20.0",
|
||||||
"ruff>=0.3.0",
|
"ruff>=0.3.0",
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user