diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a0d47a9a7..6019d1de3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,8 +4,6 @@ on: push: branches: - '**' - tags: - - '*' jobs: test-build: @@ -17,35 +15,42 @@ jobs: with: node-version: 20 - run: yarn - # Run tests & build sonar reports - run: yarn test:coverage - # Build lib - run: yarn build - - name: Upload deploy artifact + - name: Upload coverage artifact uses: actions/upload-artifact@v4 with: name: coverage path: coverage/ - - name: Upload deploy artifact + - name: Upload build artifact uses: actions/upload-artifact@v4 with: name: build path: dist/ sonarcloud: + name: SonarCloud Analysis runs-on: ubuntu-latest - needs: test-build + needs: test-build # Ensure SonarCloud job runs after the test-build job + if: ${{ github.event_name == 'pull_request' }} # Only run SonarCloud on pull requests steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Download coverage artifact uses: actions/download-artifact@v4 with: name: coverage path: coverage + - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master + uses: sonarsource/sonarcloud-github-action@v1.13 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} + -Dsonar.pullrequest.branch=${{ github.head_ref }} + -Dsonar.pullrequest.base=${{ github.base_ref }} diff --git a/sonar-project.properties b/sonar-project.properties index a6e57988e..87fb39a2b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,21 +1,16 @@ sonar.projectKey=InseeFr_Pogues sonar.organization=inseefr -sonar.host.url=https://sonarcloud.io -# Project name & version -sonar.projectName=Pogues -sonar.projectVersion=1.2.0 - -# Path to sources +# # Path to sources sonar.sources=src -sonar.exclusions=src/**/*.spec.js, jison/**/*, src/**/vtl-suggestions.js, src/**/__mocks__/* +sonar.exclusions=src/**/*.spec.jsx, jison/**/*, src/**/vtl-suggestions.jsx, src/**/__mocks__/* -# Path to tests -sonar.test.inclusions=src/**/*.spec.js +# # Path to tests +sonar.test.inclusions=src/**/*.spec.jsx -# Coverage -sonar.javascript.lcov.reportPaths=./coverage/lcov.info -sonar.coverage.exclusions=src/**/*.spec.js +# # Coverage +sonar.javascript.lcov.reportPaths=coverage/lcov.info +sonar.coverage.exclusions=src/**/*.spec.jsx -# Source encoding +# # Source encoding sonar.sourceEncoding=UTF-8 \ No newline at end of file