-
Notifications
You must be signed in to change notification settings - Fork 6
62 lines (52 loc) · 1.76 KB
/
test.yaml
File metadata and controls
62 lines (52 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Tests & Coverage
# This workflow runs unit tests and coverage reports
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
permissions:
contents: read
env:
PYTHON_VERSION: "3.11"
COVERAGE_THRESHOLD: "80"
jobs:
test:
name: Unit Tests with Coverage
runs-on: ${{ contains(github.server_url, 'github.com') && 'ubuntu-latest' || fromJSON('["self-hosted"]') }}
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Install uv"
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Run Unit Tests with Coverage"
run: uv run pytest -m "not integration" --cov=src/sap_cloud_sdk --cov-report=xml --cov-report=html --cov-report=term-missing
- name: "Upload Coverage Report"
uses: actions/upload-artifact@v4
if: contains(github.server_url, 'github.com')
with:
name: coverage-report
path: |
coverage.xml
htmlcov/
retention-days: 30
- name: "Coverage Report Summary"
run: |
echo "## 📊 Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
uv run coverage report --format=markdown --skip-empty >> $GITHUB_STEP_SUMMARY
- name: "Verify Coverage Threshold"
run: |
if ! uv run coverage report --fail-under=${{ env.COVERAGE_THRESHOLD }}; then
echo "❌ Coverage is below ${{ env.COVERAGE_THRESHOLD }}%"
exit 1
fi
echo "✅ Coverage meets ${{ env.COVERAGE_THRESHOLD }}% threshold"