ci_in_a_can 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ciinacan +2 -1
- data/lib/ci_in_a_can.rb +1 -0
- data/lib/ci_in_a_can/app.rb +4 -0
- data/lib/ci_in_a_can/build.rb +4 -6
- data/lib/ci_in_a_can/daemon.rb +1 -0
- data/lib/ci_in_a_can/github.rb +1 -1
- data/lib/ci_in_a_can/test_runner.rb +2 -3
- data/lib/ci_in_a_can/version.rb +1 -1
- data/spec/ci_in_a_can/build_spec.rb +5 -4
- data/spec/ci_in_a_can/github_spec.rb +18 -10
- data/spec/ci_in_a_can/test_runner_spec.rb +12 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 370913ef96b0b8ea7bad7d243a2ef57c3bc0c961
|
4
|
+
data.tar.gz: da919a87438e340c1b0efe14351f7ee66bd120c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5933778ec97dd4577df453bae506f08e08d543e579a0fc2ac09705bd04b2e9ec6bae3f8c61344844f5b6c7e76160734df50b3024d3543091b93b2327d0fea9d4
|
7
|
+
data.tar.gz: 6d59e751e7e9937dc19068cba66a215086f34858897ed35edd8853576bc16490b7db05cf99d289baef4139b2f6a4d1fd27c16185f6f3464e7da608c1f2f56fde
|
data/bin/ciinacan
CHANGED
@@ -44,7 +44,8 @@ eval("CiInACan.results_location = '\#{this_directory}' + '/results'")
|
|
44
44
|
options = {
|
45
45
|
access_token: ENV['GITHUB_AUTH_TOKEN'],
|
46
46
|
working_location: this_directory + "/repos",
|
47
|
-
watching_location: this_directory + "/jobs"
|
47
|
+
watching_location: this_directory + "/jobs",
|
48
|
+
site_url: ENV['SITE_URL']
|
48
49
|
}
|
49
50
|
CiInACan::Daemon.start options
|
50
51
|
sleep
|
data/lib/ci_in_a_can.rb
CHANGED
data/lib/ci_in_a_can/app.rb
CHANGED
data/lib/ci_in_a_can/build.rb
CHANGED
@@ -3,13 +3,8 @@ module CiInACan
|
|
3
3
|
class Build
|
4
4
|
|
5
5
|
attr_accessor :git_ssh, :local_location, :repo, :sha
|
6
|
-
attr_accessor :pre_test_commands
|
7
6
|
attr_accessor :id
|
8
7
|
|
9
|
-
def initialize
|
10
|
-
self.pre_test_commands = []
|
11
|
-
end
|
12
|
-
|
13
8
|
def self.parse content
|
14
9
|
data = JSON.parse content
|
15
10
|
data['payload'] = JSON.parse data['payload']
|
@@ -20,10 +15,13 @@ module CiInACan
|
|
20
15
|
build.git_ssh = "git@github.com:#{splat[3]}/#{splat[4]}.git"
|
21
16
|
build.repo = "#{splat[3]}/#{splat[4]}"
|
22
17
|
build.sha = data['payload']['head_commit']['id']
|
23
|
-
build.pre_test_commands = []
|
24
18
|
build
|
25
19
|
end
|
26
20
|
|
21
|
+
def commands
|
22
|
+
['bundle install', 'bundle exec rake']
|
23
|
+
end
|
24
|
+
|
27
25
|
end
|
28
26
|
|
29
27
|
end
|
data/lib/ci_in_a_can/daemon.rb
CHANGED
data/lib/ci_in_a_can/github.rb
CHANGED
@@ -20,7 +20,7 @@ module CiInACan
|
|
20
20
|
|
21
21
|
def report_complete_status_for build, test_result
|
22
22
|
return nil unless client
|
23
|
-
client.create_status
|
23
|
+
client.create_status(build.repo, build.sha, (test_result.passed ? 'success' : 'failure'), { target_url: "#{CiInACan.site_url}/test_result/#{test_result.id}" } )
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module CiInACan
|
2
2
|
module TestRunner
|
3
3
|
def self.run_tests_for build
|
4
|
-
commands = ["cd #{build.local_location}"
|
5
|
-
build.
|
6
|
-
commands << "bundle exec rake"
|
4
|
+
commands = ["cd #{build.local_location}"]
|
5
|
+
build.commands.each { |c| commands << c }
|
7
6
|
|
8
7
|
bash_result = CiInACan::Bash.run commands.join('; ')
|
9
8
|
|
data/lib/ci_in_a_can/version.rb
CHANGED
@@ -2,10 +2,11 @@ require_relative '../spec_helper'
|
|
2
2
|
|
3
3
|
describe CiInACan::Build do
|
4
4
|
|
5
|
-
it "should default
|
6
|
-
result = CiInACan::Build.new.
|
7
|
-
result.count.must_equal
|
8
|
-
result.
|
5
|
+
it "should default commands to the basic ruby conventions" do
|
6
|
+
result = CiInACan::Build.new.commands
|
7
|
+
result.count.must_equal 2
|
8
|
+
result[0].must_equal 'bundle install'
|
9
|
+
result[1].must_equal 'bundle exec rake'
|
9
10
|
end
|
10
11
|
|
11
12
|
[:compare, :sha, :git_ssh, :repo].to_objects {[
|
@@ -63,23 +63,34 @@ describe CiInACan::Github do
|
|
63
63
|
|
64
64
|
describe "report_complete_status" do
|
65
65
|
|
66
|
+
let(:build) do
|
67
|
+
b = CiInACan::Build.new
|
68
|
+
b.sha = UUID.new.generate
|
69
|
+
b.repo = Object.new
|
70
|
+
b
|
71
|
+
end
|
72
|
+
|
73
|
+
let(:site_url) { UUID.new.generate }
|
74
|
+
let(:expected_url) { "#{site_url}/test_result/#{test_result.id}" }
|
75
|
+
|
76
|
+
before do
|
77
|
+
CiInACan.stubs(:site_url).returns site_url
|
78
|
+
end
|
79
|
+
|
66
80
|
describe "a successful test result" do
|
67
81
|
|
68
82
|
let(:test_result) do
|
69
83
|
test_result = Object.new
|
84
|
+
test_result.stubs(:id).returns UUID.new.generate
|
70
85
|
test_result.stubs(:passed).returns true
|
71
86
|
test_result
|
72
87
|
end
|
73
88
|
|
74
89
|
it "should report a success status to the github client" do
|
75
|
-
build = CiInACan::Build.new
|
76
|
-
build.sha = Object.new
|
77
|
-
build.repo = Object.new
|
78
|
-
|
79
90
|
client = Object.new
|
80
91
|
CiInACan::Github.stubs(:client).returns client
|
81
92
|
|
82
|
-
client.expects(:create_status).with
|
93
|
+
client.expects(:create_status).with(build.repo, build.sha, 'success', { target_url: expected_url } )
|
83
94
|
|
84
95
|
CiInACan::Github.report_complete_status_for build, test_result
|
85
96
|
end
|
@@ -91,18 +102,15 @@ describe CiInACan::Github do
|
|
91
102
|
let(:test_result) do
|
92
103
|
test_result = Object.new
|
93
104
|
test_result.stubs(:passed).returns false
|
105
|
+
test_result.stubs(:id).returns UUID.new.generate
|
94
106
|
test_result
|
95
107
|
end
|
96
108
|
|
97
109
|
it "should report a success status to the github client" do
|
98
|
-
build = CiInACan::Build.new
|
99
|
-
build.sha = Object.new
|
100
|
-
build.repo = Object.new
|
101
|
-
|
102
110
|
client = Object.new
|
103
111
|
CiInACan::Github.stubs(:client).returns client
|
104
112
|
|
105
|
-
client.expects(:create_status).with
|
113
|
+
client.expects(:create_status).with(build.repo, build.sha, 'failure', { target_url: expected_url } )
|
106
114
|
|
107
115
|
CiInACan::Github.report_complete_status_for build, test_result
|
108
116
|
end
|
@@ -19,10 +19,14 @@ describe CiInACan::TestRunner do
|
|
19
19
|
|
20
20
|
describe "when no special commands exist" do
|
21
21
|
|
22
|
+
before do
|
23
|
+
build.stubs(:local_location).returns test.local_location
|
24
|
+
build.stubs(:commands).returns []
|
25
|
+
end
|
26
|
+
|
22
27
|
it "should cd into the local directory and run the default rake task" do
|
23
|
-
build.local_location = test.local_location
|
24
28
|
|
25
|
-
CiInACan::Bash.expects(:run).with("cd #{test.local_location}
|
29
|
+
CiInACan::Bash.expects(:run).with("cd #{test.local_location}").returns bash_result
|
26
30
|
|
27
31
|
CiInACan::TestRunner.run_tests_for build
|
28
32
|
end
|
@@ -62,12 +66,14 @@ describe CiInACan::TestRunner do
|
|
62
66
|
|
63
67
|
describe "when two special commands exist" do
|
64
68
|
|
65
|
-
|
66
|
-
build.local_location
|
69
|
+
before do
|
70
|
+
build.stubs(:local_location).returns test.local_location
|
71
|
+
end
|
67
72
|
|
68
|
-
|
73
|
+
it "should cd into the local directory, run the commands, then run the default rake task" do
|
74
|
+
build.stubs(:commands).returns ["1", "2"]
|
69
75
|
|
70
|
-
CiInACan::Bash.expects(:run).with("cd #{test.local_location};
|
76
|
+
CiInACan::Bash.expects(:run).with("cd #{test.local_location}; 1; 2").returns bash_result
|
71
77
|
|
72
78
|
CiInACan::TestRunner.run_tests_for build
|
73
79
|
end
|