From b5bcd7dda8847ce9a73041ddfaf9ce28f9de1160 Mon Sep 17 00:00:00 2001 From: Valeria Garcia Date: Mon, 20 May 2024 09:37:37 -0300 Subject: [PATCH] Hotfix ETO-325: Add sonarqube properties Rename Sonar github action --- .github/workflows/build.yml | 10 +++++++--- build.gradle | 40 +++++++++++++++++++++++++++++++++++-- gradle.properties.template | 9 +++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7c53adb..f1aa7a88 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,14 @@ -name: Build +name: Sonar Build on: pull_request: types: [opened, synchronize, reopened] + push: + branches: + - main + - develop jobs: build: - name: Build + name: Sonar Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -28,4 +32,4 @@ jobs: # - uses: sonarsource/sonarqube-quality-gate-action@master # timeout-minutes: 5 # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 18ad041a..d7671b5e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,11 @@ plugins { id 'java' id 'maven-publish' - id "org.sonarqube" version "2.6" + id "org.sonarqube" version "5.0.0.4638" id 'war' id 'idea' id 'groovy' + id 'jacoco' id 'com.etendoerp.gradleplugin' version '1.3.3' id 'org.kordamp.gradle.jandex' version '0.11.0' } @@ -112,12 +113,48 @@ publishing { } } +jacoco { + toolVersion = "0.8.10" +} + +jacocoTestReport { + executionData fileTree(dir: "$buildDir/jacoco", include: "**/*.exec") + reports { + xml.required = true + html.required = true + } +} + task exportProjectVersion doLast { ant.propertyfile(file: "version.properties") { entry(key: "version.tag", value: project.version) } } +/** + * Configuration for running static code analysis with SonarQube and generating code quality reports. + */ +sonarqube { + properties { + property "sonar.host.url", "$sonarHostUrl" + property "sonar.login", "$sonarToken" + property "sonar.projectBaseDir", "$sonarProjectBaseDir" + property "sonar.projectName", "$sonarProjectName" + property "sonar.projectKey", "$sonarProjectKey" + property "sonar.sourceEncoding", "UTF-8" + property "sonar.sources", "$sonarSources" + property "sonar.tests", "src-test/src" + property "sonar.java.coveragePlugin", "jacoco" + property "sonar.coverage.jacoco.xmlReportPaths", "$buildDir"+"/reports/jacoco/test/jacocoTestReport.xml" + property "sonar.projectVersion", "$sonarVersion" + property "sonar.branch.name", "$sonarBranchName" + property "sonar.scm.disabled", "true" + property "sonar.exclusions", "src-gen" + } +} + +tasks['sonarqube'].dependsOn jacocoTestReport + task upgradeCoreVersion { final String RELEASE = 'release' final String HOTFIX = 'hotfix' @@ -311,4 +348,3 @@ task call_sass(type: Exec) {} task deploySkin (dependsOn: ["cssCompile", "deploy.skin"]) doLast { } - diff --git a/gradle.properties.template b/gradle.properties.template index dd9ef29a..39b76b1e 100644 --- a/gradle.properties.template +++ b/gradle.properties.template @@ -13,3 +13,12 @@ bbdd.user=tad bbdd.password=tad org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +sonarHostUrl= +sonarToken= +sonarProjectBaseDir= +sonarProjectName= +sonarProjectKey= +sonarSources= +sonarBranchName= +sonarVersion= \ No newline at end of file