Skip to content

Commit

Permalink
Merge pull request #119 from sjinks/sonarcloud-reporting
Browse files Browse the repository at this point in the history
ci: report test execution results to SonarCloud
  • Loading branch information
sjinks authored Sep 1, 2024
2 parents 5faee93 + 06b7969 commit 03a74ec
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 579 deletions.
4 changes: 2 additions & 2 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extension": [".mjs"],
"exclude": ["dist/test/**"],
"extension": [".mts"],
"exclude": ["test/**"],
"reporter": ["text", "lcov"]
}
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
**/*.js
**/*.cjs
**/*.mjs
**/*.d.ts
**/*.d.mts
/.tsimp/**
/coverage/**
/dist/**
/node_modules/**
5 changes: 2 additions & 3 deletions .github/workflows/sonarscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ jobs:
run: npm ci

- name: Run tests
run: npm run test:coverage
env:
NO_UPDATE_NOTIFIER: 'true'
run: npm run test:sonarqube
continue-on-error: true

- name: Grab info
Expand All @@ -84,3 +82,4 @@ jobs:
-Dsonar.links.issue=${{ github.event.repository.html_url }}/issues
-Dsonar.links.scm=${{ github.repositoryUrl }}
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.testExecutionReportPaths=test-report.xml
6 changes: 3 additions & 3 deletions lib/utils.mts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { TestEvent } from 'node:test/reporters';

const map: Record<string, string> = {
const map = {
'\r': '%0D',
'\n': '%0A',
'%': '%25',
',': '%2C',
':': '%3A',
};
} as const;

const replacer = (match: string): string => map[match]!;
const replacer = (match: string): string => map[match as keyof typeof map];

export const escapeData = (s: unknown): string => String(s).replace(/[%\r\n]/gu, replacer);
export const escapeProperty = (s: unknown): string => String(s).replace(/[%\r\n:,]/gu, replacer);
Expand Down
Loading

0 comments on commit 03a74ec

Please sign in to comment.