mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
8fd9f37fd0
travis_pr_errors prints all errors from the last build on the PR that your branch is currently on. [ci skip]
44 lines
1.0 KiB
Ruby
Executable File
44 lines
1.0 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
require 'pathname'
|
|
require 'travis'
|
|
require 'rest-client'
|
|
require 'parallel'
|
|
require 'ruby-progressbar'
|
|
|
|
# current branch
|
|
branch_name = `git rev-parse --abbrev-ref HEAD`.strip
|
|
|
|
pr_number = nil
|
|
|
|
begin
|
|
response = RestClient.get "https://api.github.com/repos/opf/openproject/pulls?state=open&head=opf:#{branch_name}"
|
|
json = JSON.parse(response)
|
|
pr_number = json.first['number']
|
|
rescue => e
|
|
warn "Failed to get PR number from #{branch_name}: #{e} #{e.message}"
|
|
end
|
|
|
|
puts "Looking for PR #{pr_number}"
|
|
build = Travis::Repository.find('opf/openproject')
|
|
.each_build
|
|
.detect { |b| b.pull_request_number == pr_number.to_i }
|
|
|
|
raise "No build found for PR#{pr_number}" unless build
|
|
|
|
results = Parallel.map(build.jobs, progress: 'Searching logs') do |job|
|
|
# internal log access seems broken
|
|
errors = []
|
|
|
|
log = job.log.session.get_raw("jobs/#{job.id}/log")
|
|
log.scan(/^rspec (\S+) #.+$/) do |match|
|
|
errors << match
|
|
end
|
|
|
|
errors
|
|
end
|
|
|
|
specs = results.flatten.join(" ")
|
|
|
|
puts "Errors\n\n#{specs}"
|
|
|