Skip to content

Commit

Permalink
test: sonar cloud integration #1
Browse files Browse the repository at this point in the history
  • Loading branch information
GiuMontesano committed Sep 6, 2024
1 parent 4d6785d commit ff47d95
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: SonarCloud
on:
push:
branches:
- main
#todo remove v
- test/sonarcloud
#todo remove ^
paths:
- "**/src/**"
- "**pom.xml"
- ".github/workflows/code-review.yml"
pull_request_target:
types:
- opened
- edited
- synchronize
paths:
- "**/src/**"
- "**pom.xml"
- ".github/workflows/code-review.yml"
jobs:
build:
runs-on: ubuntu-22.04
env:
AWS_REGION: eu-south-1
AWS_ACCESS_KEY_ID: dummy
AWS_SECRET_KEY: dummy
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- name: Set up JDK 21
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
distribution: 'temurin'
java-version: '21'
- name: Prepare SonarCloud analysis configuration
run: >
mvn -Bclean org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report org.jacoco:jacoco-maven-plugin:report-aggregate
-DpublishJUnitResults=true
-DtestResultsFiles='**/surefire-reports/TEST-*.xml'
-DjavaHomeOption='JDKVersion'
-DmavenVersionOption='Default'
-DmavenAuthenticateFeed=false
-DeffectivePomSkip=false
-DsonarQubeRunAnalysis=false
- name: finding jacoco.xml
run: |
xmlReportPaths=$(find "$(pwd)" -path '*jacoco.xml' | sed 's/.*/&/' | tr '\n' ','); echo "##vso[task.setvariable variable=xmlReportPaths]$xmlReportPaths"
- name: Analyze with SonarCloud
run: >
mvn -B sonar:sonar
-Dsonar.coverage.jacoco.xmlReportPaths=$xmlReportPaths
-Dsonar.projectName=$SONARCLOUD_PROJECT_NAME
-Dsonar.projectKey=$SONARCLOUD_PROJECT_KEY
-Dsonar.organization=pagopa
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.login=$SONAR_TOKEN
-Dsonar.exclusions='**/enums/**, **/model/**, **/*Constant*, **/*Config.java, **/*Scheduler.java, **/*Application.java, **/src/test/**, **/Dummy*.java'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONARCLOUD_PROJECT_KEY: ${{ vars.SONARCLOUD_PROJECT_KEY }}
SONARCLOUD_PROJECT_NAME: ${{ vars.SONARCLOUD_PROJECT_NAME }}

0 comments on commit ff47d95

Please sign in to comment.