forked from apache/incubator-weex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDangerfile
72 lines (55 loc) · 2.13 KB
/
Dangerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Error or Warn when delete public interface
metion_break_change = git.commits.any? { |c| c.message =~ /'breack change'/ }
for file in git.modified_files do
if file.end_with?("java")
diff = git.diff_for_file(file)
if diff && diff.patch =~ /^-\s*?public\s+[\s\S]+$/
if metion_break_change
warn("Modify public in #{file}")
else
fail("Modify public in #{file} without metion it in commit message. ")
end
end
end
# Warn when there is a big PR
warn("Big PR") if git.lines_of_code > 500
has_app_changes = !git.modified_files.grep(/WeexSDK\/Source/).empty?
has_test_changes = !git.modified_files.grep(/WeexSDKTests/).empty?
# Non-trivial amounts of app changes without tests
if git.lines_of_code > 100 && has_app_changes && !has_test_changes
warn "This PR may need tests."
end
# Shows all build errors, warnings and unit tests results generated from `xcodebuild`
xcode_summary.ignored_files = '**/Pods/**'
xcode_summary.report 'ios/sdk/xcodebuild.json'
# Fails build when Copyright header is not included
oc_files = (git.modified_files + git.added_files).uniq.select do |file_path|
file_path.end_with?(".h") || file_path.end_with?(".m") || file_path.end_with?(".mm")
end
copyright_header_components = Array.[](
/Created by Weex./,
/Copyright \(c\) .*, Alibaba, Inc. All rights reserved./,
/This source code is licensed under the Apache Licence 2.0./,
/For the full copyright and license information,please view the LICENSE file in the root directory of this source tree./
)
def has_copyright_header contents, copyright
for line in copyright do
if not contents =~ line
return false
end
end
return true
end
for file_path in oc_files do
contents = File.read(file_path)
if not has_copyright_header(contents, copyright_header_components)
fail("Objective-C file '#{file_path}' does not have the copyright header.")
end
end
# prose.check_spelling oc_files
# Find reviewers without parsing blame information
# from files matching to 'Pods/*'
# mention.run(2, ["Pods/*"], [])
# warn("Please add your name", file: "CHANGELOG.md", line: 4)
# fail("Our linter has failed.")
# markdown("## xxxxx")