ci_in_a_can 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ciinacan CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- def rake_file
3
+ def rake_file id
4
4
  <<EOF
5
5
  #!/usr/bin/env rake
6
6
 
7
- desc "Start"
7
+ desc "Start #{id}"
8
8
  task :start do
9
9
  location = File.expand_path(File.dirname(__FILE__))
10
10
  system "ruby service/service.rb start"
11
- system "cd web; rackup -p 80"
11
+ system "ruby web/stay_alive.rb start"
12
12
  end
13
13
 
14
- desc "Stop"
14
+ desc "Stop #{id}"
15
15
  task :stop do
16
16
  location = File.expand_path(File.dirname(__FILE__))
17
17
  system "ruby service/service.rb stop"
@@ -19,6 +19,20 @@ end
19
19
  EOF
20
20
  end
21
21
 
22
+ def web_daemon id
23
+ <<EOF
24
+ require 'daemons'
25
+
26
+ this_directory = File.expand_path(File.dirname(__FILE__))
27
+
28
+ ::Daemons.run_proc('#{id}_ci_web') do
29
+ loop do
30
+ exec "cd \#{this_directory};rackup -p 80"
31
+ end
32
+ end
33
+ EOF
34
+ end
35
+
22
36
  def web_file
23
37
  <<EOF
24
38
  require 'ci_in_a_can'
@@ -33,7 +47,7 @@ run Sinatra::Application
33
47
  EOF
34
48
  end
35
49
 
36
- def service_file
50
+ def service_file id
37
51
  <<EOF
38
52
  require 'ci_in_a_can'
39
53
  require 'daemons'
@@ -42,7 +56,7 @@ this_directory = File.expand_path(File.dirname(__FILE__) + '/../')
42
56
 
43
57
  eval("CiInACan.results_location = '\#{this_directory}' + '/results'")
44
58
 
45
- ::Daemons.run_proc('server.rb') do
59
+ ::Daemons.run_proc('#{id}_ci_server') do
46
60
  loop do
