Skip to content

Commit e845057

Browse files
authored
Merge pull request #28 from QuantForgeOrg/dev
add automatic coverage badge
2 parents 753e80f + 7d9d59b commit e845057

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.github/workflows/release.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ jobs:
2424
- name: Install dependencies
2525
run: npm ci
2626

27+
- name: Run tests with coverage
28+
run: npx vitest run --coverage
29+
30+
- name: Generate Coverage Badge
31+
run: npx coverage-badge -o coverage.svg
32+
2733
- name: Build project
2834
run: npm run build:prod:all
2935

@@ -36,3 +42,23 @@ jobs:
3642
overwrite: true
3743
env:
3844
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Update Coverage Badge in Repo
47+
if: success()
48+
run: |
49+
git config --global user.name "github-actions[bot]"
50+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
51+
52+
# Fetch and checkout the default branch (trying main, falling back to master)
53+
git fetch origin main:main || git fetch origin master:master
54+
BRANCH=$(git show-ref --verify --quiet refs/heads/main && echo "main" || echo "master")
55+
git checkout $BRANCH
56+
57+
# Move badge to correct location
58+
mkdir -p .github/badges
59+
mv coverage.svg .github/badges/coverage.svg
60+
61+
# Commit and push
62+
git add .github/badges/coverage.svg
63+
git commit -m "docs: update coverage badge [skip ci]" || echo "No changes to commit"
64+
git push origin $BRANCH

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![npm version](https://img.shields.io/npm/v/pinets.svg?style=flat-square)](https://www.npmjs.com/package/pinets)
22
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg?style=flat-square)](https://opensource.org/licenses/AGPL-3.0)
3+
[![Coverage](./.github/badges/coverage.svg)](./.github/badges/coverage.svg)
34
[![Documentation](https://img.shields.io/badge/docs-github--pages-blue?style=flat-square)](https://quantforgeorg.github.io/PineTS/)
45
[![Reddit](https://img.shields.io/reddit/subreddit-subscribers/QuantForge?style=flat-square&logo=reddit)](https://www.reddit.com/r/QuantForge/)
56

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineConfig({
99
include: ['tests/**/*.test.ts'],
1010
exclude: ['node_modules'],
1111
coverage: {
12-
reporter: ['text', 'text-summary', 'html'],
12+
reporter: ['text', 'text-summary', 'html', 'json-summary'],
1313
reportsDirectory: './coverage',
1414
include: ['src/**/*.ts'],
1515
exclude: ['node_modules'],

0 commit comments

Comments
 (0)