From 5242fa46f09c5e07a1ad1f998f9edc2c97a8e970 Mon Sep 17 00:00:00 2001 From: Johannes Eschrig Date: Mon, 10 Nov 2025 15:16:30 +0100 Subject: [PATCH 1/3] add sonar scan with coverage --- .github/workflows/test.yml | 25 ++++++++++++++++--------- .gitignore | 1 + sonar-project.properties | 5 +++++ vitest.config.ts | 2 +- 4 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96a74b5..86dc691 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Tests +name: Test and Scan on: pull_request: @@ -18,13 +18,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.version }} + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.version }} - - name: Run Unit Tests - run: | - npm ci - npm run test + - name: Run Unit Tests + run: | + npm ci + npm run test:coverage + + - name: Sonar Scan + if: matrix.version == 22 + uses: SonarSource/sonarcloud-github-action@ffc3010689be73b8e5ae0c57ce35968afd7909e8 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index 8bb81f6..6914bd8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ dist/ # Other *.DS_Store +/coverage diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..5646416 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.projectKey=cap-js_console +sonar.organization=cap-js + +sonar.sources=. +sonar.javascript.lcov.reportPaths=./coverage/lcov.info diff --git a/vitest.config.ts b/vitest.config.ts index 90f3281..ec70191 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { coverage: { - reporter: ['text'], + reporter: ['text', 'lcov'], include: ['src/**/*.ts'], }, }, From ddbf3150ba6554c3305dd1ce61ac44022826d73d Mon Sep 17 00:00:00 2001 From: Johannes Eschrig Date: Mon, 10 Nov 2025 15:21:35 +0100 Subject: [PATCH 2/3] use non-deprecated action --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86dc691..ecf5aa8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: - name: Sonar Scan if: matrix.version == 22 - uses: SonarSource/sonarcloud-github-action@ffc3010689be73b8e5ae0c57ce35968afd7909e8 + uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 0a4be1b8c217bed6261a1534fda9f741df548b8b Mon Sep 17 00:00:00 2001 From: Johannes Eschrig Date: Mon, 10 Nov 2025 15:24:50 +0100 Subject: [PATCH 3/3] add sonar.host.url --- sonar-project.properties | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index 5646416..2038391 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,3 +1,7 @@ +sonar.host.url=https://sonar.tools.sap + +sonar.sourceEncoding=UTF-8 + sonar.projectKey=cap-js_console sonar.organization=cap-js