diff --git a/.gitea/workflows/sonar.yml b/.gitea/workflows/sonar.yml index d57181e..cf6acd8 100644 --- a/.gitea/workflows/sonar.yml +++ b/.gitea/workflows/sonar.yml @@ -34,7 +34,7 @@ jobs: npm run test:coverage - name: SonarQube Scan + Quality Gate - uses: sonarsource/sonarqube-scan-action@v5 + uses: sonarsource/sonarqube-scan-action@v6 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/package.json b/package.json index 128845e..82f6d19 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "start": "node dist/hello.js", "typecheck": "tsc --noEmit", "migrate": "npm run build && node dist/db/migrate.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": "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\" && node scripts/remap-lcov.cjs" }, "dependencies": { "@opentelemetry/api": "^1.9.1", diff --git a/scripts/remap-lcov.cjs b/scripts/remap-lcov.cjs new file mode 100644 index 0000000..d5cfb6a --- /dev/null +++ b/scripts/remap-lcov.cjs @@ -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);