diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1357fe0c..45b340ae 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -name: PR's +name: PRs on: pull_request: types: [opened, synchronize, reopened] @@ -21,7 +21,9 @@ jobs: - uses: ./.github/actions/setup - name: Execute commitlint - run: npx commitlint --from=origin/${{ github.base_ref }} + run: npx commitlint --from="origin/$BASE_REF" + env: + BASE_REF: ${{ github.base_ref }} check-file-format: name: Check files changes follow guidelines @@ -36,25 +38,3 @@ jobs: backwards-compatibility-test: needs: [pr-test] uses: ./.github/workflows/backwards-compatibility-test.yml - - pr-analysis: - name: SonarCloud Pr Analysis - runs-on: ubuntu-latest - needs: pr-test - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - # Download reports - - uses: ./.github/actions/download-coverage-report - - uses: ./.github/actions/download-lint-report - - - 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.SONARQUBE_SCANNER }} - with: - args: > - -Dsonar.pullrequest.key=${{ github.env.PR_NUMBER }} diff --git a/.github/workflows/sonar-pr.yml b/.github/workflows/sonar-pr.yml new file mode 100644 index 00000000..d1e64372 --- /dev/null +++ b/.github/workflows/sonar-pr.yml @@ -0,0 +1,33 @@ +name: Sonar for PRs +on: + workflow_run: + workflows: ['PRs'] + types: [requested] +jobs: + sonar: + name: Sonar + runs-on: ubuntu-latest + timeout-minutes: 30 + if: github.event.workflow_run.conclusion == 'success' + steps: + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.workflow_run.head_repository.full_name }} + ref: ${{ github.event.workflow_run.head_branch }} + fetch-depth: 0 + + # Download reports + - uses: ./.github/actions/download-coverage-report + - uses: ./.github/actions/download-lint-report + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} + -Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }} + -Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }} + -Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }}