diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ba210c4332..cf5504464d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,12 +145,30 @@ jobs: ctapipe-info --version + - name: Store info for sonar + env: + REF_NAME: ${{ github.ref_name }} + REF_TYPE: ${{ github.ref_type }} + PR_NUMBER: ${{ github.event.pull_request.number }} + SOURCE_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} + SOURCE_BRANCH: ${{ github.event.pull_request.head.ref }} + TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} + run: | + echo "PR_NUMBER=${PR_NUMBER}" >> sonar_env + echo "SOURCE_REPOSITORY=${SOURCE_REPOSITORY}" >> sonar_env + echo "SOURCE_BRANCH=${SOURCE_BRANCH}" >> sonar_env + echo "TARGET_BRANCH=${TARGET_BRANCH}" >> sonar_env + cat sonar_env + + # upload coverage report for sonar workflow - uses: actions/upload-artifact@v4 if: contains(matrix.extra-args, 'codecov') && contains(github.event.pull_request.labels.*.name, 'documentation-only') == false with: name: ctapipe-coverage-report - path: coverage.xml + path: | + coverage.xml + sonar_env docs: runs-on: ubuntu-latest diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 299302bc2f0..89849c2fc56 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -19,15 +19,6 @@ jobs: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' steps: - - name: Info - run: | - echo "Running Sonarqube action for PR ${PR_NUMBER} of ${REPOSITORY}:${PR_BRANCH} to ${PR_TARGET}" - env: - REPOSITORY: ${{ github.event.workflow_run.head_repository.full_name }} - PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }} - PR_BRANCH: ${{ github.event.workflow_run.pull_requests[0].head.ref }} - PR_TARGET: ${{ github.event.workflow_run.pull_requests[0].base.ref }} - - uses: actions/checkout@v4 with: repository: ${{ github.event.workflow_run.head_repository.full_name }} @@ -61,6 +52,11 @@ jobs: - name: Check artifact run: ls -l coverage + - name: Set environment + run: | + cat coverage/sonar_env >> "$GITHUB_ENV" + cat coverage/sonar_env + - name: Sonarqube Scan uses: SonarSource/sonarqube-scan-action@v2 env: @@ -70,6 +66,6 @@ jobs: 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 }} + -Dsonar.pullrequest.key=${PR_NUMBER} + -Dsonar.pullrequest.branch=${SOURCE_BRANCH} + -Dsonar.pullrequest.base=${TARGET_BRANCH}