forked from openwallet-foundation/acapy
-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (69 loc) · 3.18 KB
/
sonar-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Sonar Scan and Coverage
on:
workflow_run:
workflows: [ PR Tests ]
types:
- completed
jobs:
SonarCloud:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.repository == 'hyperledger/aries-cloudagent-python'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download PR number artifact
uses: dawidd6/action-download-artifact@v6
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@v1
with:
path: ./PR_NUMBER
- name: Download Test Coverage
uses: dawidd6/action-download-artifact@v6
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
name: TEST_COV
- name: Request GitHub API for PR data
uses: octokit/request-action@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: Move Coverage Report And Adjust Source
run: |
mkdir test-reports
mv coverage.xml test-reports
# Need to change source in coverage report because it was generated from another context
sed -i 's/\/home\/runner\/work\/aries-cloudagent-python\/aries-cloudagent-python\//\/github\/workspace\//g' test-reports/coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@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=test-reports/coverage.xml
-Dsonar.sources=./