Skip to content

Commit

Permalink
Improve Danger comment when CI jobs are canceled (#5285)
Browse files Browse the repository at this point in the history
This often happens when pushing a new commit to a PR while the Danger
job for a previous commit is still running.
  • Loading branch information
jpsim authored Oct 17, 2023
1 parent 5ec1de0 commit 7d09c6b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,23 @@ end
file = Tempfile.new('violations')

force_flag = has_danger_changes ? "--force" : ""
Open3.popen3("tools/oss-check -v #{force_flag} 2> #{file.path}") do |_, stdout, _, _|
while char = stdout.getc
print char

begin
Open3.popen3("tools/oss-check -v #{force_flag} 2> #{file.path}") do |_, stdout, _, _|
while char = stdout.getc
print char
end
end
rescue SignalException => e
if e.signo == Signal.list["TERM"]
# Post a nicer message here
fail "OSSCheck was cancelled"
else
raise e
end
rescue => e
# Handle other exceptions
fail "OSSCheck error: #{e.message}"
end

lines = file.read.chomp
Expand Down

0 comments on commit 7d09c6b

Please sign in to comment.