Skip to content

Commit 0ef05cf

Browse files
authored
feat: add test coverage reporting with GitHub Pages badge (#62)
* chore: add coverage configuration to pyproject.toml Configure pytest-cov with: - Branch coverage enabled for stackone_ai source - Exclusions for __init__.py and py.typed files - Standard exclusion patterns (TYPE_CHECKING, NotImplementedError, etc.) - JSON output to coverage/coverage.json for CI badge generation - HTML output to coverage/html for detailed reports * chore: add coverage command to justfile Add `just coverage` command that runs pytest with: - Terminal coverage report for quick feedback - JSON report for CI badge generation - HTML report for detailed analysis * chore: ignore coverage output files Add .coverage and coverage/ to .gitignore to prevent committing locally generated coverage reports. * ci: add coverage reporting with GitHub Pages deployment Add coverage job that runs on main branch pushes: - Run tests with pytest-cov to generate coverage reports - Generate coverage badge using coverage-badges-cli - Upload coverage artifacts to GitHub Pages Add deploy-coverage job to publish reports to GitHub Pages, making coverage badge and HTML report publicly accessible at https://stackonehq.github.io/stackone-ai-python/ Matches the coverage setup in stackone-ai-node repository. * docs: add coverage badge to README Display test coverage percentage badge that links to the detailed HTML coverage report on GitHub Pages.
1 parent c365dbd commit 0ef05cf

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ concurrency:
1212

1313
permissions:
1414
contents: read
15+
pages: write
16+
id-token: write
1517

1618
jobs:
1719
typos:
@@ -59,3 +61,46 @@ jobs:
5961

6062
- name: Run Tests
6163
run: nix develop --command just test
64+
65+
coverage:
66+
runs-on: ubuntu-latest
67+
if: github.ref == 'refs/heads/main'
68+
env:
69+
STACKONE_API_KEY: ${{ secrets.STACKONE_API_KEY }}
70+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
71+
steps:
72+
- name: Checkout repository
73+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
74+
75+
- name: Setup Nix
76+
uses: ./.github/actions/setup-nix
77+
78+
- name: Install dependencies
79+
run: nix develop --command just install --all-extras
80+
81+
- name: Run Tests with Coverage
82+
run: nix develop --command just coverage
83+
84+
- name: Create Coverage Badge
85+
uses: jaywcjlove/coverage-badges-cli@bd6ccbf422c0ed54c01f283019fd2bc648f58541 # v2.2.0
86+
with:
87+
source: coverage/coverage.json
88+
output: coverage/badges.svg
89+
jsonPath: totals.percent_covered
90+
91+
- name: Upload coverage artifact
92+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v3.0.2
93+
with:
94+
path: coverage/
95+
96+
deploy-coverage:
97+
needs: coverage
98+
runs-on: ubuntu-latest
99+
if: github.ref == 'refs/heads/main'
100+
environment:
101+
name: github-pages
102+
url: ${{ steps.deployment.outputs.page_url }}
103+
steps:
104+
- name: Deploy to GitHub Pages
105+
id: deployment
106+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
.pytest_cache
66
.python-version
77
__pycache__
8+
.coverage
9+
coverage/
810

911
.DS_Store
1012

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![PyPI version](https://badge.fury.io/py/stackone-ai.svg)](https://badge.fury.io/py/stackone-ai)
44
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/StackOneHQ/stackone-ai-python)](https://github.com/StackOneHQ/stackone-ai-python/releases)
5+
[![Coverage](https://stackonehq.github.io/stackone-ai-python/badges.svg)](https://stackonehq.github.io/stackone-ai-python/html/)
56

67
StackOne AI provides a unified interface for accessing various SaaS tools through AI-friendly APIs.
78

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ lint-fix:
1414
test:
1515
uv run pytest
1616

17+
# Run tests with coverage
18+
coverage:
19+
uv run pytest --cov --cov-report=term --cov-report=json --cov-report=html
20+
1721
# Run tool-specific tests
1822
test-tools:
1923
uv run pytest tests

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,26 @@ ignore_missing_imports = true
123123
module = "mcp.*"
124124
ignore_missing_imports = true
125125
ignore_errors = true
126+
127+
[tool.coverage.run]
128+
source = ["stackone_ai"]
129+
branch = true
130+
omit = [
131+
"stackone_ai/__init__.py",
132+
"**/py.typed",
133+
]
134+
135+
[tool.coverage.report]
136+
exclude_lines = [
137+
"pragma: no cover",
138+
"def __repr__",
139+
"raise NotImplementedError",
140+
"if TYPE_CHECKING:",
141+
"if typing.TYPE_CHECKING:",
142+
]
143+
144+
[tool.coverage.json]
145+
output = "coverage/coverage.json"
146+
147+
[tool.coverage.html]
148+
directory = "coverage/html"

0 commit comments

Comments
 (0)