Skip to content

Commit

Permalink
disable caching, handle errors & retry if can't build for OSSCheck
Browse files Browse the repository at this point in the history
fail the build if it couldn't be built even after retrying
  • Loading branch information
jpsim committed Jan 11, 2017
1 parent b189da0 commit 5702ef3
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ if has_app_changes
@commits[repo] = `git rev-parse HEAD`
durations = []
start = Time.now
command = '../../.build/release/swiftlint lint --no-cache'
command = '../../.build/release/swiftlint'
if `#{command} help lint`.include? '--no-cache'
command += ' lint --no-cache'
end
File.open("../#{branch}_reports/#{repo_name}.txt", 'w') do |file|
Open3.popen3(command) do |_, stdout, _, _|
file << stdout.read.chomp
Expand Down Expand Up @@ -90,10 +93,23 @@ if has_app_changes
# Generate branch reports
generate_reports(true, 'branch')
# Build master
`git checkout master`
`git pull`
`git fetch`
`git checkout origin/master`
puts 'Building master'
`swift build -c release`
unless $?.success?
# Couldn't build, start fresh
FileUtils.rm_rf %w(Packages .build)
return_value = nil
Open3.popen3('swift build -c release') do |_, stdout, _, wait_thr|
puts stdout.read.chomp
return_value = wait_thr.value
end
unless return_value.success?
fail 'Could not build master'
return
end
end
# Generate master reports
generate_reports(false, 'master')
# Diff and report changes to Danger
Expand Down

0 comments on commit 5702ef3

Please sign in to comment.