Skip to content

Commit

Permalink
added sonar integration
Browse files Browse the repository at this point in the history
  • Loading branch information
patotskiy committed Oct 24, 2024
1 parent fc79816 commit 48f1d80
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/sonar-cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: SonarCloud
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew test sonar --info
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ plugins {
id "com.diffplug.spotless" version "6.23.3"
id 'jacoco-report-aggregation'
id 'io.github.surpsg.delta-coverage' version "2.5.0"
id 'org.sonarqube' version "5.1.0.4882"
// id "io.github.gw-kit.delta-coverage" version "3.0.0-RC1"

// TODO id "org.gradlex.java-ecosystem-capabilities" version "1.0"
Expand Down Expand Up @@ -282,6 +283,18 @@ project.ext.externalDependency = [
'mustache': 'com.github.spullara.mustache.java:compiler:0.9.14'
]

sonarqube {
properties {
property "sonar.sourceEncoding", "UTF-8"
property "sonar.projectKey", "datahub-project_datahub"
property "sonar.organization", "datahub-project"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir.parentFile.path/build/reports/jacoco/test/jacocoTestReport.xml"

property "sonar.python.coverage.reportPaths", "https://sonarcloud.io"
}
}

allprojects {
apply plugin: 'idea'
apply plugin: 'eclipse'
Expand Down Expand Up @@ -379,6 +392,7 @@ subprojects {
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'

if (!project.name.contains('docker')
&& !project.name.contains('web-react')
Expand Down Expand Up @@ -472,6 +486,13 @@ subprojects {
}
}

sonarqube {
properties {
property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir.parentFile.path/build/reports/jacoco/test/jacocoTestReport.xml"
p
}
}

if (project.plugins.hasPlugin('pegasus')) {
dependencies {
dataTemplateCompile spec.product.pegasus.data
Expand Down
4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sonar.projectKey=datahub-project_datahub
sonar.sources=.
sonar.organization=datahub-project
sonar.host.url=https://sonarcloud.io

0 comments on commit 48f1d80

Please sign in to comment.