chicanery 0.1.7 → 0.1.8

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: ae8d3b8f2e9b341beba34ae7d3d3876c73c3c6b1
4
- data.tar.gz: 3d4547a9747c5cc24cda09dab73c02c8a17c0fb3
3
+ metadata.gz: 10a2f31b2de883be54826b643b9bcdb8302f92d3
4
+ data.tar.gz: 18fca2caf13b57a4aa6a411f070a40ff64ae2517
5
5
  SHA512:
6
- metadata.gz: 9219bfa43c30c733006621aa5aec6a0b4d7bc86f3fe736fcd60b712543ea953c600a1cd2421458b4859c1442cd162d18c2bd230fdd1fff70f14e4a6fb47f1d8d
7
- data.tar.gz: 728bd0f84bea90d00734173b1ee7eafc1134d2ae4a250e3108911276a1db9291510599b6d4e68fe1707fb47ea803c1d9eb00d7a2cf07c22353baee7c9d8d3106
6
+ metadata.gz: ecd3c65a9e6ca02735cda32d37b42d73428fb11f1f7d27b2f62f665befb512b3f49f73d9dee1e043bb3ffc4dc6b95088ce4f833554bfcc83f750b7b9ad006ed2
7
+ data.tar.gz: 6d956f8f614c256deecf00abcd28af7b588543e21a38e5248b177deca96861137ef7aeae5b97167df004f6a6c8687ff9b2723a698e3fe13f08041d66a26553f3
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chicanery (0.1.7)
4
+ chicanery (0.1.8)
5
+ colorize (~> 0)
5
6
  nokogiri (~> 1)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  addressable (2.3.6)
12
+ colorize (0.7.3)
11
13
  crack (0.4.2)
12
14
  safe_yaml (~> 1.0.0)
13
15
  diff-lcs (1.2.5)
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency 'nokogiri', '~>1'
21
+ gem.add_dependency 'colorize', '~>0'
21
22
 
22
23
  gem.add_development_dependency 'rake', '~>0'
23
24
  gem.add_development_dependency 'rspec', '~>2'
@@ -16,7 +16,7 @@ module Chicanery
16
16
  include Repos
17
17
  include Sites
18
18
 
19
- VERSION = "0.1.7"
19
+ VERSION = "0.1.8"
20
20
 
21
21
  def poll_period seconds=nil
22
22
  @poll_period = seconds if seconds
@@ -0,0 +1,12 @@
1
+ module Chicanery
2
+ module Debug
3
+ def verbose message
4
+ return unless ENV['CHICANERY_DEBUG'] == 'verbose'
5
+ $stderr.puts message
6
+ end
7
+
8
+ def verbose_blue message
9
+ verbose message.colorize(:blue)
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,10 @@
1
+ require 'chicanery/debug'
2
+ require 'colorize'
3
+
1
4
  module Chicanery
2
5
  module Handlers
6
+ include Debug
7
+
3
8
  %w{run started succeeded failed broken fixed commit up down crashed recovered}.each do |status|
4
9
  class_eval <<-EOF
5
10
  def when_#{status} &block
@@ -11,6 +16,7 @@ module Chicanery
11
16
  end
12
17
 
13
18
  def notify_#{status}_handlers *args
19
+ verbose_blue \"\t\tnow #{status}\"
14
20
  #{status}_handlers.each {|handler| handler.call *args }
15
21
  end
16
22
  EOF
@@ -1,36 +1,67 @@
1
1
  require 'chicanery/collections'
2
2
  require 'chicanery/handlers'
3
+ require 'chicanery/debug'
3
4
 
4
5
  module Chicanery
5
6
  module Servers
6
7
  include Collections
7
8
  include Handlers
9
+ include Debug
8
10
 
9
11
  def check_servers current_state, previous_state
10
12
  current_state[:servers] = {}
13
+ verbose_blue "Execution #{Time.now}"
11
14
  servers.each do |server|
15
+ verbose "examining server #{server.name}"
12
16
  current_jobs = server.jobs
13
- compare_jobs current_jobs, previous_state[:servers][server.name] if previous_state[:servers]
17
+ if previous_state[:servers] && previous_state[:servers][server.name]
18
+ compare_jobs current_jobs, previous_state[:servers][server.name]
19
+ else
20
+ verbose "\tno past server #{server.name} state for comparison"
21
+ end
14
22
  current_state[:servers][server.name] = current_jobs
15
23
  end
16
24
  end
17
25
 
18
26
  def compare_jobs current_jobs, previous_jobs
19
- return unless previous_jobs
20
27
  current_jobs.each do |job_name, job|
21
- compare_job job_name, job, previous_jobs[job_name] if previous_jobs[job_name]
28
+ verbose "\texamining job #{job_name} (now #{job[:activity]}, was #{job[:last_build_status]})"
29
+ if previous_jobs[job_name]
30
+ compare_job job_name, job, previous_jobs[job_name]
31
+ else
32
+ verbose "\tno past job #{job_name} state for comparison"
33
+ end
22
34
  end
23
35
  end
24
36
 
25
37
  def compare_job name, current, previous
26
- if current[:activity] == :building and previous[:activity] == :sleeping
27
- notify_started_handlers name, current
38
+ if current[:activity] == :building
39
+ verbose "\t\tcurrently building"
40
+ hack_for_forgetful_ci current, previous
41
+ if previous[:activity] == :sleeping
42
+ notify_started_handlers name, current
43
+ end
44
+ return
28
45
  end
29
- return unless current[:last_build_time] != previous[:last_build_time]
46
+ unless current[:last_build_time] != previous[:last_build_time] || current[:last_build_status] != previous[:last_build_status]
47
+ verbose "\t\tno change in timestamp or build status"
48
+ return
49
+ end
50
+ verbose "\t\t#{previous[:last_build_status]} -> #{current[:last_build_status]}"
30
51
  notify_succeeded_handlers name, current if current[:last_build_status] == :success
31
52
  notify_failed_handlers name, current if current[:last_build_status] == :failure
32
- notify_broken_handlers name, current if current[:last_build_status] == :failure and previous[:last_build_status] == :success
33
- notify_fixed_handlers name, current if current[:last_build_status] == :success and previous[:last_build_status] == :failure
53
+ notify_broken_handlers name, current if current[:last_build_status] == :failure && previous[:last_build_status] == :success
54
+ notify_fixed_handlers name, current if current[:last_build_status] == :success && previous[:last_build_status] == :failure
55
+ end
56
+
57
+ def hack_for_forgetful_ci current, previous
58
+ # the following unfortunate hack is to compensate for cctray implementations (semaphore) which lose last build information when building
59
+ return if current[:last_build_time] > 0
60
+ verbose "\t\tcopying previous build content"
61
+ %w(build_time build_status label).each do |property|
62
+ key = "last_#{property}".to_sym
63
+ current[key] = previous[key]
64
+ end
34
65
  end
35
66
  end
36
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chicanery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Ryall
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,7 @@ files:
136
150
  - lib/chicanery.rb
137
151
  - lib/chicanery/cctray.rb
138
152
  - lib/chicanery/collections.rb
153
+ - lib/chicanery/debug.rb
139
154
  - lib/chicanery/git.rb
140
155
  - lib/chicanery/handlers.rb
141
156
  - lib/chicanery/persistence.rb