Skip to content

Commit 03607ca

Browse files
sraptis-scyvkanellopoulos
authored andcommitted
correct sonar.yml & gradle.properties for sonar analysis
1 parent 2d3a8a6 commit 03607ca

File tree

2 files changed

+94
-8
lines changed

2 files changed

+94
-8
lines changed

.github/workflows/sonar.yml

Lines changed: 93 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,97 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
SAST_caller:
11-
uses: eu-digital-identity-wallet/eudi-infra-ci/.github/workflows/sast_bt_testDebugUnitTestCoverage.yml@main
12-
secrets:
10+
check-secrets:
11+
name: Check secrets presence
12+
env:
1313
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
14-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15-
DOJO_TOKEN: ${{ secrets.DOJO_TOKEN }}
16-
DOJO_URL: ${{ secrets.DOJO_URL }}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- run: if [[ -z "$SONAR_TOKEN" ]]; then exit 1; fi
17+
18+
analysis:
19+
name: Analysis
20+
needs: check-secrets
21+
env:
22+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
23+
DEFECT_DOJO_TOKEN: ${{ secrets.DOJO_TOKEN }}
24+
DEFECT_DOJO_URL: ${{ secrets.DOJO_URL }}
25+
runs-on: ubuntu-latest
26+
steps:
27+
- run: echo "ORGANIZATION=${{ github.repository_owner}}" >> $GITHUB_ENV
28+
- run: echo "PROJECT_KEY=${{ github.repository_owner}}_$(echo ${{ github.repository }} | sed 's/.*\///')" >> $GITHUB_ENV
29+
- run: echo "SCAN_DATE=$(TZ='EET' date '+%Y-%m-%d')" >> $GITHUB_ENV
30+
- uses: actions/checkout@v5
31+
with:
32+
fetch-depth: 0
33+
- uses: actions/setup-java@v5
34+
with:
35+
distribution: temurin
36+
java-version: '17'
37+
- uses: gradle/actions/wrapper-validation@v5
38+
- uses: gradle/actions/setup-gradle@v5
39+
- run: ./gradlew clean test koverXmlReport
40+
- uses: sonarsource/[email protected]
41+
if: (github.event_name == 'push'|| github.event_name == 'workflow_dispatch')
42+
with:
43+
projectBaseDir: ${{ github.workspace }}
44+
args: >
45+
-Dsonar.organization=${{ env.ORGANIZATION }}
46+
-Dsonar.projectKey=${{ env.PROJECT_KEY }}
47+
-Dsonar.scanner.skipJreProvisioning=true
48+
-Dsonar.language=kotlin
49+
-Dsonar.coverage.jacoco.xmlReportPaths=document-manager/build/reports/kover/report.xml
50+
-Dsonar.kotlin.coverage.reportPaths=document-manager/build/reports/kover/report.xml
51+
-Dsonar.kotlin.multiplatform.reportPaths=document-manager/build/reports/kover/report.xml
52+
-Dsonar.sources=document-manager/src/main
53+
-Dsonar.tests=document-manager/src/test
54+
-Dsonar.java.binaries=document-manager/build/classes/kotlin/main
55+
-Dsonar.kotlin.binaries=document-manager/build/classes/kotlin/main
56+
- uses: sonarsource/[email protected]
57+
if: (github.event_name == 'pull_request_target')
58+
with:
59+
projectBaseDir: ${{ github.workspace }}
60+
args: >
61+
-Dsonar.organization=${{ env.ORGANIZATION }}
62+
-Dsonar.projectKey=${{ env.PROJECT_KEY }}
63+
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
64+
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
65+
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
66+
-Dsonar.scanner.skipJreProvisioning=true
67+
-Dsonar.language=kotlin
68+
-Dsonar.coverage.jacoco.xmlReportPaths=document-manager/build/reports/kover/report.xml
69+
-Dsonar.kotlin.coverage.reportPaths=document-manager/build/reports/kover/report.xml
70+
-Dsonar.kotlin.multiplatform.reportPaths=document-manager/build/reports/kover/report.xml
71+
-Dsonar.sources=document-manager/src/main
72+
-Dsonar.tests=document-manager/src/test
73+
-Dsonar.java.binaries=document-manager/build/classes/kotlin/main
74+
-Dsonar.kotlin.binaries=document-manager/build/classes/kotlin/main
75+
- uses: actions/setup-node@v6
76+
if: (github.repository_owner == 'eu-digital-identity-wallet' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch'))
77+
with:
78+
node-version: 18
79+
- name: Publish Sonar Report
80+
if: (github.repository_owner == 'eu-digital-identity-wallet' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch'))
81+
run: |
82+
npm cache clean --force
83+
npm install -g [email protected]
84+
sonar-report \
85+
--sonarurl="https://sonarcloud.io" \
86+
--sonarorganization="${{ env.ORGANIZATION }}" \
87+
--branch="${{ github.ref_name }}" \
88+
--sonartoken="${{ secrets.SONAR_TOKEN }}" \
89+
--output sonarreport.html \
90+
--application="${{ env.PROJECT_KEY }}" \
91+
--sonarcomponent="${{ env.PROJECT_KEY }}"
92+
curl -X POST "${{ env.DEFECT_DOJO_URL }}/api/v2/reimport-scan/" \
93+
-H "Authorization: Token $DEFECT_DOJO_TOKEN" \
94+
-F "active=true" \
95+
-F "scan_type=SonarQube Scan detailed" \
96+
-F "minimum_severity=Info" \
97+
-F "skip_duplicates=true" \
98+
-F "close_old_findings=true" \
99+
100+
-F "scan_date=${{ env.SCAN_DATE }}" \
101+
-F "auto_create_context=True" \
102+
-F "product_name=${{ github.repository }}-${{ github.ref_name }}" \
103+
-F "engagement_name=Static Application Security Testing - ${{ github.repository }}-${{ github.ref_name }}"

gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ android.nonTransitiveRClass=true
4040

4141
systemProp.sonar.host.url=https://sonarcloud.io
4242
systemProp.sonar.gradle.skipCompile=true
43-
systemProp.sonar.coverage.reportPaths=build/reports/kover/xml/report.xml
44-
systemProp.sonar.projectName=eudi-lib-android-wallet-document-manager
43+
4544
VERSION_NAME=0.13.0-SNAPSHOT
4645

4746
SONATYPE_HOST=CENTRAL_PORTAL

0 commit comments

Comments
 (0)