Skip to content

Commit

Permalink
Fix coverage reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed May 27, 2024
1 parent eca9bd7 commit 55ff9aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions .github/scripts/coverage.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env zx --experimental
#!/usr/bin/env zx

const expected = 90
const exclude = [
'expr/test',
'checker/mock',
'vm/func_types',
'vm/runtime/helpers',
'internal/difflib',
'internal/spew',
'internal/testify',
]

cd(path.resolve(__dirname, '..', '..'))
Expand All @@ -24,9 +27,11 @@ await spinner('Running tests', async () => {
await $`go tool cover -html=coverage.out -o coverage.html`
})

const cover = await $`go tool cover -func=coverage.out`
const cover = await $({verbose: true})`go tool cover -func=coverage.out`
const total = +cover.stdout.match(/total:\s+\(statements\)\s+(\d+\.\d+)%/)[1]
if (total < expected) {
echo(chalk.red(`Coverage is too low: ${total}% < ${expected}% (expected)`))
process.exit(1)
} else {
echo(`Coverage is good: ${chalk.green(total + '%')} >= ${expected}% (expected)`)
}
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go 1.18
- name: Setup Go 1.12
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.12
- name: Test
run: npx zx --experimental .github/scripts/coverage.mjs
run: npx zx .github/scripts/coverage.mjs

0 comments on commit 55ff9aa

Please sign in to comment.