Skip to content

Commit 0eaae41

Browse files
committed
write codecov config
1 parent 6edcfc3 commit 0eaae41

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

.github/codecov.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 80%
6+
patch:
7+
default:
8+
target: 80%
9+
only_pulls: true
10+
11+
comment:
12+
layout: "reach, diff, files"
13+
behavior: default
14+
require_changes: true

.github/workflows/CI.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,37 @@ jobs:
9393
directory: packages/
9494
flags: packages
9595
verbose: true
96+
97+
- name: Check coverage on changed files
98+
uses: actions/github-script@v7
99+
with:
100+
script: |
101+
const fs = require('fs');
102+
const coverage = JSON.parse(fs.readFileSync('./coverage/coverage-summary.json', 'utf8'));
103+
104+
// Get list of changed files
105+
const exec = require('child_process').execSync;
106+
const diff = exec('git diff --name-only origin/${{ github.base_ref }} HEAD')
107+
.toString()
108+
.split('\n')
109+
.filter(file => file.endsWith('.ts') || file.endsWith('.tsx'));
110+
111+
let failed = false;
112+
const threshold = 80; // Match your vitest config threshold
113+
114+
for (const file of diff) {
115+
if (coverage[file]) {
116+
const fileCoverage = coverage[file];
117+
if (fileCoverage.lines.pct < threshold) {
118+
failed = true;
119+
console.log(`${file} has insufficient coverage: ${fileCoverage.lines.pct}%`);
120+
}
121+
}
122+
}
123+
124+
if (failed) {
125+
core.setFailed('Some changed files have insufficient coverage');
126+
}
96127
97128
e2e:
98129
needs: optimize_ci

packages/thirdweb/test/vitest.config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
coverage: {
1616
all: false,
1717
provider: "v8",
18-
reporter: process.env.CI ? ["lcov"] : ["text", "json", "html"],
18+
reporter: process.env.CI ? ["lcov", "json"] : ["text", "json", "html"],
1919
exclude: [
2020
// test files do not count
2121
"**/*.test.ts",
@@ -30,12 +30,6 @@ export default defineConfig({
3030
"src/exports/**",
3131
],
3232
include: ["src/**"],
33-
thresholds: {
34-
functions: 90,
35-
branches: 80,
36-
lines: 80,
37-
statements: 80,
38-
},
3933
},
4034
environmentMatchGlobs: [["src/react/**/*.test.tsx", "happy-dom"]],
4135
environment: "node",

0 commit comments

Comments
 (0)