forked from fastlane/fastlane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dangerfile
35 lines (26 loc) · 1.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
warn("Big PR") if lines_of_code > 500
if (pr_body.to_s + pr_title.to_s).include?("WIP")
warn("Pull Request is Work in Progress")
end
if pr_body.length < 5
warn "Please provide a changelog summary in the Pull Request description @#{pr_author}"
end
require 'json'
containing_dir = ENV["CIRCLE_ARTIFACTS"] || "." # for local testing
rspec_files = Dir[File.join(containing_dir, "rspec_logs_*.json")]
fail("Could not find test artifacts") if rspec_files.count == 0
rspec_files.each do |current|
rspec = JSON.parse(File.read(current))
rspec["examples"].each do |current_test|
next if current_test["status"] == "passed"
new_line = "<br />"
border = "<hr />"
message = current_test["exception"]["message"].strip.gsub(/\n+/, new_line).gsub(/\\t+/, new_line).gsub(/\\n+/, new_line)
tool_name = current.match(/.*rspec_logs_(.*).json/)[1] # e.g. "rspec_logs_spaceship.json"
file_path = current_test["file_path"].gsub("./", "#{tool_name}/")
error_message = "<code>#{file_path}:#{current_test["line_number"]}</code>"
error_message += border
error_message += "<pre>#{message}</pre>"
fail(error_message)
end
end