47
61
  options = {
48
62
  access_token: ENV['GITHUB_AUTH_TOKEN'],
@@ -68,12 +82,15 @@ when 'create'
68
82
 
69
83
  root = "#{Dir.pwd}/#{ARGV[1]}"
70
84
 
85
+ id = root.split('/').pop
86
+
71
87
  directories_to_create = [root, "#{root}/jobs", "#{root}/repos", "#{root}/web", "#{root}/service", "#{root}/results"]
72
88
 
73
89
  directories_to_create.each { |d| Dir.mkdir(d) unless File.exists?(d) }
74
90
 
75
- File.open("#{root}/Rakefile", 'w') { |f| f.write rake_file }
76
- File.open("#{root}/service/service.rb", 'w') { |f| f.write service_file }
77
- File.open("#{root}/web/config.ru", 'w') { |f| f.write web_file }
91
+ File.open("#{root}/Rakefile", 'w') { |f| f.write rake_file(id) }
92
+ File.open("#{root}/service/service.rb", 'w') { |f| f.write service_file(id) }
93
+ File.open("#{root}/web/stay_alive.rb", 'w') { |f| f.write web_daemon(id) }
94
+ File.open("#{root}/web/config.ru", 'w') { |f| f.write web_file }
78
95
 
79
96
  end
@@ -35,7 +35,10 @@ module CiInACan
35
35
  end
36
36
 
37
37
  def extract_branch_from payload
38
- payload['ref'].sub('refs/heads/', '')
38
+ array = payload['ref'].split('/')
39
+ array.shift # remove "refs"
40
+ array.shift # remove next value (like "heads" or "tags")
41
+ array.count == 0 ? payload['ref'] : array.join('/')
39
42
  end
40
43
 
41
44
  end
@@ -1,3 +1,3 @@
1
1
  module CiInACan
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
@@ -2,16 +2,16 @@ require_relative '../spec_helper'
2
2
 
3
3
  describe CiInACan::GithubBuildParser do
4
4
 
5
- [:branch, :compare, :sha, :git_ssh, :repo].to_objects {[
6
- ["blah", "https://github.com/darrencauthon/ci_in_a_can/commit/b1c5f9c9588f", "qwe", "git@github.com:darrencauthon/ci_in_a_can.git", "darrencauthon/ci_in_a_can"],
7
- ["bloo", "https://github.com/abc/123/commit/b1c5f9c9588f", "uio", "git@github.com:abc/123.git", "abc/123"],
8
- ["issues/5/blop", "https://github.com/abc/123/commit/b1c5f9c9588f", "uio", "git@github.com:abc/123.git", "abc/123"]
5
+ [:branch, :ref, :compare, :sha, :git_ssh, :repo].to_objects {[
6
+ ["blah", "refs/heads/blah", "https://github.com/darrencauthon/ci_in_a_can/commit/b1c5f9c9588f", "qwe", "git@github.com:darrencauthon/ci_in_a_can.git", "darrencauthon/ci_in_a_can"],
7
+ ["bloo", "refs/heads/bloo", "https://github.com/abc/123/commit/b1c5f9c9588f", "uio", "git@github.com:abc/123.git", "abc/123"],
8
+ ["issues/5/blop", "refs/heads/issues/5/blop", "https://github.com/abc/123/commit/b1c5f9c9588f", "uio", "git@github.com:abc/123.git", "abc/123"],
9
+ ["v0.0.22", "refs/tags/v0.0.22", "https://github.com/abc/123/commit/b1c5f9c9588f", "uio", "git@github.com:abc/123.git", "abc/123"],
10
+ ["apple", "apple", "https://github.com/abc/123/commit/b1c5f9c9588f", "uio", "git@github.com:abc/123.git", "abc/123"]
9
11
  ]}.each do |test|
10
12
 
11
13
  describe "parse" do
12
14
 
13
- let(:ref) { "refs/heads/#{test.branch}" }
14
-
15
15
  # content is a representation of the web request
16
16
  # that github will send on every push
17
17
  let(:content) do
@@ -19,7 +19,7 @@ describe CiInACan::GithubBuildParser do
19
19
  payload: {
20
20
  compare: test.compare,
21
21
  head_commit: { id: test.sha },
22
- ref: ref
22
+ ref: test.ref
23
23
  }.to_json
24
24
  }.to_json
25
25
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_in_a_can
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Darren Cauthon
@@ -13,6 +14,7 @@ dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,183 +30,209 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: mocha
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: subtle
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: contrast
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: timecop
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rake
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: sinatra
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - '>='
115
+ - - ! '>='
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - '>='
123
+ - - ! '>='
109
124
  - !ruby/object:Gem::Version
110
125
  version: '0'
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: json
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - '>='
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :runtime
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - '>='
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: uuid
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
- - - '>='
147
+ - - ! '>='
130
148
  - !ruby/object:Gem::Version
131
149
  version: '0'
132
150
  type: :runtime
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
- - - '>='
155
+ - - ! '>='
137
156
  - !ruby/object:Gem::Version
138
157
  version: '0'
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: listen
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
- - - '>='
163
+ - - ! '>='
144
164
  - !ruby/object:Gem::Version
145
165
  version: '0'
146
166
  type: :runtime
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
- - - '>='
171
+ - - ! '>='
151
172
  - !ruby/object:Gem::Version
152
173
  version: '0'
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: octokit
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
- - - '>='
179
+ - - ! '>='
158
180
  - !ruby/object:Gem::Version
159
181
  version: '0'
160
182
  type: :runtime
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
- - - '>='
187
+ - - ! '>='
165
188
  - !ruby/object:Gem::Version
166
189
  version: '0'
167
190
  - !ruby/object:Gem::Dependency
168
191
  name: daemons
169
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
170
194
  requirements:
171
- - - '>='
195
+ - - ! '>='
172
196
  - !ruby/object:Gem::Version
173
197
  version: '0'
174
198
  type: :runtime
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
177
202
  requirements:
178
- - - '>='
203
+ - - ! '>='
179
204
  - !ruby/object:Gem::Version
180
205
  version: '0'
181
206
  - !ruby/object:Gem::Dependency
182
207
  name: subtle
183
208
  requirement: !ruby/object:Gem::Requirement
209
+ none: false
184
210
  requirements:
185
- - - '>='
211
+ - - ! '>='
186
212
  - !ruby/object:Gem::Version
187
213
  version: '0'
188
214
  type: :runtime
189
215
  prerelease: false
190
216
  version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
191
218
  requirements:
192
- - - '>='
219
+ - - ! '>='
193
220
  - !ruby/object:Gem::Version
194
221
  version: '0'
195
222
  - !ruby/object:Gem::Dependency
196
223
  name: systemu
197
224
  requirement: !ruby/object:Gem::Requirement
225
+ none: false
198
226
  requirements:
199
- - - '>='
227
+ - - ! '>='
200
228
  - !ruby/object:Gem::Version
201
229
  version: '0'
202
230
  type: :runtime
203
231
  prerelease: false
204
232
  version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
205
234
  requirements:
206
- - - '>='
235
+ - - ! '>='
207
236
  - !ruby/object:Gem::Version
208
237
  version: '0'
209
238
  description: Fast CI. Still a WIP.
@@ -257,26 +286,33 @@ files:
257
286
  homepage: ''
258
287
  licenses:
259
288
  - MIT
260
- metadata: {}
261
289
  post_install_message:
262
290
  rdoc_options: []
263
291
  require_paths:
264
292
  - lib
265
293
  required_ruby_version: !ruby/object:Gem::Requirement
294
+ none: false
266
295
  requirements:
267
- - - '>='
296
+ - - ! '>='
268
297
  - !ruby/object:Gem::Version
269
298
  version: '0'
299
+ segments:
300
+ - 0
301
+ hash: -117443188495740805
270
302
  required_rubygems_version: !ruby/object:Gem::Requirement
303
+ none: false
271
304
  requirements:
272
- - - '>='
305
+ - - ! '>='
273
306
  - !ruby/object:Gem::Version
274
307
  version: '0'
308
+ segments:
309
+ - 0
310
+ hash: -117443188495740805
275
311
  requirements: []
276
312
  rubyforge_project:
277
- rubygems_version: 2.1.11
313
+ rubygems_version: 1.8.24
278
314
  signing_key:
279
- specification_version: 4
315
+ specification_version: 3
280
316
  summary: Fast CI. Still a WIP.
281
317
  test_files:
282
318
  - spec/ci_in_a_can/bash_result_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 29616e5e15107ead5dbd441bb60d3223deda4d4a
4
- data.tar.gz: cef539c2cee56404eef3b03301aa4adb1ae9cc78
5
- SHA512:
6
- metadata.gz: ba569e6e191e2620c31ca2cc89fca4aebd1ff71f93daa2a602e282696a5a2fa6fa2702cb094cbcc3ed7b2c84182429b19d663a89854072ac8933e20b85ceb700
7
- data.tar.gz: 7bfed8a36e03b173e32a7741e680ddf15aacc37074b8f3717da3c688dbc0fdbef333b1ae86705dff794034a9f24d1c5f5b8c555e06132b0e98e8c971c552ad65