travis_parallel_sentinel 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2aa5ab88dfac88344db98e17462a68bcd8177a6c
4
- data.tar.gz: beb3c18247afc7947c573a9942f8842a3577c0dd
3
+ metadata.gz: 9d4c31bdf6e1827e31b044b60cd9b0cae57fd165
4
+ data.tar.gz: 0e26eff5c5db4f56435d7a029922fb6d1d4843db
5
5
  SHA512:
6
- metadata.gz: 4220e44851f77b6bcda39d37addbfe62651de07ef0209fee751620abc1fd02533d3ffcb582cefc1cf1133b9252aef5d2b5ec8967e5182ab68596a23704f36b79
7
- data.tar.gz: 907375f09fc7aaa077a0064aafd6fb357f2370f8783b1c141b9643431a9e6632637f0fa318f59386705a80105cca00c44d6172523ca6303f75326a9ff2136c06
6
+ metadata.gz: 9510cca75f2b3edbe1dac428f6d9a0334f0cde90e369e3e0258a180be888a50825036aed74814d388f3741bf019a17e1a69d95a1c98c0179387729c64decddde
7
+ data.tar.gz: 770590fa4e0faae85677fb1ee21e7fa334ce9aa1012254702cf2d4e6bbcce1d13150d1f4a2b520bd627d939876a5f93ff80c1d7410b74f734c45381934674d4f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- travis_parallel_sentinel (0.1.0)
4
+ travis_parallel_sentinel (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -5,29 +5,17 @@ Simple parallel build coordination for Travis.
5
5
  Until https://github.com/travis-ci/travis-ci/issues/929 is resolved, you can use this to coordinate your builds. Install
6
6
  the gem, and you can do the following in your build scripts:
7
7
 
8
- STATUS=$(travis_parallel_sentinel)
9
- case $STATUS in
10
- ok)
11
- echo 'All clear'
12
- exit 0
13
- ;;
14
- deploy)
15
- echo 'All builds green'
16
- ;;
17
- *)
18
- echo "Unexpected build status $STATUS"
19
- exit 1
20
- ;;
21
- esac
22
-
23
- # do your deploy work here
24
-
25
- The bundled script will return `ok` for anything but the primary build; for the primary build, it will error out if any
8
+ if [ "$(travis_parallel_sentinel script)" = "deploy" ]; then
9
+ :
10
+ # do your deploy work here
11
+ fi
12
+
13
+ The bundled script will return no output for anything but the primary build; for the primary build, it will error out if any
26
14
  of the other builds have, and will return `deploy` if all went well. This is meant to run *as part of your tests*, as
27
15
  that will cause your build to error out if the deploy fails.
28
16
 
29
17
  If you want to have the standard Travis behavior, that is, have builds go green even if the deploy step fails, run the
30
- above in your after\_X step, but do `STATUS=$(travis_parallel_sentinel include)` to include the primary build status in
18
+ above in your after\_X step, but do `$(travis_parallel_sentinel after)` to include the primary build status in
31
19
  the success assessment.
32
20
 
33
21
  ## Installation
@@ -3,11 +3,12 @@
3
3
  require "bundler/setup"
4
4
  require "travis_parallel_sentinel"
5
5
 
6
- if ARGV[0] == 'include'
7
- puts TravisParallelSentinel::status(true)
8
- elsif ARGV[0].to_s == ''
9
- puts TravisParallelSentinel::status(false)
10
- else
11
- STDERR.puts "Unexpected argument #{ARGV[0]}, expected none or 'include'"
12
- exit 1
6
+ begin
7
+ status = TravisParallelSentinel::status(ARGV[0])
8
+ status = '' if status == :ok
9
+ puts status
10
+ exit(0)
11
+ rescue => e
12
+ STDERR.puts "#{e}"
13
+ exit(1)
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module TravisParallelSentinel
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -1,23 +1,37 @@
1
1
  require "travis_parallel_sentinel/version"
2
2
  require 'open-uri'
3
3
  require 'json'
4
+ require 'ostruct'
4
5
 
5
6
  TRAVIS_JOB_NUMBER = ENV['TRAVIS_JOB_NUMBER'].to_s.strip
6
7
  TRAVIS_BUILD_ID = ENV['TRAVIS_BUILD_ID'].to_s.strip
7
8
 
8
9
  module TravisParallelSentinel
9
- def status(include_deployer=false)
10
+ def result(job)
11
+ prefix = "#{job.number}="
12
+ return prefix + 'running' if job.result.nil?
13
+ return prefix + 'ok' if job.result == 0
14
+ return prefix + 'failed'
15
+ end
16
+ def results(jobs)
17
+ return jobs.collect{|job| result(job)}.join(', ')
18
+ end
19
+
20
+ def status(phase)
21
+ raise "Unexpected phase #{phase}, expected 'script' or 'after'" unless %w{script after}.include?(phase.to_s.downcase)
22
+ phase = phase.to_s.downcase.to_sym
23
+
10
24
  return :deploy if TRAVIS_JOB_NUMBER == '' # no build matrix, so good to go
11
- return :ok unless TRAVIS_JOB_NUMBER =~ /\.1$/ # first job in the sequence is the deployment container
25
+ return :ignore unless TRAVIS_JOB_NUMBER =~ /\.1$/ # first job in the sequence is the deployment container
12
26
 
13
27
  while true
14
28
  builds = JSON.parse(open("https://api.travis-ci.org/builds/#{TRAVIS_BUILD_ID}").read)
15
- jobs = status['matrix'].select{|job| job['number'] != TRAVIS_JOB_NUMBER || include_deployer}.collect{|job| job['result']}
16
- if jobs.detect{|s| s.nil?}
17
- puts "waiting... #{jobs.inspect}"
29
+ jobs = status['matrix'].collect{|job| OpenStruct.new(job)}
30
+ if jobs.select{|job| job.number != TRAVIS_JOB_NUMBER || phase == :after}.detect{|job| job.result.nil?}
31
+ STDERR.puts "waiting... #{results(jobs)}"
18
32
  sleep 5
19
- elsif jobs.detect{|s| s != 0}
20
- throw "One or more jobs failed"
33
+ elsif jobs.detect{|job| job.result != 0}
34
+ throw "Some jobs failed: #{results(jobs)}"
21
35
  else
22
36
  return :deploy
23
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis_parallel_sentinel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - retorquere
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.4.6
81
+ rubygems_version: 2.4.2
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Coordinate parallel Travis builds