Skip to content

Commit 3c4795c

Browse files
Congigure danger and ktlint
1 parent d15e00f commit 3c4795c

File tree

7 files changed

+156
-3
lines changed

7 files changed

+156
-3
lines changed

Dangerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Handle labels
2+
message "Please add labels to this PR" if github.pr_labels.empty?
3+
4+
can_merge = github.pr_json["mergeable"]
5+
message("This PR cannot be merged yet.", sticky: false) unless can_merge
6+
7+
message "This PR does not have any assignees yet." unless github.pr_json["assignee"]
8+
9+
# Handle milestones
10+
has_milestone = github.pr_json["milestone"] != nil
11+
message("This PR does not refer to an existing milestone", sticky: false) unless has_milestone
12+
13+
# Ignore issues out of PR scope
14+
github.dismiss_out_of_range_messages({
15+
error: false,
16+
warning: false,
17+
message: true,
18+
markdown: true
19+
})
20+
21+
# Ktlint
22+
checkstyle_dir = "**/reports/ktlint/ktlint*.xml"
23+
Dir[checkstyle_dir].each do |file_name|
24+
checkstyle_reports.inline_comment = true
25+
checkstyle_reports.report file_name
26+
end
27+
28+
# Lint
29+
lint_dir = "**/reports/lint-*.xml"
30+
Dir[lint_dir].each do |file_name|
31+
android_lint.skip_gradle_task = true
32+
android_lint.filtering = true
33+
android_lint.report_file = file_name
34+
android_lint.lint(inline_mode: true)
35+
end
36+
37+
# Unit tests
38+
junit_tests_dir = "**/test-results/**/*.xml"
39+
Dir[junit_tests_dir].each do |file_name|
40+
junit.parse file_name
41+
junit.show_skipped_tests = true
42+
junit.report
43+
end

Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6+
7+
gem 'danger'
8+
gem 'danger-android_lint'
9+
gem "danger-checkstyle_reports"
10+
gem 'danger-junit'

Gemfile.lock

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.6.0)
5+
public_suffix (>= 2.0.2, < 4.0)
6+
ansi (1.5.0)
7+
ast (2.4.0)
8+
claide (1.0.2)
9+
claide-plugins (0.9.2)
10+
cork
11+
nap
12+
open4 (~> 1.3)
13+
colored2 (3.1.2)
14+
cork (0.3.0)
15+
colored2 (~> 3.1)
16+
danger (6.0.9)
17+
claide (~> 1.0)
18+
claide-plugins (>= 0.9.2)
19+
colored2 (~> 3.1)
20+
cork (~> 0.1)
21+
faraday (~> 0.9)
22+
faraday-http-cache (~> 2.0)
23+
git (~> 1.5)
24+
kramdown (~> 2.0)
25+
kramdown-parser-gfm (~> 1.0)
26+
no_proxy_fix
27+
octokit (~> 4.7)
28+
terminal-table (~> 1)
29+
danger-android_lint (0.0.7)
30+
danger-plugin-api (~> 1.0)
31+
oga
32+
danger-checkstyle_reports (0.1.0)
33+
danger-plugin-api (~> 1.0)
34+
danger-junit (1.0.0)
35+
danger (> 2.0)
36+
ox (~> 2.0)
37+
danger-plugin-api (1.0.0)
38+
danger (> 2.0)
39+
faraday (0.15.4)
40+
multipart-post (>= 1.2, < 3)
41+
faraday-http-cache (2.0.0)
42+
faraday (~> 0.8)
43+
git (1.5.0)
44+
kramdown (2.1.0)
45+
kramdown-parser-gfm (1.1.0)
46+
kramdown (~> 2.0)
47+
multipart-post (2.1.1)
48+
nap (1.1.0)
49+
no_proxy_fix (0.1.2)
50+
octokit (4.14.0)
51+
sawyer (~> 0.8.0, >= 0.5.3)
52+
oga (2.15)
53+
ast
54+
ruby-ll (~> 2.1)
55+
open4 (1.3.4)
56+
ox (2.10.1)
57+
public_suffix (3.1.0)
58+
ruby-ll (2.1.2)
59+
ansi
60+
ast
61+
sawyer (0.8.2)
62+
addressable (>= 2.3.5)
63+
faraday (> 0.8, < 2.0)
64+
terminal-table (1.8.0)
65+
unicode-display_width (~> 1.1, >= 1.1.1)
66+
unicode-display_width (1.6.0)
67+
68+
PLATFORMS
69+
ruby
70+
71+
DEPENDENCIES
72+
danger
73+
danger-android_lint
74+
danger-checkstyle_reports
75+
danger-junit
76+
77+
BUNDLED WITH
78+
2.0.1

build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@
33
buildscript {
44
ext.kotlin_version = '1.3.31'
55
repositories {
6+
google()
67
jcenter()
78
maven { url 'https://maven.google.com' }
8-
google()
9+
maven { url "https://plugins.gradle.org/m2/" }
910
}
1011
dependencies {
1112
classpath 'com.android.tools.build:gradle:3.4.1'
1213
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1314
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15+
classpath "org.jlleitschuh.gradle:ktlint-gradle:8.0.0"
1416
}
1517
}
1618

1719
allprojects {
1820
repositories {
19-
jcenter()
20-
maven { url 'https://maven.google.com' }
2121
google()
22+
jcenter()
2223
}
2324
}
2425

2526
task clean(type: Delete) {
2627
delete rootProject.buildDir
2728
}
29+
30+
ext.ReporterType = org.jlleitschuh.gradle.ktlint.reporter.ReporterType

ktlint.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apply plugin: "org.jlleitschuh.gradle.ktlint"
2+
3+
ktlint {
4+
version = "0.33.0"
5+
android = true
6+
ignoreFailures = true
7+
enableExperimentalRules = true
8+
reporters = [ReporterType.CHECKSTYLE]
9+
}

library.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'com.github.dcendents.android-maven'
3+
apply from: '../ktlint.gradle'
34

45
group = 'com.github.stephenvinouze'
56

@@ -24,6 +25,10 @@ android {
2425
test.java.srcDirs += 'src/test/kotlin'
2526
androidTest.java.srcDirs += 'src/androidTest/kotlin'
2627
}
28+
lintOptions {
29+
xmlReport true
30+
abortOnError false
31+
}
2732
}
2833

2934
task sourcesJar(type: Jar) {

sample/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3+
apply from: '../ktlint.gradle'
34

45
android {
56
compileSdkVersion Integer.parseInt(ANDROID_BUILD_SDK_VERSION)
@@ -18,6 +19,10 @@ android {
1819
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1920
}
2021
}
22+
lintOptions {
23+
xmlReport true
24+
abortOnError false
25+
}
2126
}
2227

2328
dependencies {

0 commit comments

Comments
 (0)