ci_in_a_can 0.2.5 → 0.3.0
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/lib/ci_in_a_can/cleaner.rb +7 -0
- data/lib/ci_in_a_can/cli/files.rb +2 -2
- data/lib/ci_in_a_can/cloner.rb +7 -3
- data/lib/ci_in_a_can/runner.rb +1 -0
- data/lib/ci_in_a_can/sinatra.rb +64 -0
- data/lib/ci_in_a_can/version.rb +1 -1
- data/lib/ci_in_a_can/view_models/a_list_of_runs.rb +0 -3
- data/lib/ci_in_a_can/view_models/login_form.rb +0 -2
- data/lib/ci_in_a_can/view_models/repo_form.rb +0 -2
- data/lib/ci_in_a_can/web.rb +1 -1
- data/lib/ci_in_a_can/web_content.rb +1 -1
- data/spec/ci_in_a_can/cleaner_spec.rb +23 -0
- data/spec/ci_in_a_can/runner_spec.rb +14 -0
- data/spec/ci_in_a_can/web_spec.rb +1 -6
- metadata +6 -3
- data/lib/ci_in_a_can/app.rb +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ae03b9e39da688340553f31bb593eaf46892635
|
4
|
+
data.tar.gz: feb268bfb18a9d8f60776987d922b5846bd3d57f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87f02275b1d2ab4bb3777eea044ba3d8d84fa8e4eee08688e278ef24dfec0f3c25ee65a9700f0328225a175d2f753d8899e9df7420f62dfbb95dd171c0ebfc3
|
7
|
+
data.tar.gz: e84daf4eb367ac55b6cb392542472378ad70532e0d56db755f961c881e50cb0a26a53d4ef6aeedb6cbb6736919fa7a2b7c1d046be5ddf16646fb59b072d19c54
|
@@ -51,10 +51,10 @@ require 'ci_in_a_can'
|
|
51
51
|
|
52
52
|
this_directory = File.expand_path(File.dirname(__FILE__) + '/../')
|
53
53
|
|
54
|
-
eval("CiInACan::
|
54
|
+
eval("CiInACan::Web.jobs_location = '\#{this_directory}' + '/jobs'")
|
55
55
|
eval("CiInACan.results_location = '\#{this_directory}' + '/results'")
|
56
56
|
|
57
|
-
use CiInACan::
|
57
|
+
use CiInACan::Sinatra
|
58
58
|
run Sinatra::Application
|
59
59
|
EOF
|
60
60
|
end
|
data/lib/ci_in_a_can/cloner.rb
CHANGED
@@ -3,13 +3,17 @@ module CiInACan
|
|
3
3
|
module Cloner
|
4
4
|
|
5
5
|
def self.clone_a_local_copy_for build
|
6
|
-
|
6
|
+
execute the_commands_to_clone_the(build)
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
9
|
+
def self.execute command
|
10
|
+
CiInACan::Bash.run command
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.the_commands_to_clone_the build
|
10
14
|
["git clone #{build.git_ssh} #{build.local_location}",
|
11
15
|
"cd #{build.local_location}",
|
12
|
-
"git checkout #{build.sha}"]
|
16
|
+
"git checkout #{build.sha}"].join('; ')
|
13
17
|
end
|
14
18
|
|
15
19
|
end
|
data/lib/ci_in_a_can/runner.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module CiInACan
|
4
|
+
|
5
|
+
class Sinatra < Sinatra::Base
|
6
|
+
|
7
|
+
enable :sessions
|
8
|
+
|
9
|
+
get '/' do
|
10
|
+
html = CiInACan::Web.new.show_a_list_of_the_runs
|
11
|
+
CiInACan::WebContent.layout_page_around html
|
12
|
+
end
|
13
|
+
|
14
|
+
get '/login' do
|
15
|
+
html = CiInACan::Web.new.login_page
|
16
|
+
CiInACan::WebContent.layout_page_around html
|
17
|
+
end
|
18
|
+
|
19
|
+
post '/login' do
|
20
|
+
CiInACan::Web.new(params: params, session: session)
|
21
|
+
.submit_a_passphrase
|
22
|
+
redirect '/'
|
23
|
+
end
|
24
|
+
|
25
|
+
get '/test_result/:id' do
|
26
|
+
html = CiInACan::Web.new(params: params)
|
27
|
+
.show_the_test_result
|
28
|
+
CiInACan::WebContent.layout_page_around html
|
29
|
+
end
|
30
|
+
|
31
|
+
get '/test_result/:id.json' do
|
32
|
+
CiInACan::Web.new(params: params)
|
33
|
+
.show_the_test_result_in_json
|
34
|
+
end
|
35
|
+
|
36
|
+
get %r{/repo/(.+)} do
|
37
|
+
web = CiInACan::Web.new(params: params, session: session)
|
38
|
+
|
39
|
+
unless web.logged_in?
|
40
|
+
redirect '/login'
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
html = web.show_the_repo_edit_form
|
45
|
+
CiInACan::WebContent.layout_page_around html
|
46
|
+
end
|
47
|
+
|
48
|
+
post %r{/repo/(.+)} do
|
49
|
+
web = CiInACan::Web.new(params: params, session: session)
|
50
|
+
unless web.logged_in?
|
51
|
+
redirect '/login'
|
52
|
+
return
|
53
|
+
end
|
54
|
+
repo = web.update_repo_details
|
55
|
+
redirect "/repo/#{repo.id}"
|
56
|
+
end
|
57
|
+
|
58
|
+
post %r{/push/(.+)} do
|
59
|
+
CiInACan::Web.new(params: params).start_a_new_build
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/lib/ci_in_a_can/version.rb
CHANGED
@@ -6,8 +6,6 @@ module CiInACan
|
|
6
6
|
|
7
7
|
def to_html
|
8
8
|
run_html = the_original_value.map { |r| r.to_html }.join("\n")
|
9
|
-
|
10
|
-
CiInACan::WebContent.full_page_of(
|
11
9
|
<<EOF
|
12
10
|
<table class="table table-bordered">
|
13
11
|
<tbody>
|
@@ -15,7 +13,6 @@ module CiInACan
|
|
15
13
|
</tbody>
|
16
14
|
</table>
|
17
15
|
EOF
|
18
|
-
)
|
19
16
|
end
|
20
17
|
|
21
18
|
end
|
@@ -5,7 +5,6 @@ module CiInACan
|
|
5
5
|
class LoginForm < ViewModel
|
6
6
|
|
7
7
|
def to_html
|
8
|
-
CiInACan::WebContent.full_page_of(
|
9
8
|
<<EOF
|
10
9
|
<form action="/login" method="post">
|
11
10
|
Passphrase
|
@@ -13,7 +12,6 @@ Passphrase
|
|
13
12
|
<button type="submit">Submit</button>
|
14
13
|
</form>
|
15
14
|
EOF
|
16
|
-
)
|
17
15
|
end
|
18
16
|
|
19
17
|
end
|
@@ -5,7 +5,6 @@ module CiInACan
|
|
5
5
|
class RepoForm < ViewModel
|
6
6
|
|
7
7
|
def to_html
|
8
|
-
CiInACan::WebContent.full_page_of(
|
9
8
|
<<EOF
|
10
9
|
<form action="/repo/#{id}" method="post">
|
11
10
|
<div>#{url}</div>
|
@@ -15,7 +14,6 @@ module CiInACan
|
|
15
14
|
<input type="submit">Submit</input>
|
16
15
|
</form>
|
17
16
|
EOF
|
18
|
-
)
|
19
17
|
end
|
20
18
|
|
21
19
|
end
|
data/lib/ci_in_a_can/web.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe CiInACan::Cleaner do
|
4
|
+
|
5
|
+
describe "removing a local copy of a build" do
|
6
|
+
|
7
|
+
['a', 'b'].each do |local_location|
|
8
|
+
|
9
|
+
describe "different locations" do
|
10
|
+
|
11
|
+
it "should exist" do
|
12
|
+
build = CiInACan::Build.new(local_location: local_location)
|
13
|
+
CiInACan::Bash.expects(:run).with("rm -rf \"#{local_location}\"")
|
14
|
+
CiInACan::Cleaner.remove_local_copy_of build
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -11,6 +11,7 @@ describe CiInACan::Runner do
|
|
11
11
|
CiInACan::Cloner.stubs(:clone_a_local_copy_for)
|
12
12
|
CiInACan::TestRunner.stubs(:run_tests_for)
|
13
13
|
CiInACan::TestResultNotifier.stubs(:send_for)
|
14
|
+
CiInACan::Cleaner.stubs(:remove_local_copy_of)
|
14
15
|
end
|
15
16
|
|
16
17
|
it "should clone the git repo" do
|
@@ -22,6 +23,11 @@ describe CiInACan::Runner do
|
|
22
23
|
CiInACan::TestRunner.expects(:run_tests_for).with build
|
23
24
|
CiInACan::Runner.run build
|
24
25
|
end
|
26
|
+
|
27
|
+
it "should cleanup after itself" do
|
28
|
+
CiInACan::Cleaner.expects(:remove_local_copy_of).with build
|
29
|
+
CiInACan::Runner.run build
|
30
|
+
end
|
25
31
|
|
26
32
|
it "should run the test after the clone" do
|
27
33
|
count = 0
|
@@ -31,6 +37,14 @@ describe CiInACan::Runner do
|
|
31
37
|
CiInACan::Runner.run build
|
32
38
|
end
|
33
39
|
|
40
|
+
it "should cleanup after the test results are retrieved" do
|
41
|
+
count = 0
|
42
|
+
CiInACan::TestRunner.stubs(:run_tests_for).with { count += 1 }
|
43
|
+
CiInACan::Cleaner.stubs(:remove_local_copy_of).with { count.must_equal 1; true }
|
44
|
+
|
45
|
+
CiInACan::Runner.run build
|
46
|
+
end
|
47
|
+
|
34
48
|
it "should call the test result notifier with the build and the results" do
|
35
49
|
test_results = Object.new
|
36
50
|
CiInACan::TestRunner.stubs(:run_tests_for).with(build).returns test_results
|
@@ -47,7 +47,6 @@ describe CiInACan::Web do
|
|
47
47
|
|
48
48
|
params[:id] = Object.new
|
49
49
|
test_result = Object.new
|
50
|
-
web_content = Object.new
|
51
50
|
html = Object.new
|
52
51
|
|
53
52
|
test_result.stubs(:to_html).returns html
|
@@ -56,13 +55,9 @@ describe CiInACan::Web do
|
|
56
55
|
.with(params[:id])
|
57
56
|
.returns test_result
|
58
57
|
|
59
|
-
CiInACan::WebContent.stubs(:full_page_of)
|
60
|
-
.with(html)
|
61
|
-
.returns web_content
|
62
|
-
|
63
58
|
result = web.show_the_test_result
|
64
59
|
|
65
|
-
result.must_be_same_as
|
60
|
+
result.must_be_same_as html
|
66
61
|
|
67
62
|
end
|
68
63
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_in_a_can
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -227,10 +227,10 @@ files:
|
|
227
227
|
- bin/ciinacan
|
228
228
|
- ci_in_a_can.gemspec
|
229
229
|
- lib/ci_in_a_can.rb
|
230
|
-
- lib/ci_in_a_can/app.rb
|
231
230
|
- lib/ci_in_a_can/bash.rb
|
232
231
|
- lib/ci_in_a_can/bash_result.rb
|
233
232
|
- lib/ci_in_a_can/build.rb
|
233
|
+
- lib/ci_in_a_can/cleaner.rb
|
234
234
|
- lib/ci_in_a_can/cli.rb
|
235
235
|
- lib/ci_in_a_can/cli/files.rb
|
236
236
|
- lib/ci_in_a_can/cli/structure_builder.rb
|
@@ -243,6 +243,7 @@ files:
|
|
243
243
|
- lib/ci_in_a_can/repo.rb
|
244
244
|
- lib/ci_in_a_can/run.rb
|
245
245
|
- lib/ci_in_a_can/runner.rb
|
246
|
+
- lib/ci_in_a_can/sinatra.rb
|
246
247
|
- lib/ci_in_a_can/test_result.rb
|
247
248
|
- lib/ci_in_a_can/test_result_notifier.rb
|
248
249
|
- lib/ci_in_a_can/test_runner.rb
|
@@ -260,6 +261,7 @@ files:
|
|
260
261
|
- spec/ci_in_a_can/bash_result_spec.rb
|
261
262
|
- spec/ci_in_a_can/bash_spec.rb
|
262
263
|
- spec/ci_in_a_can/build_spec.rb
|
264
|
+
- spec/ci_in_a_can/cleaner_spec.rb
|
263
265
|
- spec/ci_in_a_can/cli/structure_builder_spec.rb
|
264
266
|
- spec/ci_in_a_can/cli_spec.rb
|
265
267
|
- spec/ci_in_a_can/cloner_spec.rb
|
@@ -304,6 +306,7 @@ test_files:
|
|
304
306
|
- spec/ci_in_a_can/bash_result_spec.rb
|
305
307
|
- spec/ci_in_a_can/bash_spec.rb
|
306
308
|
- spec/ci_in_a_can/build_spec.rb
|
309
|
+
- spec/ci_in_a_can/cleaner_spec.rb
|
307
310
|
- spec/ci_in_a_can/cli/structure_builder_spec.rb
|
308
311
|
- spec/ci_in_a_can/cli_spec.rb
|
309
312
|
- spec/ci_in_a_can/cloner_spec.rb
|
data/lib/ci_in_a_can/app.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'sinatra/base'
|
2
|
-
|
3
|
-
module CiInACan
|
4
|
-
|
5
|
-
class App < Sinatra::Base
|
6
|
-
|
7
|
-
enable :sessions
|
8
|
-
|
9
|
-
before do
|
10
|
-
session[:authenticated] = session[:passphrase] == ENV['PASSPHRASE'].to_s
|
11
|
-
end
|
12
|
-
|
13
|
-
class << self
|
14
|
-
attr_accessor :jobs_location
|
15
|
-
end
|
16
|
-
|
17
|
-
get '/login' do
|
18
|
-
CiInACan::Web.new.login_page
|
19
|
-
end
|
20
|
-
|
21
|
-
post '/login' do
|
22
|
-
web = CiInACan::Web.new(params: params, session: session)
|
23
|
-
web.submit_a_passphrase
|
24
|
-
redirect '/'
|
25
|
-
end
|
26
|
-
|
27
|
-
get '/test_result/:id.json' do
|
28
|
-
CiInACan::Web.new(params: params).show_the_test_result_in_json
|
29
|
-
end
|
30
|
-
|
31
|
-
post %r{/repo/(.+)} do
|
32
|
-
|
33
|
-
web = CiInACan::Web.new(params: params, session: session)
|
34
|
-
unless web.logged_in?
|
35
|
-
redirect '/login'
|
36
|
-
return
|
37
|
-
end
|
38
|
-
repo = web.update_repo_details
|
39
|
-
redirect "/repo/#{repo.id}"
|
40
|
-
end
|
41
|
-
|
42
|
-
get %r{/repo/(.+)} do
|
43
|
-
web = CiInACan::Web.new(params: params, session: session)
|
44
|
-
|
45
|
-
unless web.logged_in?
|
46
|
-
redirect '/login'
|
47
|
-
return
|
48
|
-
end
|
49
|
-
|
50
|
-
web.show_the_repo_edit_form
|
51
|
-
end
|
52
|
-
|
53
|
-
get '/test_result/:id' do
|
54
|
-
CiInACan::Web.new(params: params).show_the_test_result
|
55
|
-
end
|
56
|
-
|
57
|
-
get '/' do
|
58
|
-
CiInACan::Web.new.show_a_list_of_the_runs
|
59
|
-
end
|
60
|
-
|
61
|
-
post %r{/push/(.+)} do
|
62
|
-
CiInACan::Web.new(params: params).start_a_new_build
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|