Skip to content

Sonar Scan and Coverage on PRs #2799

Sonar Scan and Coverage on PRs

Sonar Scan and Coverage on PRs #2799

Workflow file for this run

name: Sonar Scan and Coverage on PRs
on:
workflow_run:
workflows: [ PR Tests ]
types:
- completed
permissions:
contents: read
pull-requests: read
checks: write
jobs:
SonarCloud:
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@5c98f0b039f36ef966fdb7dfa9779262785ecb05 # v14
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@b549046febe0fe86f8cb4f93c24e284433f9ab58 # v1.1.7
with:
path: ./PR_NUMBER
- name: Download Test Coverage
uses: dawidd6/action-download-artifact@5c98f0b039f36ef966fdb7dfa9779262785ecb05 # v14
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
name: TEST_COV
- name: Request GitHub API for PR data
uses: octokit/request-action@05a2312de9f8207044c4c9e41fe19703986acc13 # 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@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # 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=./