Skip to content

Commit

Permalink
Integrate SonarQube code analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Saeed Rezaee <[email protected]>
  • Loading branch information
SaeedRe committed Jan 19, 2024
1 parent 8490dc2 commit f00bd4a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/pipeline-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,33 @@ jobs:
uses: better0fdead/actions-setup-docker@better0fdead/increase-timeout

#Build without test on Windows or macOS (when not a PR)
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Cache SonarQube 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: Gradle build
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: |
if [[ "$RUNNER_OS" == "Windows" || ( "$RUNNER_OS" == "macOS" && ${{ github.event_name }} != 'pull_request' ) ]]; then
./gradlew build -x test
else
./gradlew build
./gradlew build sonar --info
fi
shell: bash
16 changes: 16 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins {
id 'java'
id 'com.github.jk1.dependency-license-report' version '1.16'
id("org.jetbrains.dokka") version "1.6.10"
id "org.sonarqube" version "4.4.1.3373"
}

repositories {
Expand All @@ -27,12 +28,27 @@ final def tdeps = gradle.settings.test_dependencies
final def app_version = '2.0.0'
ext.keep_test_container_alive = project.hasProperty('keep_test_container_alive') ? project.getProperty('keep_test_container_alive').toBoolean() : false

def sonarProjectKey = System.getenv("SONAR_CLOUD_PROJECT_KEY")
def sonarProjectName = System.getenv("SONAR_CLOUD_PROJECT_NAME")
def sonarProjectOrganization = System.getenv("SONAR_CLOUD_ORGANIZATION")

sonar {
properties {
property "sonar.projectKey", sonarProjectKey
property "sonar.projectName", sonarProjectName
property "sonar.organization", sonarProjectOrganization
property "sonar.sourceEncoding", "UTF-8"
property "sonar.host.url", "https://sonarcloud.io"
}
}

allprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'maven-publish'
apply from: "$rootDir/ktlint.gradle"
apply plugin: 'java'
apply plugin: "org.jetbrains.dokka"
apply plugin: "org.sonarqube"

repositories {
mavenCentral()
Expand Down

0 comments on commit f00bd4a

Please sign in to comment.