diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 157506d..23c4930 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,19 +1,24 @@ name: test on: push: - branches-ignore: [main] + branches: + - main + pull_request: + types: [opened, synchronize, reopened] workflow_dispatch: - jobs: unit-tests: strategy: matrix: os: ['ubuntu-latest', 'windows-latest'] - node_version: [lts/-1, lts/*, latest] + node_version: [lts/*] fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + with: + # Shallow clones should be disabled for a better relevancy of sonarqube analysis + fetch-depth: 0 - uses: pnpm/action-setup@v4 with: version: 9.5.0 @@ -23,4 +28,9 @@ jobs: node-version: ${{ matrix.node_version }} cache: 'pnpm' - run: pnpm run build - - run: pnpm run test + - run: pnpm run test:coverage + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.nycrc.json b/.nycrc.json index 7e61aee..b96d450 100644 --- a/.nycrc.json +++ b/.nycrc.json @@ -1,7 +1,14 @@ { + "$schema": "https://json.schemastore.org/nycrc.json", "extends": "@istanbuljs/nyc-config-typescript", "all": true, - "check-coverage": true, - "extensions": [".ts"], - "reporter": ["text", "html", "lcov"] + "check-coverage": false, + "extensions": [ + ".ts" + ], + "reporter": [ + "text", + "html", + "lcov" + ] } diff --git a/package.json b/package.json index d370d93..d6b6d08 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,9 @@ "format:write": "prettier -w \"**/*.{ts,json}\"", "postpack": "shx rm -f oclif.manifest.json", "posttest": "pnpm run lint", - "prepack": "oclif manifest && pnpm run build:release && pnpm run test", - "test": "mocha", - "coverage": "nyc --reporter=lcov npm run test" + "prepack": "oclif manifest && pnpm run build:release && pnpm run test:unit", + "test:unit": "mocha", + "test:coverage": "nyc --reporter=lcov npm run test:unit" }, "keywords": [ "obsidian", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..058c047 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectKey=ovm +sonar.javascript.lcov.reportPaths=./coverage/lcov.info +sonar.sources=src +sonar.exclusions=**/node_modules/**,**/coverage/**,**/dist/** +sonar.test.inclusions=**/*.test.ts +sonar.typescript.lcov.reportPaths=./coverage/lcov.info