gianluz / danger-kotlin-android-lint-plugin Goto Github PK
View Code? Open in Web Editor NEWShow the Android lint errors with Danger
License: Apache License 2.0
Show the Android lint errors with Danger
License: Apache License 2.0
Hey there, I am trying to setup klint for Danger kotlin on my project and I've run into a slight problem ๐ . The plugin seems to throw a number format exception because some elements in the xml output for my project don't contain a line
attribute.
Here's the relevant section of github workflow:
- name: Run Android Lint
run: ./gradlew lint
- uses: yutailang0119/action-android-lint@v1 ## Trying this to ensure that the .xml report is actually valid
with:
xml_path: app/build/reports/*.xml # Support glob patterns by https://www.npmjs.com/package/@actions/glob
- name: Run Danger
uses: docker://ghcr.io/danger/danger-kotlin:1.0.0
with:
args: --failOnErrors --no-publish-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Here's my Dangerfile.kts:
@file:Repository("https://repo.maven.apache.org")
@file:DependsOn("org.apache.commons:commons-text:1.6")
@file:DependsOn("com.gianluz:danger-kotlin-android-lint-plugin:0.1.0")
@file:DependsOn("io.github.ackeecz:danger-kotlin-detekt:0.1.4")
import systems.danger.kotlin.*
import com.gianluz.dangerkotlin.androidlint.AndroidLint
import io.github.ackeecz.danger.detekt.DetektPlugin
import java.nio.file.Files
import java.nio.file.Paths
import java.util.function.BiPredicate
import java.util.stream.Collectors
register plugin AndroidLint
register plugin DetektPlugin
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")
// Changelog
if (!isTrivial && !changelogChanged && sourceChanges != null) {
warn("Any changes to library code should be reflected in the Changelog.\n\nPlease 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")
}
}
AndroidLint.report("app/build/reports/lint-results-debug.xml")
val detektReports = Files.find(Paths.get(""), 10, BiPredicate { path, attributes ->
val fileName = path.toFile().name
fileName.endsWith("detekt.xml")
}).map { it.toFile() }.collect(Collectors.toList())
DetektPlugin.parseAndReport(*detektReports.toTypedArray())
}
Here's the error from Github actions:
Run docker://ghcr.io/danger/danger-kotlin:1.0.0
/usr/bin/docker run --name ghcriodangerdangerkotlin100_5b9aab --label e28490 --workdir /github/workspace --rm -e JAVA_HOME -e GITHUB_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/inflow-android/inflow-android":"/github/workspace" ghcr.io/danger/danger-kotlin:1.0.0 --failOnErrors --no-publish-check
Executing $(which danger) ci --process danger-kotlin --passURLForDSL --failOnErrors --no-publish-check - pid 1
Executing kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /tmp/danger-dsl.json danger_out.json - pid 26
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at com.gianluz.dangerkotlin.androidlint.AndroidLint.asInt(AndroidLint.kt:148)
at com.gianluz.dangerkotlin.androidlint.AndroidLint.report(AndroidLint.kt:99)
at com.gianluz.dangerkotlin.androidlint.AndroidLint.report(AndroidLint.kt:76)
at Dangerfile_df.<init>(Dangerfile.df.kts:43)
warning: some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath
/usr/local/lib/danger/danger-kotlin.jar: warning: library has Kotlin runtime bundled into it
Dangerfile.df.kts:45:75: warning: parameter 'attributes' is never used, could be renamed to _
val detektReports = Files.find(Paths.get(""), 10, BiPredicate { path, attributes ->
^
Uncaught Kotlin exception: kotlin.Exception: Command kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /tmp/danger-dsl.json danger_out.json exited with code 768
at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)
at kfun:systems.danger.cmd.dangerfile.DangerFile#execute(kotlin.String;kotlin.String){} (0x41e271)
at kfun:systems.danger.DangerKotlin#run(){} (0x41c68f)
at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b6f7)
at Init_and_run_start (0x44c656)
at __libc_start_main (0x7fd727beeb97)
at (0x405031)
at ((nil))
Failing the build, there is 1 fail.
Request failed [403]: https://api.github.com/user
Response: {
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}
Request failed [403]: https://api.github.com/user
Response: {
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}
Feedback: https://github.com/inflow-app/inflow-android/pull/98#issuecomment-967718498
Uncaught Kotlin exception: kotlin.Exception: Command $(which danger) ci --process danger-kotlin --passURLForDSL --failOnErrors --no-publish-check exited with code 256
at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)
at kfun:systems.danger.cmd.dangerjs.DangerJS#process(systems.danger.cmd.Command;kotlin.String;kotlin.collections.List<kotlin.String>){} (0x41f2bb)
at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b95b)
at Init_and_run_start (0x44c656)
at __libc_start_main (0x7f90dcfa9b97)
at (0x405031)
at ((nil))
I hope the issue was descriptive enough. Any help would be appreciated. Also please point me to the video for your talk at droidcon london. I feel like I'd be able to do much more if I could just watch that talk again ๐ข
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.