ci_in_a_can 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31e9275f019608a97e7e6ea655b439cd587333bc
4
- data.tar.gz: 89511f751f0190e266e6caecbb9ac25b04062712
3
+ metadata.gz: 370913ef96b0b8ea7bad7d243a2ef57c3bc0c961
4
+ data.tar.gz: da919a87438e340c1b0efe14351f7ee66bd120c0
5
5
  SHA512:
6
- metadata.gz: 9f9011926a330dae7f54f9615f5b88de47ad36ed8c85eff279bf2db7521437e2437cca5e10f8f2c022b6577bfb48d1ef78988738dc52651359d5942220b3e992
7
- data.tar.gz: afbcbac244e588ca6c6c7bcd9914a64a7fc962cb83255bab224e757dcd6a5b70a6806c8ec11d7e63610cb0ab61d36594fd57505ea1649e9af712501b7f3b9434
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
@@ -7,6 +7,7 @@ module CiInACan
7
7
 
8
8
  class << self
9
9
  attr_accessor :results_location
10
+ attr_accessor :site_url
10
11
  end
11
12
 
12
13
  end
@@ -10,6 +10,10 @@ module CiInACan
10
10
  attr_accessor :jobs_location
11
11
  end
12
12
 
13
+ get '/test_result/:id' do
14
+ CiInACan::TestResult.find(params[:id]).to_json
15
+ end
16
+
13
17
  get '/' do
14
18
  <<EOF
15
19
  <html>
@@ -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
@@ -1,6 +1,7 @@
1
1
  module CiInACan
2
2
  module Daemon
3
3
  def self.start options
4
+ CiInACan.site_url = options[:site_url]
4
5
  CiInACan::Github.access_token = options[:access_token]
5
6
  CiInACan::Watcher.watch options[:watching_location], options[:working_location]
6
7
  sleep
@@ -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 build.repo, build.sha, (test_result.passed ? 'success' : 'failure')
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}", "bundle install"]
5
- build.pre_test_commands.each { |c| commands << c }
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
 
@@ -1,3 +1,3 @@
1
1
  module CiInACan
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -2,10 +2,11 @@ require_relative '../spec_helper'
2
2
 
3
3
  describe CiInACan::Build do
4
4
 
5
- it "should default pre_test_commands to an empty array" do
6
- result = CiInACan::Build.new.pre_test_commands
7
- result.count.must_equal 0
8
- result.is_a?(Array).must_equal true
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 build.repo, build.sha, 'success'
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 build.repo, build.sha, 'failure'
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}; bundle install; bundle exec rake").returns bash_result
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
- it "should cd into the local directory, run the commands, then run the default rake task" do
66
- build.local_location = test.local_location
69
+ before do
70
+ build.stubs(:local_location).returns test.local_location
71
+ end
67
72
 
68
- build.pre_test_commands = ["1", "2"]
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}; bundle install; 1; 2; bundle exec rake").returns bash_result
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_in_a_can
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon