Skip to content

Commit 1f58e9f

Browse files
committed
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.
1 parent a5aa667 commit 1f58e9f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-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

0 commit comments

Comments
 (0)