Skip to content

Commit

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

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'
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/
3 changes: 2 additions & 1 deletion 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 @@ -56,7 +57,7 @@
"release": "npm run build && npm run lint && np",
"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:vitest": "vitest run --coverage",
"watch": "npm run build -- --watch"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function mask<T, S>(
message?: string
): T {
const result = validate(value, struct, { coerce: true, mask: true, message })

// bingo
if (result[0]) {
throw result[0]
} else {
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 9d4237c

Please sign in to comment.