diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96a74b5..ecf5aa8 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/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 + 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..2038391 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +sonar.host.url=https://sonar.tools.sap + +sonar.sourceEncoding=UTF-8 + +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'], }, },