Skip to content

Commit

Permalink
Store PR info via artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jul 9, 2024
1 parent 5346b04 commit 812e03a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -61,6 +52,13 @@ jobs:
- name: Check artifact
run: ls -l coverage

- name: Set environment
run: |
if [ -f "coverage/sonar_env" ]; then
cat coverage/sonar_env >> "$GITHUB_ENV"
cat coverage/sonar_env
fi
- name: Sonarqube Scan
uses: SonarSource/sonarqube-scan-action@v2
env:
Expand All @@ -70,6 +68,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}

0 comments on commit 812e03a

Please sign in to comment.