travis_parallel_sentinel 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -19
- data/bin/travis_parallel_sentinel +8 -7
- data/lib/travis_parallel_sentinel/version.rb +1 -1
- data/lib/travis_parallel_sentinel.rb +21 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d4c31bdf6e1827e31b044b60cd9b0cae57fd165
|
4
|
+
data.tar.gz: 0e26eff5c5db4f56435d7a029922fb6d1d4843db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9510cca75f2b3edbe1dac428f6d9a0334f0cde90e369e3e0258a180be888a50825036aed74814d388f3741bf019a17e1a69d95a1c98c0179387729c64decddde
|
7
|
+
data.tar.gz: 770590fa4e0faae85677fb1ee21e7fa334ce9aa1012254702cf2d4e6bbcce1d13150d1f4a2b520bd627d939876a5f93ff80c1d7410b74f734c45381934674d4f
|
data/Gemfile.lock
CHANGED
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
puts
|
10
|
-
|
11
|
-
|
12
|
-
|
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,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
|
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 :
|
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'].
|
16
|
-
if jobs.detect{|
|
17
|
-
puts "waiting... #{jobs
|
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{|
|
20
|
-
throw "
|
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.
|
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.
|
81
|
+
rubygems_version: 2.4.2
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Coordinate parallel Travis builds
|