perkins 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Gemfile +1 -0
- data/README.md +11 -8
- data/Rakefile +1 -18
- data/config/database.yml +19 -0
- data/db/migrate/20150130143050_create_builds.rb +1 -1
- data/db/migrate/20150220143051_add_build_status_to_build_reports.rb +10 -0
- data/db/migrate/20150220143053_add_commit_to_build_reports.rb +10 -0
- data/db/migrate/20150220143054_add_hook_id_to_repo.rb +10 -0
- data/db/schema.rb +4 -2
- data/examples/Capfile +17 -0
- data/examples/Gemfile +14 -1
- data/examples/Gemfile.lock +45 -19
- data/examples/Procfile +8 -3
- data/examples/README.md +12 -0
- data/examples/boot.rb +5 -4
- data/examples/config.ru +2 -11
- data/examples/{database.yml → config/database.example.yml} +0 -0
- data/examples/config/database.yml +27 -0
- data/examples/config/deploy.rb +78 -0
- data/examples/config/deploy/staging.rb +61 -0
- data/examples/{rainbows.rb → config/rainbows/development.rb} +1 -1
- data/examples/config/rainbows/production.rb +56 -0
- data/examples/{sidekiq.yml → config/sidekiq.yml} +0 -0
- data/examples/db/schema.rb +43 -0
- data/examples/rakefile +8 -0
- data/lib/perkins/application.rb +1 -1
- data/lib/perkins/assets.rb +3 -3
- data/lib/perkins/assets/javascripts/app.js +1 -0
- data/lib/perkins/assets/javascripts/perkings.js.coffee +14 -9
- data/lib/perkins/assets/javascripts/perkins/helpers.js.coffee +2 -2
- data/lib/perkins/assets/javascripts/perkins/m/models.js.coffee +15 -9
- data/lib/perkins/assets/javascripts/perkins/router.js.coffee +1 -0
- data/lib/perkins/assets/javascripts/perkins/v/my_repos.js.coffee +1 -1
- data/lib/perkins/assets/javascripts/perkins/v/orgs.js.coffee +1 -1
- data/lib/perkins/assets/javascripts/perkins/v/repo.js.coffee +38 -5
- data/lib/perkins/assets/javascripts/templates/repo.hamlc +5 -14
- data/lib/perkins/assets/javascripts/templates/repos/build_row.hamlc +10 -5
- data/lib/perkins/assets/javascripts/templates/repos/config.hamlc +23 -13
- data/lib/perkins/assets/javascripts/templates/repos/report_detail.hamlc +6 -6
- data/lib/perkins/assets/javascripts/vendor/eventsource.polyfill.js +512 -0
- data/lib/perkins/build/script.rb +2 -1
- data/lib/perkins/build/script/go.rb +1 -1
- data/lib/perkins/build/script/ruby.rb +1 -1
- data/lib/perkins/build/script/stages.rb +0 -1
- data/lib/perkins/build_report.rb +27 -7
- data/lib/perkins/build_worker.rb +10 -15
- data/lib/perkins/git_loader_worker.rb +1 -14
- data/lib/perkins/repo.rb +106 -21
- data/lib/perkins/runner.rb +57 -12
- data/lib/perkins/server.rb +42 -46
- data/lib/perkins/socket_server.rb +38 -0
- data/lib/perkins/version.rb +1 -1
- data/lib/tasks/db_tasks.rake +35 -0
- data/perkins.gemspec +16 -19
- data/spec/README.md +3 -0
- data/spec/lib/build/build_spec.rb +7 -3
- data/spec/lib/repo_spec.rb +23 -32
- data/spec/lib/runner_spec.rb +52 -2
- data/spec/lib/server_spec.rb +15 -6
- data/spec/spec_helper.rb +6 -5
- metadata +21 -57
- data/.DS_Store +0 -0
- data/lib/perkins/views/builds.haml +0 -43
- data/lib/perkins/views/menu.haml +0 -18
- data/lib/perkins/views/orgs.haml +0 -101
- data/lib/perkins/views/profile.haml +0 -31
- data/lib/perkins/views/repos/config.haml +0 -72
- data/lib/perkins/views/repos/github.haml +0 -45
- data/lib/perkins/views/repos/menu.haml +0 -17
- data/lib/perkins/views/repos/repo.haml +0 -64
- data/lib/perkins/views/repos/spinner.haml +0 -3
data/lib/perkins/server.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require '
|
2
|
+
require 'active_record'
|
3
3
|
#require 'sinatra/reloader' #if ENV['RACK_ENV'] == "development"
|
4
4
|
require 'pry'
|
5
5
|
require 'json'
|
@@ -17,7 +17,7 @@ module Perkins
|
|
17
17
|
class Server < Sinatra::Application
|
18
18
|
|
19
19
|
attr_reader :app
|
20
|
-
set server: '
|
20
|
+
set server: 'rainbows', connections: []
|
21
21
|
set :sessions, true
|
22
22
|
set :foo, 'bar'
|
23
23
|
enable :sessions
|
@@ -32,6 +32,13 @@ module Perkins
|
|
32
32
|
|
33
33
|
register Perkins::Auth::Github
|
34
34
|
|
35
|
+
before /.*/ do
|
36
|
+
if request.url.match(/.json$/)
|
37
|
+
request.accept.unshift('application/json')
|
38
|
+
request.path_info = request.path_info.gsub(/.json$/,'')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
35
42
|
#authenticate all -
|
36
43
|
before do
|
37
44
|
unless %w[stream sse logout unauthenticated /auth/github/callback /repos/receiver badge].include? request.path_info.split('/')[1]
|
@@ -87,7 +94,6 @@ module Perkins
|
|
87
94
|
content_type :json
|
88
95
|
repo = find_repo(params)
|
89
96
|
#detects a recently added repo (no dir and no prev builds)
|
90
|
-
enqueue_git_clone(repo) if !repo.exists? && repo.last_report_id.blank?
|
91
97
|
repo.as_json(methods: [:last_report_id, :http_url]).to_json
|
92
98
|
end
|
93
99
|
|
@@ -101,8 +107,7 @@ module Perkins
|
|
101
107
|
get '/repos/:login/:name/builds' do
|
102
108
|
content_type :json
|
103
109
|
repo = find_repo(params)
|
104
|
-
|
105
|
-
repo.exists? ? repo.build_reports.to_json : enqueue_git_clone(repo)
|
110
|
+
repo.build_reports.to_json
|
106
111
|
end
|
107
112
|
|
108
113
|
get '/repos/:login/:name/builds/:build_id' do
|
@@ -110,23 +115,21 @@ module Perkins
|
|
110
115
|
repo = find_repo(params)
|
111
116
|
record = repo.build_reports.find(params[:build_id])
|
112
117
|
#record.to_json
|
113
|
-
|
118
|
+
record.to_json
|
114
119
|
end
|
115
120
|
|
116
121
|
get '/repos/:login/:name/config' do
|
117
122
|
content_type :json
|
118
123
|
repo = find_repo(params)
|
119
|
-
|
120
|
-
hook
|
121
|
-
hook.to_attrs.to_json
|
124
|
+
hook = repo.get_hook
|
125
|
+
hook.try(:to_attrs).try(:to_json) || {}.to_json
|
122
126
|
end
|
123
127
|
|
124
128
|
#TODO send this through bg job
|
125
129
|
get '/repos/:login/:name/run_commit' do
|
126
130
|
content_type :json
|
127
131
|
repo = find_repo(params)
|
128
|
-
repo.
|
129
|
-
sha = repo.git.log.map(&:sha).first
|
132
|
+
sha = github_user.api.commits(repo.name).first[:sha]
|
130
133
|
repo.add_commit(sha, "master")
|
131
134
|
repo.to_json
|
132
135
|
end
|
@@ -134,24 +137,8 @@ module Perkins
|
|
134
137
|
#TODO for json
|
135
138
|
post '/repos/:login/:name/add_hook' do
|
136
139
|
repo = find_repo(params)
|
137
|
-
hook =
|
138
|
-
|
139
|
-
res = github_user.api.edit_hook(
|
140
|
-
repo.name,
|
141
|
-
hook["id"],
|
142
|
-
'web',
|
143
|
-
{:url => params[:webhook_url], :content_type => 'json'},
|
144
|
-
{:active => true}
|
145
|
-
)
|
146
|
-
else
|
147
|
-
res = github_user.api.create_hook(
|
148
|
-
repo.name,
|
149
|
-
'web',
|
150
|
-
{ :url => params[:webhook_url], :content_type => 'json'},
|
151
|
-
{ :events => ['push'], :active => true}
|
152
|
-
)
|
153
|
-
end
|
154
|
-
redirect "/repos/#{repo.name}/config"
|
140
|
+
hook = repo.add_hook(params[:webhook_url])
|
141
|
+
hook.try(:to_attrs).try(:to_json) || {}.to_json
|
155
142
|
end
|
156
143
|
|
157
144
|
get '/repos/:login/:name/builds/:build_id/restart' do
|
@@ -186,14 +173,27 @@ module Perkins
|
|
186
173
|
github_user.api.user.to_attrs.merge({repos: repos}).to_json
|
187
174
|
end
|
188
175
|
|
176
|
+
@@conns = []
|
189
177
|
|
190
178
|
get '/stream', provides: 'text/event-stream' do
|
191
|
-
stream
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
179
|
+
stream(:keep_open) do |out|
|
180
|
+
@@conns << out
|
181
|
+
out.callback { @@conns.delete(out) }
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
Thread.new do
|
186
|
+
redis = Redis.connect
|
187
|
+
redis.psubscribe('message', 'message.*') do |on|
|
188
|
+
on.pmessage do |match, channel, message|
|
189
|
+
|
190
|
+
channel = channel.sub('message.', '')
|
191
|
+
|
192
|
+
@@conns.each do |out|
|
193
|
+
out << "event: #{channel}\n"
|
194
|
+
out << "data: #{message}\n\n"
|
195
|
+
end
|
196
|
+
end
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
@@ -210,9 +210,11 @@ module Perkins
|
|
210
210
|
|
211
211
|
def initialize(args={})
|
212
212
|
super
|
213
|
-
return if args.blank?
|
214
|
-
puts "PerkinsCI environment loaded on #{args[:host]}:#{args[:port]}".green
|
213
|
+
#return if args.blank?
|
215
214
|
app = Perkins::Application.instance
|
215
|
+
|
216
|
+
puts "PerkinsCI #{settings.environment} environment loaded on #{app.host}:#{app.port}".green
|
217
|
+
|
216
218
|
self.class.set :perkins_application, app
|
217
219
|
self.class.set :github_options, {
|
218
220
|
:scopes => "admin:repo_hook,repo,user:email",
|
@@ -237,17 +239,13 @@ module Perkins
|
|
237
239
|
def find_repo(params)
|
238
240
|
id = "#{params[:login]}/#{params[:name]}"
|
239
241
|
repo = Repo.find_by(name: id)
|
240
|
-
#repo.load_git #it seems that we dont need this here
|
241
242
|
repo
|
242
243
|
end
|
243
244
|
|
244
|
-
def enqueue_git_clone(repo)
|
245
|
-
GitLoaderWorker.perform_async(repo.id )
|
246
|
-
end
|
247
|
-
|
248
245
|
def request_badge(opts={})
|
249
246
|
begin
|
250
|
-
|
247
|
+
image_path = "https://img.shields.io/badge/build-#{opts[:status]}-#{opts[:color]}.svg?style=flat-square"
|
248
|
+
url = URI.parse(image_path)
|
251
249
|
result = Net::HTTP.get(url)
|
252
250
|
rescue => e
|
253
251
|
e
|
@@ -277,8 +275,6 @@ module Perkins
|
|
277
275
|
#set :database, 'sqlite:///db/test.sqlite3'
|
278
276
|
end
|
279
277
|
|
280
|
-
#::Perkins::Server.run!(options)
|
281
|
-
|
282
278
|
end
|
283
279
|
|
284
280
|
def self.start_listener(app_config)
|
@@ -291,7 +287,7 @@ module Perkins
|
|
291
287
|
####################################
|
292
288
|
|
293
289
|
def default_data
|
294
|
-
{
|
290
|
+
{ year: Time.now.year, app: @app}
|
295
291
|
end
|
296
292
|
|
297
293
|
helpers do
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'goliath'
|
2
|
+
require 'redis'
|
3
|
+
|
4
|
+
module Perkins
|
5
|
+
class Subscribe < Goliath::API
|
6
|
+
def response(env)
|
7
|
+
EM.synchrony do
|
8
|
+
@redis = Redis.new(Options::redis)
|
9
|
+
channel = env["REQUEST_PATH"].sub(/^\/subscribe\//, '')
|
10
|
+
|
11
|
+
# We pass the subscribe method a block which describes what to
|
12
|
+
# do when we receive an event.
|
13
|
+
# This block writes the message formatted as a server sent event
|
14
|
+
# to the HTTP stream.
|
15
|
+
@redis.subscribe(channel) do |on|
|
16
|
+
on.message do |channel, message|
|
17
|
+
@message = message
|
18
|
+
env.stream_send(payload)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
streaming_response(200, { 'Content-Type' => "text/event-stream" })
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def on_close(env)
|
28
|
+
@redis.disconnect
|
29
|
+
end
|
30
|
+
|
31
|
+
def payload
|
32
|
+
"id: #{Time.now}\n" +
|
33
|
+
"data: #{@message}" +
|
34
|
+
"\r\n\n"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/perkins/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "pry"
|
2
|
+
require "perkins"
|
3
|
+
require 'yaml'
|
4
|
+
require 'logger'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
include ActiveRecord::Tasks
|
8
|
+
|
9
|
+
class Seeder
|
10
|
+
def initialize(seed_file)
|
11
|
+
@seed_file = seed_file
|
12
|
+
end
|
13
|
+
|
14
|
+
def load_seed
|
15
|
+
raise "Seed file '#{@seed_file}' does not exist" unless File.file?(@seed_file)
|
16
|
+
load @seed_file
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
root = Dir.pwd #File.expand_path '..', __FILE__
|
22
|
+
DatabaseTasks.env = ENV['ENV'] || 'development'
|
23
|
+
DatabaseTasks.database_configuration = YAML.load(File.read(File.join(root, 'config/database.yml')))
|
24
|
+
DatabaseTasks.db_dir = File.join root, 'db'
|
25
|
+
DatabaseTasks.fixtures_path = File.join root, 'test/fixtures'
|
26
|
+
DatabaseTasks.migrations_paths = [File.join(root, 'db/migrate'), File.join(Perkins::ROOT_PATH, "db/migrate") ]
|
27
|
+
DatabaseTasks.seed_loader = Seeder.new File.join root, 'db/seeds.rb'
|
28
|
+
DatabaseTasks.root = root
|
29
|
+
|
30
|
+
task :environment do
|
31
|
+
ActiveRecord::Base.configurations = DatabaseTasks.database_configuration
|
32
|
+
ActiveRecord::Base.establish_connection DatabaseTasks.env.to_sym
|
33
|
+
end
|
34
|
+
|
35
|
+
load 'active_record/railties/databases.rake'
|
data/perkins.gemspec
CHANGED
@@ -21,32 +21,29 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'activesupport', ['>= 3', '< 4.1']
|
22
22
|
spec.add_dependency 'activerecord', ['>= 3', '< 4.1']
|
23
23
|
|
24
|
-
spec.add_dependency "sinatra-activerecord"
|
25
24
|
spec.add_dependency "sinatra-contrib"
|
26
25
|
spec.add_dependency "sqlite3"
|
27
26
|
|
28
|
-
spec.
|
29
|
-
spec.
|
30
|
-
spec.
|
31
|
-
spec.
|
32
|
-
spec.
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
spec.
|
37
|
-
spec.
|
38
|
-
spec.
|
39
|
-
spec.
|
40
|
-
spec.
|
41
|
-
spec.
|
42
|
-
spec.add_runtime_dependency("sidekiq")
|
43
|
-
spec.add_runtime_dependency("dotenv-rails")
|
27
|
+
spec.add_dependency("git")
|
28
|
+
spec.add_dependency("redis")
|
29
|
+
spec.add_dependency("thor")
|
30
|
+
spec.add_dependency("sinatra")
|
31
|
+
spec.add_dependency("haml")
|
32
|
+
spec.add_dependency("sprockets")
|
33
|
+
spec.add_dependency("haml_coffee_assets")
|
34
|
+
spec.add_dependency("yui-compressor")
|
35
|
+
spec.add_dependency("rdiscount")
|
36
|
+
spec.add_dependency("travis-yaml")
|
37
|
+
spec.add_dependency("redis-namespace")
|
38
|
+
spec.add_dependency("thin")
|
39
|
+
spec.add_dependency("sidekiq")
|
40
|
+
spec.add_dependency("dotenv-rails")
|
44
41
|
|
45
42
|
spec.add_dependency "warden-github", "~>1.0"
|
46
43
|
|
47
44
|
# I find it well worth to include CoffeeScript and SASS as well
|
48
|
-
spec.
|
49
|
-
spec.
|
45
|
+
spec.add_dependency("coffee-script")
|
46
|
+
spec.add_dependency("sass")
|
50
47
|
|
51
48
|
|
52
49
|
spec.add_development_dependency "bundler", "~> 1.7"
|
data/spec/README.md
ADDED
@@ -32,9 +32,9 @@ describe "Repo" do
|
|
32
32
|
before :each do
|
33
33
|
@repo = Perkins::Repo.where(cached: false).last
|
34
34
|
allow_any_instance_of(Perkins::Repo).to receive(:check_config_existence).and_return(file)
|
35
|
-
|
36
|
-
expect(@repo.git).to be_instance_of(Git::Base)
|
37
|
-
|
35
|
+
#@repo.load_git
|
36
|
+
#expect(@repo.git).to be_instance_of(Git::Base)
|
37
|
+
#@path = @repo.git.dir.path
|
38
38
|
end
|
39
39
|
|
40
40
|
after :each do
|
@@ -46,8 +46,12 @@ describe "Repo" do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "run run run should add a new report" do
|
49
|
+
@repo.load_git
|
49
50
|
sha = @repo.git.log.map(&:sha).first
|
51
|
+
@repo.runner.report = @repo.build_reports.create
|
52
|
+
|
50
53
|
@repo.runner.run(sha)
|
54
|
+
expect(@repo.build_reports.last.build_status).to_not be_blank
|
51
55
|
expect(@repo.build_reports.size).to be == 1
|
52
56
|
#binding.pry
|
53
57
|
#expect(@repo.runner.status).to be == true
|
data/spec/lib/repo_spec.rb
CHANGED
@@ -44,7 +44,6 @@ describe "Repo" do
|
|
44
44
|
expect(r.name).to_not be_blank
|
45
45
|
expect(r.id).to_not be_blank
|
46
46
|
expect(r.url).to_not be_blank
|
47
|
-
#expect(r.local_path).to_not be_blank
|
48
47
|
end
|
49
48
|
|
50
49
|
context "load git" do
|
@@ -52,34 +51,32 @@ describe "Repo" do
|
|
52
51
|
@repo = Perkins::Repo.first
|
53
52
|
end
|
54
53
|
|
55
|
-
it "will not
|
56
|
-
expect(@repo.
|
57
|
-
expect(@repo.downloaded?).to be == false
|
54
|
+
it "git will be not loaded" do
|
55
|
+
expect(@repo.git).to be_blank
|
58
56
|
end
|
59
57
|
|
60
58
|
it "will be downloaded after load_git" do
|
61
59
|
@repo.load_git
|
62
|
-
expect(@repo.
|
60
|
+
expect(@repo.git).to be_present
|
61
|
+
expect(@repo.git.dir.path).to be == "/tmp/#{@repo.name}"
|
62
|
+
expect(File.exist?(@repo.git.dir.path)).to be_present
|
63
63
|
end
|
64
|
-
end
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
@repo = Perkins::Repo.first
|
65
|
+
it "override dir with virtual_sha" do
|
66
|
+
@repo.virtual_sha = "xxx"
|
69
67
|
@repo.load_git
|
70
|
-
expect(@repo.git).to
|
71
|
-
@
|
72
|
-
|
73
|
-
|
74
|
-
it "should download repo" do
|
75
|
-
expect(File.exist?(@path)).to be_present
|
68
|
+
expect(@repo.git).to be_present
|
69
|
+
expect(@repo.git.dir.path).to be == "/tmp/#{@repo.name}xxx"
|
70
|
+
expect(File.exist?(@repo.git.dir.path)).to be_present
|
76
71
|
end
|
77
72
|
|
78
73
|
it "should have a default runner" do
|
74
|
+
@repo.load_git
|
79
75
|
expect(@repo.runner).to_not be_blank
|
80
76
|
end
|
81
77
|
|
82
78
|
it "should have branches" do
|
79
|
+
@repo.load_git
|
83
80
|
expect(@repo.runner_branch).to be == ["master"]
|
84
81
|
expect(@repo.branches).to include("master")
|
85
82
|
end
|
@@ -97,33 +94,27 @@ describe "Repo" do
|
|
97
94
|
it "should have a runner" do
|
98
95
|
expect(@repo.runner).to be_instance_of(Perkins::Runner)
|
99
96
|
end
|
100
|
-
|
101
|
-
it "runner true" do
|
102
|
-
sha = @repo.git.log.map(&:sha).first
|
103
|
-
allow_any_instance_of(Perkins::Runner).to receive(:run_script).and_return("stubbed")
|
104
|
-
allow_any_instance_of(Perkins::Runner).to receive(:successful_command?).and_return(true)
|
105
|
-
runner = @repo.runner
|
106
|
-
runner.run(sha)
|
107
|
-
expect(runner.response).to be == "stubbed"
|
108
|
-
expect(runner.status).to be == true
|
109
|
-
expect(@repo.build_status).to be == "stopped"
|
110
|
-
end
|
111
97
|
end
|
112
98
|
|
113
99
|
context "receive commit" do
|
114
100
|
before :each do
|
115
101
|
allow_any_instance_of(Perkins::Repo).to receive(:check_config_existence).and_return(file)
|
116
102
|
@repo = Perkins::Repo.first
|
117
|
-
|
118
|
-
expect(@repo.git).to be_instance_of(Git::Base)
|
119
|
-
|
103
|
+
#@repo.load_git
|
104
|
+
#expect(@repo.git).to be_instance_of(Git::Base)
|
105
|
+
#@path = @repo.git.dir.path
|
106
|
+
end
|
107
|
+
|
108
|
+
it "will enqueue commit" do
|
109
|
+
sha = "123456789"
|
110
|
+
expect(@repo).to receive(:enqueue_commit) #.with(sha, "master")
|
111
|
+
@repo.add_commit(sha, "master")
|
120
112
|
end
|
121
113
|
|
122
114
|
it "will increment Worker jobs when receive commit " do
|
123
|
-
sha =
|
115
|
+
sha = "123456789"
|
124
116
|
@repo.add_commit(sha, "master")
|
125
|
-
expect(
|
126
|
-
expect(Perkins::Worker.jobs.size).to be > 0
|
117
|
+
expect(Perkins::BuildWorker.jobs.size).to be > 0
|
127
118
|
end
|
128
119
|
|
129
120
|
end
|
data/spec/lib/runner_spec.rb
CHANGED
@@ -38,12 +38,20 @@ describe "Runner" do
|
|
38
38
|
@runner = Perkins::Runner.new
|
39
39
|
@runner.config = file
|
40
40
|
@runner.repo = repo
|
41
|
+
|
42
|
+
report = Perkins::BuildReport.new
|
43
|
+
report.sha = "master"
|
44
|
+
report.branch = "master"
|
45
|
+
|
46
|
+
@runner.repo.build_reports << report
|
47
|
+
@runner.repo.save
|
48
|
+
|
49
|
+
@runner.report = report
|
41
50
|
#allow_any_instance_of(Perkins::Repo).to receive(:clone_or_load).and_return(true)
|
42
51
|
#allow_any_instance_of(Perkins::Repo).to receive(:git).and_return(Git::Base.new)
|
43
52
|
end
|
44
53
|
|
45
54
|
it "runner should raise error in case it fails" do
|
46
|
-
|
47
55
|
expect{@runner.run!}.to raise_error
|
48
56
|
end
|
49
57
|
|
@@ -51,10 +59,19 @@ describe "Runner" do
|
|
51
59
|
#allow_any_instance_of(Git::Base).to receive(:chdir).and_return(true)
|
52
60
|
expect{@runner.run("master")}.to_not raise_error
|
53
61
|
#expect(Git::Base).to have_received(:chdir)
|
54
|
-
|
55
62
|
expect(@runner.duration).to be > 0
|
56
63
|
expect(@runner).to_not be_running
|
64
|
+
end
|
65
|
+
|
66
|
+
it "will make repo in sha dir" do
|
67
|
+
#allow_any_instance_of(Git::Base).to receive(:chdir).and_return(true)
|
68
|
+
@runner.repo.virtual_sha = "master"
|
57
69
|
|
70
|
+
expect{@runner.run("master")}.to_not raise_error
|
71
|
+
#expect(Git::Base).to have_received(:chdir)
|
72
|
+
|
73
|
+
expect(@runner.duration).to be > 0
|
74
|
+
expect(@runner).to_not be_running
|
58
75
|
end
|
59
76
|
end
|
60
77
|
|
@@ -63,6 +80,16 @@ describe "Runner" do
|
|
63
80
|
before :each do
|
64
81
|
repo.clone_or_load
|
65
82
|
@runner = repo.runner
|
83
|
+
|
84
|
+
|
85
|
+
report = Perkins::BuildReport.new
|
86
|
+
report.sha = "master"
|
87
|
+
report.branch = "master"
|
88
|
+
repo.build_reports << report
|
89
|
+
repo.branch = "master"
|
90
|
+
repo.save
|
91
|
+
@runner.report = report
|
92
|
+
|
66
93
|
end
|
67
94
|
|
68
95
|
it "should install bundler" do
|
@@ -73,5 +100,28 @@ describe "Runner" do
|
|
73
100
|
|
74
101
|
end
|
75
102
|
|
103
|
+
context "build report" do
|
104
|
+
|
105
|
+
let( :repo ){ Perkins::Repo.find_by(name: "michelson/godard") }
|
106
|
+
before :each do
|
107
|
+
repo.clone_or_load
|
108
|
+
@runner = repo.runner
|
109
|
+
|
110
|
+
|
111
|
+
@report = Perkins::BuildReport.new
|
112
|
+
@report.sha = "master"
|
113
|
+
@report.branch = "master"
|
114
|
+
repo.build_reports << @report
|
115
|
+
repo.branch = "master"
|
116
|
+
repo.save
|
117
|
+
@runner.report = @report
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
it "retrieve_commit_info" do
|
122
|
+
@report.retrieve_commit_info
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
76
126
|
end
|
77
127
|
|