Skip to content

Commit

Permalink
WIP: Danger.systems Integration (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
r0adkll authored Aug 10, 2023
1 parent 4a1822b commit 7ffdb37
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ ij_kotlin_imports_layout = *
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true

[*.df.kts]
ktlint_standard_no-wildcard-imports = disabled

[*.sq]
indent_size = 2
ij_continuation_indent_size = 2
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ on:
pull_request:

jobs:
danger:
runs-on: ubuntu-latest
name: "danger"
steps:
- uses: actions/checkout@v1
- name: Danger
uses: docker://ghcr.io/danger/danger-kotlin:1.2.0
with:
args: --failOnErrors --no-publish-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

code-style:
needs: [danger]
runs-on: macos-latest
timeout-minutes: 60
# env:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ report.xml
Preview.html
screenshots/**/*.png
test_output
/.idea/appInsightsSettings.xml
/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata
/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
9 changes: 9 additions & 0 deletions .idea/kotlinScripting.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Dangerfile.df.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import systems.danger.kotlin.*

danger(args) {

val allSourceFiles = git.modifiedFiles + git.createdFiles
val changelogChanged = allSourceFiles.contains("CHANGELOG.md")
val sourceChanges = allSourceFiles.firstOrNull { it.contains("src") }

onGitHub {
val isTrivial = pullRequest.title.contains("#trivial")

message("This PR has been checked by Danger")

// Changelog
if (!isTrivial && !changelogChanged && sourceChanges != null) {
warn(
"any changes to library code should be reflected in the Changelog.\n\n" +
"Please consider adding a note there and adhere to the " +
"[Changelog Guidelines](https://github.com/Moya/contributors/blob/master/Changelog%20Guidelines.md).",
)
}

// Big PR Check
if ((pullRequest.additions ?: 0) - (pullRequest.deletions ?: 0) > 300) {
warn("Big PR, try to keep changes smaller if you can")
}

// Work in progress check
if (pullRequest.title.contains("WIP", false)) {
warn("PR is classed as Work in Progress")
}
}
}
25 changes: 6 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ allprojects {
tasks.withType<KotlinCompilationTask<*>>().configureEach {
compilerOptions {
// Treat all Kotlin warnings as errors
// allWarningsAsErrors.set(true)

// Hack to make klib manifests have an actually unique name
// val uniqueName = "${[email protected]}.${[email protected]}"
// freeCompilerArgs.addAll(
// "-module-name",
// uniqueName,
// )
allWarningsAsErrors.set(true)

if (project.hasProperty("deckbox.enableComposeCompilerReports")) {
freeCompilerArgs.addAll(
Expand All @@ -47,16 +40,10 @@ allprojects {
}
}
}
}

// pluginManager.withPlugin("kotlin-multiplatform") {
// val kotlinExtension = project.extensions.getByName("kotlin")
// as org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
// val uniqueName = "${project.group}.${project.name}"
//
// kotlinExtension.targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget::class.java) {
// compilations.configureEach {
// kotlinOptions.freeCompilerArgs += listOf("-module-name", uniqueName)
// }
// }
// }
tasks.register<Copy>("bootstrap") {
from(file("scripts/pre-push"))
into(file(".git/hooks"))
fileMode = 777
}
16 changes: 16 additions & 0 deletions scripts/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

echo "**** Running Pre-Push Check ****"

git stash -q --keep-index

./gradlew spotlessCheck
./gradlew -P gradle/build-logic spotlessCheck

status=$?

git stash pop -q

echo "**** Pre-Push Check Finished ****"

exit $status

0 comments on commit 7ffdb37

Please sign in to comment.