fix: run all tests in CI and remap LCOV paths for Sonar
sonar / sonar (push) Skipped
sonar / sonar (pull_request) Canceled after 7m29s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-11 15:06:50 -03:00
co-authored by Cursor
parent 9ef746aa4f
commit b3f515bb64
3 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ jobs:
npm run test:coverage npm run test:coverage
- name: SonarQube Scan + Quality Gate - name: SonarQube Scan + Quality Gate
uses: sonarsource/sonarqube-scan-action@v5 uses: sonarsource/sonarqube-scan-action@v6
env: env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
+2 -2
View File
@@ -11,8 +11,8 @@
"start": "node dist/hello.js", "start": "node dist/hello.js",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"migrate": "npm run build && node dist/db/migrate.js", "migrate": "npm run build && node dist/db/migrate.js",
"test": "npm run build && node --test dist/**/*.test.js", "test": "npm run build && node --test \"dist/**/*.test.js\"",
"test:coverage": "npm run build && node -e \"require('fs').mkdirSync('coverage',{recursive:true})\" && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test dist/**/*.test.js" "test:coverage": "npm run build && node -e \"require('fs').mkdirSync('coverage',{recursive:true})\" && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test \"dist/**/*.test.js\" && node scripts/remap-lcov.cjs"
}, },
"dependencies": { "dependencies": {
"@opentelemetry/api": "^1.9.1", "@opentelemetry/api": "^1.9.1",
+10
View File
@@ -0,0 +1,10 @@
const fs = require("node:fs");
const path = require("node:path");
const file = path.join("coverage", "lcov.info");
const remapped = fs.readFileSync(file, "utf8").replace(/^SF:(.+)$/gm, (_, p) => {
const norm = String(p).replaceAll("\\", "/");
const match = /(?:^|\/)dist\/(.+)\.js$/.exec(norm);
return match ? `SF:src/${match[1]}.ts` : `SF:${norm}`;
});
fs.writeFileSync(file, remapped);