Module: TravisParallelSentinel
- Defined in:
- lib/travis_parallel_sentinel.rb,
lib/travis_parallel_sentinel/version.rb
Constant Summary collapse
- VERSION =
"0.1.8"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.status(phase) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/travis_parallel_sentinel.rb', line 22 def status(phase) raise "Unexpected phase #{phase.inspect}, expected 'script' or 'after'" unless %w{script after}.include?(phase.to_s.downcase) phase = phase.to_s.downcase.to_sym return :deploy if TRAVIS_JOB_NUMBER == '' # no build matrix, so good to go return :ignore unless TRAVIS_JOB_NUMBER =~ /\.1$/ # first job in the sequence is the deployment container while true builds = JSON.parse(open("https://api.travis-ci.org/builds/#{TRAVIS_BUILD_ID}").read) jobs = status['matrix'].collect{|job| OpenStruct.new(job)} if jobs.select{|job| job.number != TRAVIS_JOB_NUMBER || phase == :after}.detect{|job| job.result.nil?} $stderr.puts "waiting... #{results(jobs)}" sleep 5 elsif jobs.detect{|job| job.result != 0} throw "Some jobs failed: #{results(jobs)}" else return :deploy end end end |
Instance Method Details
#result(job) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/travis_parallel_sentinel.rb', line 12 def result(job) prefix = "#{job.number}=" return prefix + 'running' if job.result.nil? return prefix + 'ok' if job.result == 0 return prefix + 'failed' end |
#results(jobs) ⇒ Object
18 19 20 |
# File 'lib/travis_parallel_sentinel.rb', line 18 def results(jobs) return jobs.collect{|job| result(job)}.join(', ') end |