Skip to content

Commit

Permalink
Add code coverage reporting with Codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoffrey committed Jun 25, 2024
1 parent f24c3cd commit 6b60826
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,17 @@ jobs:
- run: npm install && npm test && npm run lint
env:
CI: true

codecov:
runs-on: ubuntu-latest
timeout-minutes: 10
name: 'Codecov: node-22, ubuntu-latest'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Generate coverage report
run: npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: actions
on: [push, pull_request]
jobs:
coverage:
runs-on: ubuntu-latest
name: Code Coverage Report
steps:
- name: Generate report
uses: irongut/[email protected]
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
npm-debug.log
package-lock.json
tmp/
coverage/
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@types/node": "^18.7.14",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@vitest/coverage-istanbul": "^1.6.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
Expand All @@ -57,6 +58,7 @@
"test": "npm run build && npm run test:types && npm run test:vitest",
"test:types": "tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit",
"test:vitest": "vitest run",
"test:coverage": "vitest run --coverage",
"watch": "npm run build -- --watch"
},
"keywords": [
Expand Down
12 changes: 12 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
coverage: {
enabled: true,
include: ['src'],
provider: 'istanbul',
reporter: ['cobertura'],
},
},
})

0 comments on commit 6b60826

Please sign in to comment.