Skip to content

Commit b7cf55d

Browse files
committed
fix: use node to parse JSON in coverage workflow
1 parent 9ba1f4a commit b7cf55d

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.github/workflows/coverage.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ jobs:
5757
echo ""
5858
5959
# Extract coverage from CI run (actual)
60-
CI_COV=$(npx ts-node --files -e "
61-
import fs from 'fs';
62-
import path from 'path';
60+
CI_COV=$(node -e "
61+
const fs = require('fs');
6362
const content = fs.readFileSync('coverage/lcov.info', 'utf8').replace(/\r\n/g, '\n');
6463
let linesFound = 0, linesHit = 0;
6564
content.split('\n').forEach(line => {
@@ -70,10 +69,24 @@ jobs:
7069
")
7170
7271
# Extract PR baseline (what developer committed)
73-
PR_BASELINE=$(cat coverage-baseline.json | grep -o '"lines":"[^"]*"' | cut -d'"' -f4)
72+
PR_BASELINE=$(node -e "
73+
try {
74+
const data = require('./coverage-baseline.json');
75+
console.log(data.lines || '0');
76+
} catch(e) {
77+
console.log('0');
78+
}
79+
")
7480
7581
# Extract main baseline (production baseline)
76-
MAIN_BASELINE=$(cat coverage-baseline-main.json | grep -o '"lines":"[^"]*"' | cut -d'"' -f4 || echo "0")
82+
MAIN_BASELINE=$(node -e "
83+
try {
84+
const data = require('./coverage-baseline-main.json');
85+
console.log(data.lines || '0');
86+
} catch(e) {
87+
console.log('0');
88+
}
89+
")
7790
7891
echo "📊 Coverage Results (Lines):"
7992
echo " CI (actual): ${CI_COV}% ← Fresh coverage from this PR"

0 commit comments

Comments
 (0)