-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from buildkite/tech/code-quality-enhancements
Introduce Static Code Analysis and Refine Encapsulation in SDK
- Loading branch information
Showing
41 changed files
with
1,361 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Yaml Lint | ||
on: | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- '**.yml' | ||
|
||
jobs: | ||
yamllint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: yaml-lint | ||
uses: reviewdog/[email protected] | ||
with: | ||
level: error | ||
reporter: github-pr-review | ||
yamllint_flags: '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
extends: default | ||
ignore: | | ||
/build/ | ||
rules: | ||
document-start: disable | ||
line-length: disable | ||
truthy: disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
group = "com.buildkite.test.collector.buildlogic" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
dependencies { | ||
implementation(libs.detekt.gradlePlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("staticCodeAnalysis") { | ||
id = "buildkite.static-code-analysis" | ||
implementationClass = "StaticCodeAnalysisConventionPlugin" | ||
} | ||
register("gitHooks") { | ||
id = "buildkite.git-hooks" | ||
implementationClass = "GitHooksConventionPlugin" | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
build-logic/convention/src/main/kotlin/GitHooksConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.Copy | ||
import org.gradle.api.tasks.Exec | ||
|
||
class GitHooksConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
tasks.register(TASK_COPY_HOOKS, Copy::class.java) { | ||
from("$rootDir/support/scripts/git") { | ||
include("pre-push") | ||
} | ||
into("$rootDir/.git/hooks") | ||
} | ||
tasks.register(TASK_INSTALL_HOOKS, Exec::class.java) { | ||
workingDir(rootDir) | ||
outputs.dir("$rootDir/.git/hooks") | ||
commandLine("chmod") | ||
args("-R", "+x", ".git/hooks") | ||
dependsOn(tasks.named(TASK_COPY_HOOKS)) | ||
} | ||
|
||
tasks.getByPath(":example:preBuild").dependsOn(tasks.named(TASK_INSTALL_HOOKS)) | ||
} | ||
} | ||
|
||
private companion object { | ||
const val TASK_COPY_HOOKS = "copyGitHooks" | ||
const val TASK_INSTALL_HOOKS = "installGitHooks" | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
build-logic/convention/src/main/kotlin/StaticCodeAnalysisConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import io.gitlab.arturbosch.detekt.Detekt | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class StaticCodeAnalysisConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("io.gitlab.arturbosch.detekt") | ||
} | ||
|
||
fun Detekt.commonDetektConfiguration() { | ||
parallel = true | ||
buildUponDefaultConfig = true | ||
setSource(file(projectDir)) | ||
config.setFrom(file("$rootDir/support/vendor/detekt/detekt.yml")) | ||
include("**/*.kt") | ||
include("**/*.kts") | ||
exclude("**/resources/**") | ||
exclude("**/build/**") | ||
reports { | ||
xml.required.set(false) | ||
html.required.set(true) | ||
} | ||
} | ||
|
||
tasks.register(TASK_DETEKT_ALL, Detekt::class.java) { | ||
description = "Run lint check for whole project" | ||
commonDetektConfiguration() | ||
} | ||
|
||
tasks.register(TASK_DETEKT_FORMAT, Detekt::class.java) { | ||
description = "Format lint errors for whole project" | ||
autoCorrect = true | ||
commonDetektConfiguration() | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
dependencies { | ||
add( | ||
configurationName = "detektPlugins", | ||
dependencyNotation = libs.findLibrary("detekt.formatting").get() | ||
) | ||
} | ||
} | ||
} | ||
|
||
private companion object { | ||
const val TASK_DETEKT_ALL = "detektAll" | ||
const val TASK_DETEKT_FORMAT = "detektFormat" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "build_logic" | ||
include(":convention") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.