Skip to content

Commit

Permalink
Update code quality workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed May 15, 2024
1 parent fcc7156 commit d8defd5
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 53 deletions.
77 changes: 30 additions & 47 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
@@ -1,75 +1,58 @@
name: Code quality

on:
merge_group:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]

jobs:
android-lint:
if: github.event.pull_request.draft == false
name: Android Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- uses: reviewdog/action-setup@v1
- name: Run android linter
uses: gradle/gradle-build-action@v2
with:
arguments: lint
- name: review linter
uses: dvdandroid/action-android-lint@master
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
lint_xml_file: ./build/reports/android-lint.xml
reporter: github-pr-review
- name: check linter
uses: dvdandroid/action-android-lint@master
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
lint_xml_file: ./build/reports/android-lint.xml
reporter: github-pr-check
- uses: gradle/actions/setup-gradle@v3
- name: Run Android Lint
run: ./gradlew lint
- uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: build/reports/android-lint/
category: android-lint

detekt:
if: github.event.pull_request.draft == false
name: Detekt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- uses: reviewdog/action-setup@v1
- name: review detekt
uses: alaegin/[email protected]
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
detekt_config: config/detekt.yml
reviewdog_reporter: github-pr-review
detekt_excludes: "**/build/**,**/.idea/**,**/buildSrc/**,**/androidTest/**,**/test/**,**/resources/**"
- name: check detekt
uses: alaegin/[email protected]
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
detekt_config: config/detekt.yml
reviewdog_reporter: github-pr-check
detekt_excludes: "**/build/**,**/.idea/**,**/buildSrc/**,**/androidTest/**,**/test/**,**/resources/**"
- uses: gradle/actions/setup-gradle@v3
- name: Run Detekt
run: ./gradlew detekt
- uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: build/reports/detekt.sarif
category: detekt

android-unit-test:
if: github.event.pull_request.draft == false
unit-test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Run android local unit test
uses: gradle/gradle-build-action@v2
with:
arguments: testDebug
- uses: gradle/actions/setup-gradle@v3
- name: Run Unit Tests
run: ./gradlew testDebug
17 changes: 14 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.report.ReportMergeTask

plugins {
alias(libs.plugins.android.application) apply false
Expand All @@ -9,6 +10,12 @@ plugins {
alias(libs.plugins.detekt)
}

apply(plugin = "android-reporting")

val detektReportMerge by tasks.registering(ReportMergeTask::class) {
output.set(rootProject.layout.buildDirectory.file("reports/detekt.sarif"))
}

allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")

Expand All @@ -28,14 +35,18 @@ allprojects {
xml.required.set(false)
html.required.set(true)
txt.required.set(false)
sarif.required.set(false)
sarif.required.set(true)
md.required.set(false)
}
finalizedBy(detektReportMerge)
}

dependencies {
//noinspection UseTomlInstead
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0")
detektPlugins(libs.detekt.formatting)
}

detektReportMerge {
input.from(tasks.withType<Detekt>().map { it.sarifReportFile })
}
}

Expand Down
3 changes: 2 additions & 1 deletion data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ android {
lint {
// https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/dsl/LintOptions
abortOnError = false
sarifReport = true
sarifOutput = rootProject.layout.buildDirectory.file("reports/android-lint/${project.name}.sarif").get().asFile
}
publishing {
singleVariant("release") {
Expand All @@ -51,7 +53,6 @@ android {

dependencies {
api(libs.kotlinx.serialization.json)
detektPlugins(libs.detekt.formatting)

testImplementation(libs.robolectric)
testImplementation(libs.junit)
Expand Down
2 changes: 2 additions & 0 deletions dataprovider-paging/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ android {
lint {
// https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/dsl/LintOptions
abortOnError = false
sarifReport = true
sarifOutput = rootProject.layout.buildDirectory.file("reports/android-lint/${project.name}.sarif").get().asFile
}
publishing {
singleVariant("release") {
Expand Down
2 changes: 2 additions & 0 deletions dataprovider-retrofit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ android {
lint {
// https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/dsl/LintOptions
abortOnError = false
sarifReport = true
sarifOutput = rootProject.layout.buildDirectory.file("reports/android-lint/${project.name}.sarif").get().asFile
}
publishing {
singleVariant("release") {
Expand Down
4 changes: 2 additions & 2 deletions dataproviderdemo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ android {
abortOnError = true
checkAllWarnings = true
checkDependencies = false
xmlReport = true // Enable for Danger Android Lint
xmlOutput = file("${project.rootDir}/build/reports/android-lint.xml")
sarifReport = true
sarifOutput = rootProject.layout.buildDirectory.file("reports/android-lint/${project.name}.sarif").get().asFile
disable.add("LogConditional")
}
}
Expand Down

0 comments on commit d8defd5

Please sign in to comment.