From 985308bf0c2ffb0095af8c0e1c818b3ebe130df1 Mon Sep 17 00:00:00 2001 From: XiangRongLin <41164160+XiangRongLin@users.noreply.github.com> Date: Mon, 15 Mar 2021 19:21:53 +0100 Subject: [PATCH 1/2] Set the whole configDir instead of only configFile for checkstyle --- app/build.gradle | 2 +- checkstyle.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0b8de4d41..3f1803761 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -111,7 +111,7 @@ configurations { } checkstyle { - configFile rootProject.file('checkstyle.xml') + configDir rootProject.file(".") ignoreFailures false showViolations true toolVersion = checkstyleVersion diff --git a/checkstyle.xml b/checkstyle.xml index af8c5480f..61145d61f 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -22,8 +22,7 @@ - + From 72818ffa4257f72ac0181127b2a35656e5b39898 Mon Sep 17 00:00:00 2001 From: XiangRongLin <41164160+XiangRongLin@users.noreply.github.com> Date: Mon, 15 Mar 2021 09:51:51 +0100 Subject: [PATCH 2/2] Add sonar plugin and github actions file for sonar analysis Copied from sonarcloud.io setup page with minor adjustments. Adjusted branch to 'dev' and updated versions --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ app/build.gradle | 12 ++++++++++++ 2 files changed, 43 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25e16ddfe..2a58f5960 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,3 +40,34 @@ jobs: with: name: app path: app/build/outputs/apk/debug/*.apk + sonar: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Set up JDK 11 + uses: actions/setup-java@v1.4.3 + with: + java-version: 11 # Sonar requires JDK 11 + + - name: Cache SonarCloud packages + uses: actions/cache@v2 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache Gradle packages + uses: actions/cache@v2 + 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 \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 3f1803761..7a3f10e34 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,7 @@ +plugins { + id "org.sonarqube" version "3.1.1" +} + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' @@ -158,6 +162,14 @@ afterEvaluate { preDebugBuild.dependsOn formatKtlint, runCheckstyle, runKtlint } +sonarqube { + properties { + property "sonar.projectKey", "TeamNewPipe_NewPipe" + property "sonar.organization", "teamnewpipe" + property "sonar.host.url", "https://sonarcloud.io" + } +} + dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'