Skip to content

Sonar Scan and Coverage on PRs #2938

Sonar Scan and Coverage on PRs

Sonar Scan and Coverage on PRs #2938

Workflow file for this run

name: Sonar Scan and Coverage on PRs
on:
workflow_run:
workflows: [ PR Tests ]
types:
- completed
jobs:
SonarCloud:
permissions:
contents: read
pull-requests: read
checks: write
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.repository == 'openwallet-foundation/acapy'
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
fetch-depth: 0
- name: Download PR number artifact
uses: dawidd6/action-download-artifact@b6e2e70617bc3265edd6dab6c906732b2f1ae151 # v21
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
name: PR_NUMBER
- name: Read PR_NUMBER
id: pr_number
uses: juliangruber/read-file-action@271ff311a4947af354c6abcd696a306553b9ec18 # v1.1.8
with:
path: ./PR_NUMBER
- name: Download Test Coverage
uses: dawidd6/action-download-artifact@b6e2e70617bc3265edd6dab6c906732b2f1ae151 # v21
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
name: TEST_COV
- name: Request GitHub API for PR data
uses: octokit/request-action@45eef13998ff762839b0a0de9bbcf41970fd056d # v2.x
id: get_pr_data
with:
route: GET /repos/${{ github.event.repository.full_name }}/pulls/${{ steps.pr_number.outputs.content }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout base branch
run: |
echo forked repo = ${{ fromJson(steps.get_pr_data.outputs.data).head.repo.html_url }}.git
echo base repo = ${{ github.event.repository.clone_url }}
git remote add upstream ${{ fromJson(steps.get_pr_data.outputs.data).head.repo.html_url }}.git
git fetch --all
echo pr number = ${{ fromJson(steps.get_pr_data.outputs.data).number }}
echo forked branch = ${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
echo base branch = ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
git checkout -B temp-branch-for-scanning upstream/${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@7006c4492b2e0ee0f816d36501671557c97f5995 # 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=${{ fromJson(steps.get_pr_data.outputs.data).number }}
-Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
-Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
-Dsonar.coverage.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.cpd.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.sources=./