-
Notifications
You must be signed in to change notification settings - Fork 11
Code Quality and Coverage
- Tools
- Scheme
- Running and publishing reports to SonarCloud from local machine
- Running SonarCloud analysis using GitHub Actions
- Example
The following tools are used for code coverage and static code analysis:
- JaCoCo Java code coverage plugin - Jacoco
- SonarQube plugin - SonarQube
- SonarCloud service - SonarCloud
Make sure that Gradle task sonarqube
in build.gradle
file is correctly configured:
The credentials can be obtained from Vitalii Kulinsky
In order to push coverage and other code analysis data you need to run Gradle task sonarqube
:
- From IntelliJ IDEA select the Gradle tab and run
sonarqube
task
- After completion you will find report data in your SonarCloud(SonarQube) UI.
The credentials and instructions for GitHub Actions can be found in the SonarCloud account in the Administration -> Analysis Method section:
Sonar token obtained from the previous step should be added to the GitHub repository settings in the Secrets section:
sonarqube {
tasks['sonarqube'].dependsOn jacocoTestReport
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.projectKey", "ita-social-projects_dokazovi-be"
property "sonar.organization", "ita-social-projects"
property "sonar.jacoco.reportPaths", "$buildDir/reports/jacoco/test/jacocoTestReport.xml"
property "sonar.coverage.exclusions", "**/*.sql," +
"src/main/java/com/softserveinc/dokazovi/entity/**," +
"src/main/java/com/softserveinc/dokazovi/dto/**," +
"src/main/java/com/softserveinc/dokazovi/config/**"
}
}
sonarqube
task depends on jacocoTestReport
task since it generates coverage reports used by the Sonar scanner.
In turn jacocoTestReport
depends on test
task.
Workflow for SonarCloud Code Analysis is located in develop/.github/workflows/Build_and_Test.yml file.
The action is triggered when new code is pushed to the develop branch or when Pull-request is created or changed.
As a result of workflow SonarCloud status bar will be reflected in the pull request: