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

Sonar workflow #5844

Merged
merged 2 commits into from
Mar 20, 2021
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: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 13 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -111,7 +115,7 @@ configurations {
}

checkstyle {
configFile rootProject.file('checkstyle.xml')
configDir rootProject.file(".")
ignoreFailures false
showViolations true
toolVersion = checkstyleVersion
Expand Down Expand Up @@ -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'

Expand Down
3 changes: 1 addition & 2 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<module name="SuppressionFilter">
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
default="checkstyle-suppressions.xml" />
<property name="file" value="${config_loc}/checkstyle-suppressions.xml" />
<property name="optional" value="true"/>
</module>

Expand Down