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

Update Gradle configuration and GitHub Action workflow #40

Merged
merged 6 commits into from
May 21, 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
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ The library provides:
* Requests with Retrofit to get the usual metadata associated with SRG SSR productions.
* Gson serialization and deserialization.
* A flat object model to easily access the data relevant to front-end users.
* Dagger2 modules to easy integration.
18 changes: 14 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// 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
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.kotlin.android) apply false
// https://github.com/detekt/detekt
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 @@ -29,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
15 changes: 9 additions & 6 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.kapt)
`maven-publish`
}

Expand All @@ -25,6 +24,12 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

buildFeatures {
resValues = false
shaders = false
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -35,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 @@ -45,15 +52,11 @@ android {
}

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

testImplementation(libs.robolectric)
testImplementation(libs.junit)
testImplementation(libs.junit.ktx)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
testImplementation(libs.ext.junit)
}

publishing {
Expand Down
18 changes: 10 additions & 8 deletions dataprovider-paging/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

buildFeatures {
resValues = false
shaders = false
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -33,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 All @@ -43,14 +51,8 @@ android {
}

dependencies {
api(project(mapOf("path" to ":dataprovider-retrofit")))
implementation(libs.core.ktx)
implementation(libs.lifecycle.viewmodel.ktx)
api(libs.paging.runtime.ktx)

testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
api(project(":dataprovider-retrofit"))
api(libs.paging.common)
}

publishing {
Expand Down
20 changes: 11 additions & 9 deletions dataprovider-retrofit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

buildFeatures {
resValues = false
shaders = false
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -33,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 All @@ -43,21 +51,15 @@ android {
}

dependencies {
api(project(mapOf("path" to ":data")))
implementation(libs.core.ktx)
api(libs.lifecycle.livedata.ktx)

//retrofit implementation
api(project(":data"))
api(libs.retrofit)
compileOnly(libs.androidx.annotation)
implementation(libs.retrofit2.kotlinx.serialization.converter)
//noinspection GradleDependency
implementation(libs.logging.interceptor)

testImplementation(libs.junit.ktx)
testImplementation(libs.junit)
testRuntimeOnly(libs.robolectric)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
testImplementation(libs.ext.junit)
}

publishing {
Expand Down
19 changes: 9 additions & 10 deletions dataproviderdemo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
}

android {
Expand Down Expand Up @@ -32,6 +31,11 @@ android {
}
}

buildFeatures {
resValues = false
shaders = false
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -45,21 +49,16 @@ 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")
}
}

dependencies {
implementation(project(mapOf("path" to ":dataprovider-retrofit")))
implementation(project(mapOf("path" to ":dataprovider-paging")))
implementation(libs.core.ktx)
implementation(project(":dataprovider-retrofit"))
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.constraintlayout)

testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
implementation(libs.lifecycle.viewmodel)
}
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=true
android.nonFinalResIds=true
Loading
Loading