travis-surveillance 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/travis/surveillance/build.rb +1 -1
- data/lib/travis/surveillance/cli.rb +18 -11
- data/lib/travis/surveillance/job.rb +10 -0
- data/lib/travis/surveillance/surveyor.rb +2 -2
- data/lib/travis/surveillance/version.rb +1 -1
- data/spec/support/jobs/2.json +10 -0
- data/spec/support/pusher/dylanegan-travis-surveillance-job-started-2.json +5 -0
- data/spec/travis/surveillance/job_spec.rb +4 -0
- data/spec/travis/surveillance/surveyor_spec.rb +8 -0
- metadata +5 -1
data/README.md
CHANGED
@@ -37,23 +37,30 @@ module Travis
|
|
37
37
|
end
|
38
38
|
|
39
39
|
surveyor = Travis::Surveillance::Surveyor.new(Travis::Surveillance::Project.new(project))
|
40
|
-
|
41
40
|
project = surveyor.project
|
42
|
-
print "\x1b[2J\x1b[H"
|
43
|
-
print "Project: #{project.owner}/#{project.name}\n\n"
|
44
|
-
print "\x1b[H"
|
45
|
-
$stdout.flush
|
46
41
|
|
47
42
|
surveyor.survey do
|
48
|
-
print "\x1b[2J\x1b[H"
|
49
|
-
print "Project: #{project.owner}/#{project.name}\n\n"
|
50
|
-
|
51
43
|
if project.builds.any? && builds = project.builds.sort_by { |b| b.id }.reverse
|
44
|
+
print "\x1b[2J\x1b[H"
|
45
|
+
|
52
46
|
latest = builds.first
|
53
47
|
|
54
|
-
table = Terminal::Table.new :
|
48
|
+
table = Terminal::Table.new title: "#{project.owner}/#{project.name}", style: { width: 120 } do |t|
|
49
|
+
t << ["Build", latest.number]
|
50
|
+
t << ["Duration", latest.duration] unless latest.building?
|
51
|
+
t << ["Branch", latest.branch]
|
52
|
+
t << ["Commit", latest.commit]
|
53
|
+
t << ["Compare URL", latest.compare_url]
|
54
|
+
t << ["Author", latest.author_name]
|
55
|
+
t << ["Message", latest.message.length > 100 ? "#{latest.message[0..100]} ..." : latest.message]
|
56
|
+
end
|
57
|
+
|
58
|
+
print table
|
59
|
+
print "\n\n"
|
60
|
+
|
61
|
+
table = Terminal::Table.new title: "Build Matrix", headings: ['Job', 'State', 'Duration', 'Runtime', 'ENV'], style: { width: 120 } do |t|
|
55
62
|
latest.jobs.each do |job|
|
56
|
-
t << [job.number, job.state, job.duration, job.config.env]
|
63
|
+
t << [job.number, job.state, job.duration, job.runtime, job.config.env]
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
@@ -62,7 +69,7 @@ module Travis
|
|
62
69
|
if builds.size > 1
|
63
70
|
print "\n\n"
|
64
71
|
|
65
|
-
table = Terminal::Table.new :title => "Build History", :headings => ['Build', 'State', 'Branch', 'Message', 'Duration'] do |t|
|
72
|
+
table = Terminal::Table.new :title => "Build History", :headings => ['Build', 'State', 'Branch', 'Message', 'Duration'], style: { width: 120 } do |t|
|
66
73
|
builds.each do |build|
|
67
74
|
next if build == latest
|
68
75
|
t << [build.number, build.state, build.branch, build.message, build.duration]
|
@@ -65,6 +65,16 @@ module Travis
|
|
65
65
|
status.nil?
|
66
66
|
end
|
67
67
|
|
68
|
+
def runtime
|
69
|
+
return @runtime if @runtime
|
70
|
+
@runtime = build.config.language.dup
|
71
|
+
case @runtime
|
72
|
+
when "ruby"
|
73
|
+
@runtime << " #{config.rvm}"
|
74
|
+
end
|
75
|
+
@runtime
|
76
|
+
end
|
77
|
+
|
68
78
|
def state
|
69
79
|
if running?
|
70
80
|
'running'
|
@@ -67,7 +67,7 @@ module Travis
|
|
67
67
|
return unless json = parse_and_check(payload)
|
68
68
|
|
69
69
|
unless build = @project.build_for(json['build']['id'])
|
70
|
-
Travis::Surveillance.log({ surveyor: true, build: true, started: true, id: json['build']['id'] })
|
70
|
+
Travis::Surveillance.log({ surveyor: true, build: true, started: true, id: json['build']['id'], number: json['build']['number'] })
|
71
71
|
@project.add_build(json['build'])
|
72
72
|
end
|
73
73
|
end
|
@@ -76,7 +76,7 @@ module Travis
|
|
76
76
|
json, build = parse_and_check_and_build(payload)
|
77
77
|
return unless build
|
78
78
|
|
79
|
-
Travis::Surveillance.log({ surveyor: true, build: true, finished: true, id: build.id })
|
79
|
+
Travis::Surveillance.log({ surveyor: true, build: true, finished: true, id: build.id, number: build.number })
|
80
80
|
build.attributes = json['build']
|
81
81
|
@project.status = build.status
|
82
82
|
end
|
@@ -24,6 +24,10 @@ describe Travis::Surveillance::Job do
|
|
24
24
|
@job.number.must_equal "1.1"
|
25
25
|
end
|
26
26
|
|
27
|
+
it "should have a runtime" do
|
28
|
+
@job.runtime.must_equal "ruby 1.9.3"
|
29
|
+
end
|
30
|
+
|
27
31
|
it "should have a started_at" do
|
28
32
|
@job.started_at.must_equal Time.parse("2012-08-04T13:28:29Z")
|
29
33
|
end
|
@@ -28,6 +28,14 @@ describe Travis::Surveillance::Surveyor do
|
|
28
28
|
@project.builds.last.jobs.last.running?.must_equal true
|
29
29
|
end
|
30
30
|
|
31
|
+
it "should handle multiple job:started" do
|
32
|
+
@surveyor.socket.simulate_received('build:started', pusher_json_for(@project.slug, 'build:started'), 'common')
|
33
|
+
@surveyor.socket.simulate_received('job:started', pusher_json_for(@project.slug, 'job:started'), 'common')
|
34
|
+
@surveyor.socket.simulate_received('job:started', pusher_json_for(@project.slug, 'job:started:2'), 'common')
|
35
|
+
@project.builds.last.jobs.first.runtime.must_equal "ruby 1.9.3"
|
36
|
+
@project.builds.last.jobs.last.runtime.must_equal "ruby 1.9.2"
|
37
|
+
end
|
38
|
+
|
31
39
|
it "should handle job:finished" do
|
32
40
|
@surveyor.socket.simulate_received('build:started', pusher_json_for(@project.slug, 'build:started'), 'common')
|
33
41
|
@surveyor.socket.simulate_received('job:started', pusher_json_for(@project.slug, 'job:started'), 'common')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis-surveillance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -133,10 +133,12 @@ files:
|
|
133
133
|
- spec/helper.rb
|
134
134
|
- spec/support/builds/1.json
|
135
135
|
- spec/support/jobs/1.json
|
136
|
+
- spec/support/jobs/2.json
|
136
137
|
- spec/support/projects/dylanegan-travis-surveillance.json
|
137
138
|
- spec/support/pusher/dylanegan-travis-surveillance-build-finished.json
|
138
139
|
- spec/support/pusher/dylanegan-travis-surveillance-build-started.json
|
139
140
|
- spec/support/pusher/dylanegan-travis-surveillance-job-finished.json
|
141
|
+
- spec/support/pusher/dylanegan-travis-surveillance-job-started-2.json
|
140
142
|
- spec/support/pusher/dylanegan-travis-surveillance-job-started.json
|
141
143
|
- spec/travis/surveillance/build_spec.rb
|
142
144
|
- spec/travis/surveillance/job_spec.rb
|
@@ -173,10 +175,12 @@ test_files:
|
|
173
175
|
- spec/helper.rb
|
174
176
|
- spec/support/builds/1.json
|
175
177
|
- spec/support/jobs/1.json
|
178
|
+
- spec/support/jobs/2.json
|
176
179
|
- spec/support/projects/dylanegan-travis-surveillance.json
|
177
180
|
- spec/support/pusher/dylanegan-travis-surveillance-build-finished.json
|
178
181
|
- spec/support/pusher/dylanegan-travis-surveillance-build-started.json
|
179
182
|
- spec/support/pusher/dylanegan-travis-surveillance-job-finished.json
|
183
|
+
- spec/support/pusher/dylanegan-travis-surveillance-job-started-2.json
|
180
184
|
- spec/support/pusher/dylanegan-travis-surveillance-job-started.json
|
181
185
|
- spec/travis/surveillance/build_spec.rb
|
182
186
|
- spec/travis/surveillance/job_spec.rb
|