forked from SwifterSwift/SwifterSwift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dangerfile
51 lines (40 loc) · 1.63 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
message('Thank you for submitting a pull request to SwifterSwift. The team will review your submission as soon as possible.')
# Checks for modified source files
source_changes_exist = !git.modified_files.grep(/Sources/).empty?
# Checks for changelog entry
no_changelog_entry = !git.modified_files.include?("CHANGELOG.md")
# Checks for tests
no_test_changes = git.modified_files.grep(/Tests/).empty?
if source_changes_exist && no_test_changes
warn('Consider adding tests for new extensions or updating existing tests for a modified SwifterSwift extension')
end
if source_changes_exist && no_changelog_entry
warn('The source files have been modified. Please consider adding a CHANGELOG entry if necessary.')
end
swiftlint.lint_files
# Checks if pull request is labeled as [WIP]
warn('This pull request is marked as Work in Progress. DO NOT MERGE!') if github.pr_title.include? "[WIP]"
# Xcode summary
def summary(platform:)
xcode_summary.report "xcodebuild-#{platform}.json"
end
def label_tests_summary(label:, platform:)
file_name = "xcodebuild-#{platform}.json"
json = File.read(file_name)
data = JSON.parse(json)
data["tests_summary_messages"].each { |message|
if !message.empty?
message.insert(1, " " + label + ":")
end
}
File.open(file_name,"w") do |f|
f.puts JSON.pretty_generate(data)
end
end
label_tests_summary(label: "iOS", platform: "ios")
label_tests_summary(label: "tvOS", platform: "tvos")
label_tests_summary(label: "macOS", platform: "macos")
summary(platform: "ios")
summary(platform: "tvos")
summary(platform: "macos")
summary(platform: "watchos")