From 2b4dc4679242a56fa10c557218769d767d088cd0 Mon Sep 17 00:00:00 2001 From: Quentin Ruhier Date: Thu, 12 Sep 2024 10:54:12 +0200 Subject: [PATCH] ci : sonar only on PR --- .github/workflows/sonar.yml | 33 +++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 18 ------------------ 2 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/sonar.yml diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml new file mode 100644 index 000000000..e3920d1cd --- /dev/null +++ b/.github/workflows/sonar.yml @@ -0,0 +1,33 @@ +name: SonarCloud PR Analysis + +on: + pull_request: + branches: + - '**' # Trigger on pull requests targeting any branch + +jobs: + sonarcloud: + name: Sonar Analysis + runs-on: ubuntu-latest + needs: test-build + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Ensure full history is fetched for accurate analysis + + - name: Download coverage artifact + uses: actions/download-artifact@v4 + with: + name: coverage + path: coverage + + - name: SonarCloud Scan + 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/.github/workflows/test.yaml b/.github/workflows/test.yaml index a0d47a9a7..d8d0378b2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -31,21 +31,3 @@ jobs: with: name: build path: dist/ - - sonarcloud: - runs-on: ubuntu-latest - needs: test-build - 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 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}