Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate SonarQube code analysis #35

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions .github/workflows/pipeline-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- name: Check repository
uses: actions/checkout@v3
uses: actions/checkout@v4


- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand All @@ -25,12 +26,38 @@ jobs:
if: ${{ matrix.os == 'macos-latest' && github.event_name == 'pull_request' }}
uses: better0fdead/actions-setup-docker@better0fdead/increase-timeout

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

#Build without test on Windows or macOS (when not a PR)
- name: Gradle build
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_CLOUD_ORGANIZATION: ${{ vars.SONAR_CLOUD_ORGANIZATION }}
SONAR_CLOUD_PROJECT_KEY: ${{ vars.SONAR_CLOUD_PROJECT_KEY }}
SONAR_CLOUD_PROJECT_NAME: ${{ vars.SONAR_CLOUD_PROJECT_NAME }}
run: |
if [[ "$RUNNER_OS" == "Windows" || ( "$RUNNER_OS" == "macOS" && ${{ github.event_name }} != 'pull_request' ) ]]; then
./gradlew build -x test
else
./gradlew build
./gradlew build --scan 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
Loading