Skip to content

Commit

Permalink
Merge pull request #607 from ehrbase/feature/fix-github-action-sonar-…
Browse files Browse the repository at this point in the history
…access

Add sonar analyses as workflow_run
  • Loading branch information
vmueller-vg authored May 27, 2024
2 parents e26f095 + d7919c9 commit 5c187de
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/report-sonar-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Report Sonar Results"

# we have multiple workflows - this helps to distinguish for them
run-name: "${{ github.event.pull_request.title && github.event.pull_request.title || github.ref_name }} - Report Sonar Results"

on:
workflow_run:
workflows: ["Build & Test"] # runs after build and test workflow
types:
- completed

jobs:
#
# Collect Junit reports generated by build_and_test
#
collect-junit-reports:
runs-on: ubuntu-latest
steps:

# Download jacoco overall coverage from build & test output
- name: Download - Jacoco Overall Coverage
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run-id: ${{ github.event.workflow_run.id }} # download artifacts from build and test workflow
pattern: jacoco-coverage-overall # uses artifact of build and test workflow
merge-multiple: true
path: ./

- name: Sonar - Analyze
# Dependabot has no access to the SONAR_TOKEN secret, so we need to skip sonar.
# if: ${{ github.actor != 'dependabot[bot]' && github.repository_owner == 'ehrbase' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn --batch-mode sonar:sonar \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.organization=ehrbase \
-Dsonar.projectKey=ehrbase_openEHR_SDK \
-Dsonar.exclusions=test/** \
-Dsonar.coverage.exclusions=test/**,test-data/**/*,opt-14/**/*,response-dto/**/* \
-Dsonar.coverage.jacoco.xmlReportPaths=${{ github.workspace }}/test-coverage/target/site/jacoco-overall-coverage/jacoco.xml

0 comments on commit 5c187de

Please sign in to comment.