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

CI #7

Merged
merged 1 commit into from
May 28, 2024
Merged

CI #7

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
8 changes: 8 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ android {
}
}
}
lint {
warningsAsErrors = true
abortOnError = true
baseline = file("lint-baseline.xml")
checkReleaseBuilds = false
ignoreTestSources = true
checkDependencies = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down
5 changes: 5 additions & 0 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues name="AGP (7.4.0-alpha09)" by="lint 7.4.0-alpha09" client="gradle" dependencies="true" format="6"
type="baseline" variant="all" version="7.4.0-alpha09">

</issues>
110 changes: 110 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,116 @@ plugins {
alias(libs.plugins.dagger.hilt.android) apply false
alias(libs.plugins.google.services) apply false
alias(libs.plugins.serialization) apply false

// CI plugins
alias(libs.plugins.ci.detekt)
alias(libs.plugins.ci.ktlint)
alias(libs.plugins.ci.spotless)
}

val ktlintVersion: String = libs.versions.ktlint.get()

subprojects {
apply {
plugin("io.gitlab.arturbosch.detekt")
plugin("org.jlleitschuh.gradle.ktlint")
plugin("com.diffplug.spotless")
}

ktlint {
debug.set(false)
version.set(ktlintVersion)
verbose.set(true)
android.set(false)
outputToConsole.set(true)
ignoreFailures.set(false)
enableExperimentalRules.set(true)
filter {
exclude("**/generated/**")
include("**/kotlin/**")
}
}

spotless {
kotlin {
target(
fileTree(
mapOf(
"dir" to ".",
"include" to listOf("**/*.kt"),
"exclude" to listOf("**/build/**", "**/spotless/*.kt")
)
)
)
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
val delimiter = "^(package|object|import|interface|internal|@file|//startfile)"
val licenseHeaderFile = rootProject.file("spotless/copyright.kt")
licenseHeaderFile(licenseHeaderFile, delimiter)
}
}

tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
// Treat all Kotlin warnings as errors (disabled by default)
// allWarningsAsErrors = project.hasProperty("warningsAsErrors") ? project.warningsAsErrors : false
// Opt-in to experimental compose APIs
freeCompilerArgs = freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn")

jvmTarget = "17"
}
}

withType<Test>().configureEach {
jvmArgs = listOf(
"-Dkotlintest.tags.exclude=Integration,EndToEnd,Performance",
)
testLogging {
events("passed", "skipped", "failed")
}
testLogging.showStandardStreams = true
useJUnitPlatform()
}
}
}

tasks {

withType<Test>().configureEach {
jvmArgs = listOf(
"-Dkotlintest.tags.exclude=Integration,EndToEnd,Performance",
)
testLogging {
events("passed", "skipped", "failed")
}
testLogging.showStandardStreams = true
useJUnitPlatform()
}

register<io.gitlab.arturbosch.detekt.Detekt>("templateDetekt") {
description = "Runs a custom detekt build."
setSource(files("src/main/kotlin", "src/test/kotlin"))
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
debug = true
reports {
xml.required.set(true)
xml.outputLocation.set(file("build/reports/detekt/detekt.xml"))
html.required.set(true)
txt.required.set(true)
}
include("**/*.kt")
include("**/*.kts")
exclude("resources/")
exclude("build/")
include("**/*.kt")
include("**/*.kts")
exclude(".*/resources/.*")
exclude(".*/build/.*")
exclude("/versions.gradle.kts")
exclude("buildSrc/settings.gradle.kts")
}
}

buildscript {
Expand Down
8 changes: 7 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ firebase-crashlytics = "3.0.1"
firebase-perfs = "1.4.2"
lifecycleCommon = "2.8.0"
lifecycleService = "2.8.0"
detekt = "1.23.6"
ktlint = "12.1.1"
spotless = "6.3.0"

[libraries]
accompanist-drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanistDrawablepainter" }
Expand Down Expand Up @@ -85,4 +88,7 @@ dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hi
google-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebase-crashlytics" }
firebase-perf = { id = "com.google.firebase.firebase-perf", version.ref = "firebase-perfs" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ci-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
ci-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
ci-spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
15 changes: 15 additions & 0 deletions spotless/copyright.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright $YEAR Angel Studio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Loading