foca-integrity 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION.yml +1 -1
- data/app.rb +8 -2
- data/bin/integrity +3 -3
- data/integrity.gemspec +7 -6
- data/lib/integrity.rb +24 -13
- data/lib/integrity/builder.rb +2 -2
- data/lib/integrity/notifier.rb +10 -9
- data/lib/integrity/project.rb +2 -1
- data/lib/integrity/scm/git.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- metadata +11 -2
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/app.rb
CHANGED
@@ -104,9 +104,15 @@ post "/:project/push" do
|
|
104
104
|
|
105
105
|
begin
|
106
106
|
payload = JSON.parse(params[:payload] || "")
|
107
|
-
|
108
|
-
|
107
|
+
|
108
|
+
if Integrity.config[:build_all_commits]
|
109
|
+
payload['commits'].sort_by { |commit| Time.parse(commit['timestamp']) }.each do |commit|
|
110
|
+
current_project.build(commit['id']) if payload['ref'] =~ /#{current_project.branch}/
|
111
|
+
end
|
112
|
+
else
|
113
|
+
current_project.build(payload['after']) if payload['ref'] =~ /#{current_project.branch}/
|
109
114
|
end
|
115
|
+
|
110
116
|
'Thanks, build started.'
|
111
117
|
rescue JSON::ParserError => exception
|
112
118
|
invalid_payload!(exception.to_s)
|
data/bin/integrity
CHANGED
@@ -15,7 +15,7 @@ class WithIntegrity < Thor
|
|
15
15
|
create_dir_structure
|
16
16
|
copy_template_files
|
17
17
|
edit_template_files
|
18
|
-
create_db(root /
|
18
|
+
create_db(root / "config.yml")
|
19
19
|
after_setup_message
|
20
20
|
end
|
21
21
|
|
@@ -55,9 +55,9 @@ class WithIntegrity < Thor
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def edit_thin_configuration
|
58
|
-
config = File.read(root /
|
58
|
+
config = File.read(root / "thin.yml")
|
59
59
|
config.gsub! %r(/apps/integrity), root
|
60
|
-
File.open(root /
|
60
|
+
File.open(root / "thin.yml", 'w') { |f| f.puts config }
|
61
61
|
end
|
62
62
|
|
63
63
|
def after_setup_message
|
data/integrity.gemspec
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
Gem::Specification.new do |s|
|
4
2
|
s.name = %q{integrity}
|
5
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.4"
|
6
4
|
|
7
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
6
|
s.authors = ["Nicol\303\241s Sanguinetti", "Simon Rozet"]
|
9
|
-
s.date = %q{2008-
|
7
|
+
s.date = %q{2008-12-08}
|
10
8
|
s.default_executable = %q{integrity}
|
11
9
|
s.description = %q{Your Friendly Continuous Integration server. Easy, fun and painless!}
|
12
10
|
s.email = %q{contacto@nicolassanguinetti.info}
|
@@ -16,14 +14,14 @@ Gem::Specification.new do |s|
|
|
16
14
|
s.post_install_message = %q{Run `integrity help` for information on how to setup Integrity.}
|
17
15
|
s.require_paths = ["lib"]
|
18
16
|
s.rubyforge_project = %q{integrity}
|
19
|
-
s.rubygems_version = %q{1.
|
17
|
+
s.rubygems_version = %q{1.2.0}
|
20
18
|
s.summary = %q{The easy and fun Continuous Integration server}
|
21
19
|
|
22
20
|
if s.respond_to? :specification_version then
|
23
21
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
22
|
s.specification_version = 2
|
25
23
|
|
26
|
-
if
|
24
|
+
if current_version >= 3 then
|
27
25
|
s.add_runtime_dependency(%q<sinatra>, [">= 0.3.2"])
|
28
26
|
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
29
27
|
s.add_runtime_dependency(%q<dm-core>, [">= 0.9.5"])
|
@@ -37,6 +35,7 @@ Gem::Specification.new do |s|
|
|
37
35
|
s.add_runtime_dependency(%q<foca-sinatra-diddies>, [">= 0.0.2"])
|
38
36
|
s.add_runtime_dependency(%q<rspec_hpricot_matchers>, [">= 0"])
|
39
37
|
s.add_runtime_dependency(%q<thor>, [">= 0"])
|
38
|
+
s.add_runtime_dependency(%q<bcrypt-ruby>, [">= 0"])
|
40
39
|
else
|
41
40
|
s.add_dependency(%q<sinatra>, [">= 0.3.2"])
|
42
41
|
s.add_dependency(%q<haml>, [">= 0"])
|
@@ -51,6 +50,7 @@ Gem::Specification.new do |s|
|
|
51
50
|
s.add_dependency(%q<foca-sinatra-diddies>, [">= 0.0.2"])
|
52
51
|
s.add_dependency(%q<rspec_hpricot_matchers>, [">= 0"])
|
53
52
|
s.add_dependency(%q<thor>, [">= 0"])
|
53
|
+
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
|
54
54
|
end
|
55
55
|
else
|
56
56
|
s.add_dependency(%q<sinatra>, [">= 0.3.2"])
|
@@ -66,5 +66,6 @@ Gem::Specification.new do |s|
|
|
66
66
|
s.add_dependency(%q<foca-sinatra-diddies>, [">= 0.0.2"])
|
67
67
|
s.add_dependency(%q<rspec_hpricot_matchers>, [">= 0"])
|
68
68
|
s.add_dependency(%q<thor>, [">= 0"])
|
69
|
+
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
|
69
70
|
end
|
70
71
|
end
|
data/lib/integrity.rb
CHANGED
@@ -13,9 +13,9 @@ require 'yaml'
|
|
13
13
|
require 'logger'
|
14
14
|
require 'digest/sha1'
|
15
15
|
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
16
|
+
require 'core_ext/object'
|
17
|
+
require 'core_ext/string'
|
18
|
+
require 'core_ext/time'
|
19
19
|
|
20
20
|
require 'project'
|
21
21
|
require 'build'
|
@@ -35,11 +35,12 @@ module Integrity
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.default_configuration
|
38
|
-
@defaults ||= { :database_uri
|
39
|
-
:export_directory
|
40
|
-
:log
|
41
|
-
:base_uri
|
42
|
-
:use_basic_auth
|
38
|
+
@defaults ||= { :database_uri => 'sqlite3::memory:',
|
39
|
+
:export_directory => root / 'exports',
|
40
|
+
:log => STDOUT,
|
41
|
+
:base_uri => 'http://localhost:8910',
|
42
|
+
:use_basic_auth => false,
|
43
|
+
:build_all_commits => true}
|
43
44
|
end
|
44
45
|
|
45
46
|
def self.config
|
@@ -49,12 +50,22 @@ module Integrity
|
|
49
50
|
def self.config=(file)
|
50
51
|
@config = default_configuration.merge(YAML.load_file(file))
|
51
52
|
end
|
52
|
-
|
53
|
-
def self.
|
54
|
-
|
53
|
+
|
54
|
+
def self.log(message, &block)
|
55
|
+
logger.info(message, &block)
|
55
56
|
end
|
56
57
|
|
57
|
-
def self.logger
|
58
|
-
@logger
|
58
|
+
def self.logger
|
59
|
+
@logger ||= Logger.new(config[:log], "daily").tap do |logger|
|
60
|
+
logger.formatter = LogFormatter.new
|
61
|
+
end
|
59
62
|
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
class LogFormatter < Logger::Formatter
|
67
|
+
def call(severity, time, progname, msg)
|
68
|
+
time.strftime("[%H:%M:%S] ") + msg2str(msg) + "\n"
|
69
|
+
end
|
70
|
+
end
|
60
71
|
end
|
data/lib/integrity/builder.rb
CHANGED
@@ -13,7 +13,7 @@ module Integrity
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def build(commit)
|
16
|
-
Integrity.
|
16
|
+
Integrity.log "Building #{commit} (#{@branch}) of #{@build.project.name} in #{export_directory} using #{scm_name}"
|
17
17
|
@scm.with_revision(commit) { run_build_script }
|
18
18
|
@build
|
19
19
|
ensure
|
@@ -38,7 +38,7 @@ module Integrity
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def run_build_script
|
41
|
-
Integrity.
|
41
|
+
Integrity.log "Running `#{build_script}` in #{@scm.working_directory}"
|
42
42
|
|
43
43
|
IO.popen "(cd #{@scm.working_directory} && #{build_script}) 2>&1", "r" do |pipe|
|
44
44
|
@build.output = pipe.read
|
data/lib/integrity/notifier.rb
CHANGED
@@ -12,16 +12,15 @@ module Integrity
|
|
12
12
|
validates_present :project_id
|
13
13
|
|
14
14
|
def self.available
|
15
|
-
@available ||= constants.map {|name| const_get(name) }.select
|
16
|
-
notifier.respond_to?(:to_haml) && notifier.respond_to?(:notify_of_build)
|
17
|
-
end - [Notifier::Base]
|
15
|
+
@available ||= constants.map { |name| const_get(name) }.select { |notifier| valid_notifier?(notifier) }
|
18
16
|
end
|
19
17
|
|
20
18
|
def self.enable_notifiers(project, enabled, config={})
|
21
|
-
all.destroy!
|
19
|
+
all(:project_id => project).destroy!
|
22
20
|
list_of_enabled_notifiers(enabled).each do |name|
|
23
21
|
create! :project_id => project, :name => name, :config => config[name]
|
24
22
|
end
|
23
|
+
|
25
24
|
end
|
26
25
|
|
27
26
|
def notify_of_build(build)
|
@@ -35,12 +34,14 @@ module Integrity
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def self.list_of_enabled_notifiers(names)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
[*names].reject { |n| n.nil? }
|
38
|
+
end
|
39
|
+
private_class_method :list_of_enabled_notifiers
|
40
|
+
|
41
|
+
def self.valid_notifier?(notifier)
|
42
|
+
notifier.respond_to?(:to_haml) && notifier.respond_to?(:notify_of_build) && notifier != Notifier::Base
|
43
43
|
end
|
44
|
+
private_class_method :valid_notifier?
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
data/lib/integrity/project.rb
CHANGED
@@ -78,9 +78,10 @@ module Integrity
|
|
78
78
|
def send_notifications
|
79
79
|
notifiers.each do |notifier|
|
80
80
|
begin
|
81
|
+
Integrity.log "Notifying of build #{last_build.short_commit_identifier} using the #{notifier.name} notifier"
|
81
82
|
notifier.notify_of_build last_build
|
82
83
|
rescue Timeout::Error
|
83
|
-
Integrity.
|
84
|
+
Integrity.log "#{notifier.name} notifier timed out"
|
84
85
|
next
|
85
86
|
end
|
86
87
|
end
|
data/lib/integrity/scm/git.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../lib/integrity'
|
2
2
|
require 'spec'
|
3
3
|
|
4
|
+
module LoggingSpecHelper
|
5
|
+
def self.included(mod)
|
6
|
+
mod.before(:each) { Integrity.stub!(:log) }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
module NotifierSpecHelper
|
5
11
|
def self.included(mod)
|
6
12
|
mod.before(:each) { Integrity.stub!(:config).and_return(:base_uri => "http://localhost:4567") }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foca-integrity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Nicol\xC3\xA1s Sanguinetti"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-
|
13
|
+
date: 2008-12-08 00:00:00 -08:00
|
14
14
|
default_executable: integrity
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -130,6 +130,15 @@ dependencies:
|
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: "0"
|
132
132
|
version:
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: bcrypt-ruby
|
135
|
+
version_requirement:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: "0"
|
141
|
+
version:
|
133
142
|
description: Your Friendly Continuous Integration server. Easy, fun and painless!
|
134
143
|
email: contacto@nicolassanguinetti.info
|
135
144
|
executables:
|