cuke_ci_workers 0.1 → 0.2

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.
@@ -15,7 +15,7 @@ module CukeCIWorkers
15
15
  def initialize(options)
16
16
  @configuration_file_name = options[:configuration_file_name]
17
17
  @configuration = YAML.load_file(@configuration_file_name)
18
-
18
+
19
19
  @poll_uri = URI.parse(@configuration['poll_url'])
20
20
  @push_url = @configuration['push_url']
21
21
 
@@ -26,16 +26,22 @@ module CukeCIWorkers
26
26
 
27
27
  def run
28
28
  $running = true
29
- Signal.trap('INT') { $running = false }
30
-
29
+
30
+ Signal.trap('INT') {
31
+ say('Exiting...')
32
+ $running = false
33
+ }
34
+
31
35
  while($running) do
32
36
  begin
33
37
  run_present = poll_for_run
34
- #rescue Exception => e
35
- # log_exception(e)
38
+ rescue Exception => e
39
+ log_exception(e)
36
40
  end
37
41
 
38
42
  if run_present
43
+ say('Found run.')
44
+
39
45
  begin
40
46
  pull_repo
41
47
  checkout_commit
@@ -46,10 +52,11 @@ module CukeCIWorkers
46
52
  else
47
53
  push_error
48
54
  end
49
- #rescue Exception => e
50
- # log_exception(e)
55
+ rescue Exception => e
56
+ log_exception(e)
51
57
  end
52
58
  else
59
+ say('Nothing found. Going to sleep...')
53
60
  sleep 5
54
61
  end
55
62
  end
@@ -59,6 +66,7 @@ module CukeCIWorkers
59
66
 
60
67
  def poll_for_run
61
68
  message('Polling for run')
69
+ say("from #{@poll_uri}")
62
70
  result = Net::HTTP.get(@poll_uri)
63
71
 
64
72
  begin
@@ -85,7 +93,6 @@ module CukeCIWorkers
85
93
 
86
94
  def prepare
87
95
  message('Preparing working directory')
88
- return
89
96
  run_command(:prepare)
90
97
  end
91
98
 
@@ -93,12 +100,12 @@ module CukeCIWorkers
93
100
  message('Running Cucumber')
94
101
  output = run_command(:cucumber, temp_file_name)
95
102
 
96
- if $?.success?
97
- File.read(temp_file_name)
98
- else
99
- logger.error("Cucumber failed: #{output}")
100
- nil
101
- end
103
+ #if $?.success?
104
+ File.read(temp_file_name)
105
+ #else
106
+ # logger.error("Cucumber failed: #{output}")
107
+ # nil
108
+ #end
102
109
  end
103
110
 
104
111
  def push_result(result)
@@ -122,7 +129,7 @@ module CukeCIWorkers
122
129
  url = @push_url % @run_id
123
130
  @push_uri = URI.parse(url)
124
131
 
125
- message "Pushing json to #{url}"
132
+ say "Pushing json to #{url}"
126
133
 
127
134
  Net::HTTP.start(@push_uri.host, @push_uri.port) do |http|
128
135
  http.post("#{@push_uri.path}?#{@push_uri.query}", json, 'Content-Type' => 'application/json')
@@ -157,7 +164,13 @@ module CukeCIWorkers
157
164
  opts.parse!
158
165
 
159
166
  options[:configuration_file_name] ||= default_runner_config_file_name
160
- self.new(options)
167
+
168
+ begin
169
+ self.new(options)
170
+ rescue
171
+ puts "Could not open configuration file at '#{options[:configuration_file_name]}'."
172
+ exit
173
+ end
161
174
  rescue OptionParser::ParseError
162
175
  puts opts
163
176
  exit
@@ -17,6 +17,7 @@ module CukeCIWorkers
17
17
  private
18
18
 
19
19
  def log_exception(e)
20
+ say("### Exception: #{e.message}")
20
21
  logger.error(e.message + "\n " + e.backtrace * "\n ")
21
22
  end
22
23
 
@@ -27,6 +28,12 @@ module CukeCIWorkers
27
28
  end
28
29
  end
29
30
 
31
+ def say(text)
32
+ if @verbose
33
+ puts(text)
34
+ end
35
+ end
36
+
30
37
  def run_command(key, *args)
31
38
  command = interpolate_command(key, args)
32
39
  logger.info " #{command}"
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- server_url = 'http://localhost:3000/projects/<%= project_id %>/receipt?api_key=<%= api_key %>'
3
+ server_url = 'http://localhost:3000/projects/<%= project_id %>/receipt.json?api_key=<%= api_key %>'
4
4
  log_file_name = 'cuke_ci_notifier.log'
5
5
 
6
6
  require 'rubygems'
@@ -1,8 +1,8 @@
1
1
  temp_file_name: "cucumber.out"
2
2
  log_file_name: "cuke_ci_runner.log"
3
3
  log_level: "WARN"
4
- poll_url: "http://localhost:3000/projects/<%= project_id %>/runs/next?api_key=<%= api_key %>"
5
- push_url: "http://localhost:3000/projects/<%= project_id %>/runs/%s/results?api_key=<%= api_key %>"
4
+ poll_url: "http://localhost:3000/projects/<%= project_id %>/runs/next.json?api_key=<%= api_key %>"
5
+ push_url: "http://localhost:3000/projects/<%= project_id %>/runs/%s/results.json?api_key=<%= api_key %>"
6
6
  commands:
7
7
  pull: "git pull origin master"
8
8
  check_out: "git reset --hard %s"
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuke_ci_workers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ version: "0.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Gregor Weckbecker
@@ -18,8 +18,21 @@ cert_chain: []
18
18
 
19
19
  date: 2010-10-17 00:00:00 +02:00
20
20
  default_executable:
21
- dependencies: []
22
-
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: json
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
23
36
  description: Cucumber based continuous integration.
24
37
  email:
25
38
  - info@timfischbach.de