diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000000..a94fe9404a --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,42 @@ + +name: SonarCloud analysis + +on: + schedule: + # * is a special character in YAML so you have to quote this string + # expression evaluates to midnight on Tuesdays UTC + - cron: '0 0 * * 2' + +permissions: + pull-requests: read # allows SonarCloud to decorate PRs with analysis results + +jobs: + Analysis: + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Gradle packages + uses: actions/cache@v1 + 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 build sonarqube --info + diff --git a/build.gradle b/build.gradle index ee5f488d7b..a4dca8ef1d 100644 --- a/build.gradle +++ b/build.gradle @@ -28,8 +28,21 @@ plugins { id 'me.champeau.jmh' version '0.6.6' apply false id 'net.ltgt.errorprone' version '2.0.2' id 'maven-publish' + id 'org.sonarqube' version '3.4.0.2513' } +sonarqube { + properties { + property "sonar.projectKey", "hyperledger_besu" + property "sonar.organization", "hyperledger" + property "sonar.host.url", "https://sonarcloud.io" + property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml" + property "sonar.coverage.exclusions", "acceptance-tests/**/*" + } +} + +project.tasks["sonarqube"].dependsOn "jacocoRootReport" + if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { throw new GradleException("Java 17 or later is required to build Besu.\n" + " Detected version ${JavaVersion.current()}") @@ -862,7 +875,7 @@ task checkSpdxHeader(type: CheckSpdxHeader) { "(.*/.idea/.*)", "(.*/out/.*)", "(.*/build/.*)", - "(.*/src/[^/]+/generated/.*)", + "(.*/src/[^/]+/generated/.*)" ].join("|") } diff --git a/gradle.properties b/gradle.properties index 2e2a4bbdbf..2061eb9c1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ version=23.1.1-SNAPSHOT org.gradle.welcome=never # Set exports/opens flags required by Google Java Format and ErrorProne plugins. (JEP-396) -org.gradle.jvmargs=-Xmx2g \ +org.gradle.jvmargs=-Xmx4g \ --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ --add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \ diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index a922547577..6ad80febdb 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -5365,6 +5365,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradlew b/gradlew index 1b6c787337..aef870434d 100755 --- a/gradlew +++ b/gradlew @@ -86,7 +86,7 @@ APP_NAME="Gradle" APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +DEFAULT_JVM_OPTS='"-Xmx1024m" "-Xms256m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum