Skip to content

Commit 4be7ffe

Browse files
(ci) Add tests coverage
1 parent 137dbac commit 4be7ffe

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed

.github/workflows/coverage.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
coverage:
9+
name: Coverage
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
RAYFORCE_GITHUB: "https://github.com/RayforceDB/rayforce.git"
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
submodules: false
20+
21+
- name: Set up Python 3.14
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.14'
25+
cache: 'pip'
26+
27+
- name: Install system dependencies
28+
run: |
29+
sudo apt-get update -qq
30+
sudo apt-get install -y -qq git gcc clang gcc-c++ make
31+
32+
- name: Install build dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install setuptools wheel setuptools-scm
36+
37+
- name: Build rayforce binaries
38+
run: make app
39+
40+
- name: Install test dependencies
41+
run: |
42+
pip install pytest pytest-cov coverage pandas>=2.0.0 polars>=0.19.0
43+
44+
- name: Run tests with coverage
45+
run: |
46+
python -m pytest -x -vv --cov=rayforce --cov-report=term-missing --cov-report=xml --cov-report=html tests/
47+
48+
- name: Coverage Report
49+
run: |
50+
python -m coverage report
51+
echo "Coverage HTML report generated in htmlcov/index.html"
52+
53+
- name: Upload coverage to Codecov
54+
uses: codecov/codecov-action@v4
55+
with:
56+
file: ./coverage.xml
57+
flags: unittests
58+
name: codecov-umbrella
59+
fail_ci_if_error: false
60+
61+
- name: Upload coverage HTML report
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: coverage-report
65+
path: htmlcov/
66+
retention-days: 30

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
.pytest_cache
44
.mypy_cache
55

6+
# Coverage
7+
.coverage
8+
.coverage.*
9+
htmlcov/
10+
.coverage.*
11+
*.cover
12+
.hypothesis/
13+
.pytest_cache/
14+
coverage.xml
15+
*.coveragerc
16+
617
# Binaries
718
rayforce/bin/
819
rayforce/rayforce/

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ app: pull_rayforce_from_github patch_rayforce_makefile rayforce_binaries
7373
test:
7474
python3 -m pytest -x -vv tests/
7575

76+
test-cov:
77+
python3 -m pytest -x -vv --cov=rayforce --cov-report=term-missing --cov-report=html tests/
78+
python3 -m pytest -x -vv --cov=rayforce --cov-report=term-missing tests/
79+
7680
lint:
7781
python3 -m ruff format tests/ rayforce/
7882
python3 -m ruff check rayforce/ --fix

pyproject.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ rayforce = "rayforce.cli:main"
3030
pandas = ["pandas>=2.0.0"]
3131
polars = ["polars>=0.19.0"]
3232
all = ["pandas>=2.0.0", "polars>=0.19.0"]
33+
dev = [
34+
"pytest>=7.0.0",
35+
"pytest-cov>=4.0.0",
36+
"coverage>=7.0.0",
37+
"ruff>=0.1.0",
38+
"mypy>=1.0.0",
39+
"pandas>=2.0.0",
40+
"polars>=0.19.0",
41+
]
3342

3443
[tool.cibuildwheel]
3544
build = "cp311-* cp312-* cp313-* cp314-*"
@@ -141,3 +150,36 @@ quote-style = "double"
141150
indent-style = "space"
142151
skip-magic-trailing-comma = false
143152
line-ending = "auto"
153+
154+
[tool.coverage.run]
155+
source = ["rayforce"]
156+
omit = [
157+
"*/tests/*",
158+
"*/test_*.py",
159+
"*/__pycache__/*",
160+
"*/setup.py",
161+
"*/benchmark/*",
162+
"*/scripts/*",
163+
"rayforce/rayforce/*", # C extension code
164+
"rayforce/capi/*", # C API code
165+
"rayforce/_rayforce_c.pyi", # Type stubs
166+
]
167+
168+
[tool.coverage.report]
169+
exclude_lines = [
170+
"pragma: no cover",
171+
"def __repr__",
172+
"raise AssertionError",
173+
"raise NotImplementedError",
174+
"if __name__ == .__main__.:",
175+
"if TYPE_CHECKING:",
176+
"@abstractmethod",
177+
"class .*\\bProtocol\\):",
178+
"@(abc\\.)?abstractmethod",
179+
]
180+
precision = 2
181+
show_missing = true
182+
skip_covered = false
183+
184+
[tool.coverage.html]
185+
directory = "htmlcov"

0 commit comments

Comments
 (0)