-
Notifications
You must be signed in to change notification settings - Fork 23
57 lines (57 loc) · 2.06 KB
/
sonar.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
name: Sonar
on:
workflow_run:
workflows: [ "Java CI with Gradle" ]
types:
- completed
jobs:
build:
name: Sonar
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{github.event.workflow_run.head_sha}}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Download IntegrationTest report
uses: actions/download-artifact@v4
with:
path: reports
pattern: kubernetes-integration-tests-reports
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{github.event.workflow_run.id}}
- name: Download UnitTest report
uses: actions/download-artifact@v4
with:
path: reports
pattern: ubuntu-latest-test-reports
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{github.event.workflow_run.id}}
- name: Download PrInfo
uses: actions/download-artifact@v4
with:
pattern: prInfo
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{github.event.workflow_run.id}}
- name: Create coverage report and run Sonar analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mkdir build
cp -r reports/*-reports/* build/
if [ '${{github.event.workflow_run.event}}' == 'pull_request' ]; then
PR_NUMBER=$(<prInfo/PR)
BASE_REF=$(<prInfo/base_ref)
HEAD_REF=$(<prInfo/head_ref)
./gradlew jacocoTestReport sonar -Dsonar.pullrequest.base=$BASE_REF -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=${{github.repository}}
else
./gradlew jacocoTestReport sonar
fi
shell: bash