bantic-integrity 0.1.4
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.
- data/README.markdown +153 -0
- data/Rakefile +82 -0
- data/VERSION.yml +4 -0
- data/app.rb +278 -0
- data/bin/integrity +82 -0
- data/config/config.sample.ru +30 -0
- data/config/config.sample.yml +34 -0
- data/config/thin.sample.yml +13 -0
- data/integrity.gemspec +72 -0
- data/lib/integrity/build.rb +56 -0
- data/lib/integrity/builder.rb +49 -0
- data/lib/integrity/core_ext/object.rb +6 -0
- data/lib/integrity/core_ext/string.rb +5 -0
- data/lib/integrity/core_ext/time.rb +13 -0
- data/lib/integrity/notifier/base.rb +55 -0
- data/lib/integrity/notifier.rb +50 -0
- data/lib/integrity/project.rb +94 -0
- data/lib/integrity/scm/git/uri.rb +57 -0
- data/lib/integrity/scm/git.rb +83 -0
- data/lib/integrity/scm.rb +22 -0
- data/lib/integrity.rb +71 -0
- data/public/buttons.css +82 -0
- data/public/reset.css +7 -0
- data/public/spinner.gif +0 -0
- data/spec/form_field_matchers.rb +91 -0
- data/spec/spec_helper.rb +135 -0
- data/vendor/sinatra-hacks/lib/hacks.rb +49 -0
- data/views/build.haml +2 -0
- data/views/build_info.haml +22 -0
- data/views/error.haml +29 -0
- data/views/home.haml +22 -0
- data/views/integrity.sass +387 -0
- data/views/layout.haml +25 -0
- data/views/new.haml +53 -0
- data/views/not_found.haml +31 -0
- data/views/notifier.haml +7 -0
- data/views/project.haml +32 -0
- data/views/unauthorized.haml +38 -0
- metadata +216 -0
data/public/buttons.css
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
/* --------------------------------------------------------------
|
2
|
+
|
3
|
+
buttons.css
|
4
|
+
* Gives you some great CSS-only buttons.
|
5
|
+
|
6
|
+
Created by Kevin Hale [particletree.com]
|
7
|
+
* particletree.com/features/rediscovering-the-button-element
|
8
|
+
|
9
|
+
See Readme.txt in this folder for instructions.
|
10
|
+
|
11
|
+
-------------------------------------------------------------- */
|
12
|
+
|
13
|
+
button {
|
14
|
+
display:block;
|
15
|
+
float:left;
|
16
|
+
margin:0 0.583em 0.667em 0;
|
17
|
+
padding:5px 10px 5px 7px; /* Links */
|
18
|
+
|
19
|
+
border:1px solid #dedede;
|
20
|
+
border-top:1px solid #eee;
|
21
|
+
border-left:1px solid #eee;
|
22
|
+
|
23
|
+
background-color:#f5f5f5;
|
24
|
+
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
|
25
|
+
font-size:100%;
|
26
|
+
line-height:130%;
|
27
|
+
text-decoration:none;
|
28
|
+
font-weight:bold;
|
29
|
+
color:#565656;
|
30
|
+
cursor:pointer;
|
31
|
+
}
|
32
|
+
button {
|
33
|
+
width:auto;
|
34
|
+
overflow:visible;
|
35
|
+
padding:4px 10px 3px 7px; /* IE6 */
|
36
|
+
}
|
37
|
+
button[type] {
|
38
|
+
padding:4px 10px 4px 7px; /* Firefox */
|
39
|
+
line-height:17px; /* Safari */
|
40
|
+
}
|
41
|
+
*:first-child+html button[type] {
|
42
|
+
padding:4px 10px 3px 7px; /* IE7 */
|
43
|
+
}
|
44
|
+
button img {
|
45
|
+
margin:0 3px -3px 0 !important;
|
46
|
+
padding:0;
|
47
|
+
border:none;
|
48
|
+
width:16px;
|
49
|
+
height:16px;
|
50
|
+
float:none;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
/* Button colors
|
55
|
+
-------------------------------------------------------------- */
|
56
|
+
|
57
|
+
/* Standard */
|
58
|
+
button:hover {
|
59
|
+
background-color:#dff4ff;
|
60
|
+
border:1px solid #c2e1ef;
|
61
|
+
color:#336699;
|
62
|
+
}
|
63
|
+
|
64
|
+
/* Positive */
|
65
|
+
body .positive {
|
66
|
+
color:#529214;
|
67
|
+
}
|
68
|
+
button.positive:hover {
|
69
|
+
background-color:#E6EFC2;
|
70
|
+
border:1px solid #C6D880;
|
71
|
+
color:#529214;
|
72
|
+
}
|
73
|
+
|
74
|
+
/* Negative */
|
75
|
+
body .negative {
|
76
|
+
color:#d12f19;
|
77
|
+
}
|
78
|
+
button.negative:hover {
|
79
|
+
background:#fbe3e4;
|
80
|
+
border:1px solid #fbc2c4;
|
81
|
+
color:#d12f19;
|
82
|
+
}
|
data/public/reset.css
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
3
|
+
Code licensed under the BSD License:
|
4
|
+
http://developer.yahoo.net/yui/license.txt
|
5
|
+
version: 2.5.2
|
6
|
+
*/
|
7
|
+
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;font-variant:normal;}sup {vertical-align:text-top;}sub {vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
|
data/public/spinner.gif
ADDED
Binary file
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module FormFieldHpricotMatchers
|
2
|
+
# TODO: Add support for selects
|
3
|
+
class HaveField
|
4
|
+
include RspecHpricotMatchers
|
5
|
+
|
6
|
+
def initialize(id, type, tagname)
|
7
|
+
@tagname = tagname
|
8
|
+
@type = type
|
9
|
+
@id = id
|
10
|
+
@tag_matcher = have_tag("#{@tagname}##{@id}", @tagname == "textarea" ? @value : nil)
|
11
|
+
@label_set = true # always check for a label, unless explicitly told not to
|
12
|
+
end
|
13
|
+
|
14
|
+
def named(name)
|
15
|
+
@name_set = true
|
16
|
+
@name = name
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def with_label(label)
|
21
|
+
@label = label
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def without_label
|
26
|
+
@label_set = false
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def with_value(value)
|
31
|
+
@value_set = true
|
32
|
+
@value = value
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def checked
|
37
|
+
@checked = "checked"
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def unchecked
|
42
|
+
@checked = ""
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def matches?(actual)
|
47
|
+
(@label_set ? have_tag("label[@for=#{@id}]", @label).matches?(actual) : true) &&
|
48
|
+
@tag_matcher.matches?(actual) do |field|
|
49
|
+
field["type"].should == @type if @type
|
50
|
+
field["name"].should == @name if @name_set
|
51
|
+
field["value"].should == @value if @value_set && @tagname == "input"
|
52
|
+
field["checked"].should == @checked if @checked
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def failure_message
|
57
|
+
attrs = [
|
58
|
+
"id ##{@id}",
|
59
|
+
@name && "name '#{@name}'",
|
60
|
+
@type && "type '#{@type}'",
|
61
|
+
@label && "labelled '#{@label}'",
|
62
|
+
@value && "value '#{@value}'"
|
63
|
+
].compact.join(", ")
|
64
|
+
"You expected a #{@tagname}#{@type ? " (#{@type})" : ""} with #{attrs} but found none.\n\n#{@tag_matcher.failure_message}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def have_field(id, type="text", tagname="input")
|
69
|
+
HaveField.new(id, type, tagname)
|
70
|
+
end
|
71
|
+
|
72
|
+
def have_textfield(id)
|
73
|
+
have_field(id)
|
74
|
+
end
|
75
|
+
|
76
|
+
def have_password(id)
|
77
|
+
have_field(id, "password")
|
78
|
+
end
|
79
|
+
|
80
|
+
def have_checkbox(id)
|
81
|
+
have_field(id, "checkbox")
|
82
|
+
end
|
83
|
+
|
84
|
+
def have_radio(id)
|
85
|
+
have_field(id, "radio")
|
86
|
+
end
|
87
|
+
|
88
|
+
def have_textarea(id)
|
89
|
+
have_field(id, nil, "textarea")
|
90
|
+
end
|
91
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/integrity'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
module LoggingSpecHelper
|
5
|
+
def self.included(mod)
|
6
|
+
mod.before(:each) { Integrity.stub!(:log) }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module NotifierSpecHelper
|
11
|
+
def self.included(mod)
|
12
|
+
mod.before(:each) { Integrity.stub!(:config).and_return(:base_uri => "http://localhost:4567") }
|
13
|
+
end
|
14
|
+
|
15
|
+
class Integrity::Notifier::Stub < Integrity::Notifier::Base
|
16
|
+
def self.to_haml
|
17
|
+
""
|
18
|
+
end
|
19
|
+
|
20
|
+
def deliver!
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def mock_build(messages={})
|
26
|
+
messages = {
|
27
|
+
:project => stub("project", :name => "Integrity", :permalink => "integrity"),
|
28
|
+
:commit_identifier => "e7e02bc669d07064cdbc7e7508a21a41e040e70d",
|
29
|
+
:short_commit_identifier => "e7e02b",
|
30
|
+
:status => :success,
|
31
|
+
:successful? => true,
|
32
|
+
:commit_message => "the commit message",
|
33
|
+
:commit_author => stub("author", :name => "Nicolás Sanguinetti"),
|
34
|
+
:commited_at => Time.mktime(2008, 07, 25, 18, 44),
|
35
|
+
:output => "the output \e[31mwith color coding\e[0m"
|
36
|
+
}.merge(messages)
|
37
|
+
@build ||= stub("build", messages)
|
38
|
+
end
|
39
|
+
|
40
|
+
def notifier_config(overrides={})
|
41
|
+
@config ||= overrides
|
42
|
+
end
|
43
|
+
|
44
|
+
def notifier
|
45
|
+
@notifier ||= stub("notifier", :method_missing => nil)
|
46
|
+
end
|
47
|
+
|
48
|
+
def the_form(locals = {})
|
49
|
+
locals = { :config => {} }.merge(locals)
|
50
|
+
require 'haml'
|
51
|
+
@form ||= Haml::Engine.new(klass.to_haml).render(self, locals)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "A notifier", :shared => true do
|
56
|
+
it "should have a `notify_of_build' class method" do
|
57
|
+
klass.should respond_to(:notify_of_build)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have a `to_haml' class method" do
|
61
|
+
klass.should respond_to(:to_haml)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module DatabaseSpecHelper
|
66
|
+
def self.included(mod)
|
67
|
+
mod.before(:each) { setup_database! }
|
68
|
+
end
|
69
|
+
|
70
|
+
def setup_database!
|
71
|
+
DataMapper.setup(:default, 'sqlite3::memory:')
|
72
|
+
DataMapper.auto_migrate!
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
module AppSpecHelper
|
77
|
+
def self.included(mod)
|
78
|
+
require 'rspec_hpricot_matchers'
|
79
|
+
require Integrity.root / 'spec/form_field_matchers'
|
80
|
+
|
81
|
+
mod.send(:include, DatabaseSpecHelper)
|
82
|
+
mod.send(:include, RspecHpricotMatchers)
|
83
|
+
mod.send(:include, FormFieldHpricotMatchers)
|
84
|
+
end
|
85
|
+
|
86
|
+
def mock_project(messages={})
|
87
|
+
messages = {
|
88
|
+
:name => "Integrity",
|
89
|
+
:permalink => "integrity",
|
90
|
+
:new_record? => false,
|
91
|
+
:uri => "git://github.com/foca/integrity.git",
|
92
|
+
:branch => "master",
|
93
|
+
:command => "rake",
|
94
|
+
:public? => true,
|
95
|
+
:builds => [],
|
96
|
+
:config_for => {},
|
97
|
+
:build => nil,
|
98
|
+
:update_attributes => true,
|
99
|
+
:save => true,
|
100
|
+
:destroy => nil,
|
101
|
+
:errors => stub("errors", :on => nil),
|
102
|
+
:notifies? => false,
|
103
|
+
:enable_notifiers => nil
|
104
|
+
}.merge(messages)
|
105
|
+
|
106
|
+
@project ||= stub("project", messages)
|
107
|
+
end
|
108
|
+
|
109
|
+
def mock_build(messages={})
|
110
|
+
messages = {
|
111
|
+
:status => :success,
|
112
|
+
:successful? => true,
|
113
|
+
:output => 'output',
|
114
|
+
:project => @project,
|
115
|
+
:commit_identifier => '9f6302002d2259c05a64767e0dedb15d280a4848',
|
116
|
+
:commit_author => mock("author",
|
117
|
+
:name => 'Nicolás Sanguinetti',
|
118
|
+
:email => 'contacto@nicolassanguinetti.info',
|
119
|
+
:full =>'Nicolás Sanguinetti <contacto@nicolassanguinetti.info>'
|
120
|
+
),
|
121
|
+
:commited_at => Time.mktime(2008, 7, 24, 17, 15),
|
122
|
+
:commit_message => "Add Object#tap for versions of ruby that don't have it"
|
123
|
+
}.merge(messages)
|
124
|
+
messages[:short_commit_identifier] = messages[:commit_identifier][0..5]
|
125
|
+
mock('build', messages)
|
126
|
+
end
|
127
|
+
|
128
|
+
def disable_basic_auth!
|
129
|
+
Integrity.stub!(:config).and_return(:use_basic_auth => false)
|
130
|
+
end
|
131
|
+
|
132
|
+
def enable_basic_auth!
|
133
|
+
Integrity.stub!(:config).and_return(:use_basic_auth => true, :admin_username => 'user', :admin_password => 'pass')
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Sinatra
|
2
|
+
class EventContext
|
3
|
+
def params
|
4
|
+
@params ||= ParamsParser.new(@route_params.merge(@request.params)).to_hash
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
class ParamsParser
|
10
|
+
attr_reader :hash
|
11
|
+
|
12
|
+
def initialize(hash)
|
13
|
+
@hash = nested(hash)
|
14
|
+
end
|
15
|
+
|
16
|
+
alias :to_hash :hash
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def nested(hash)
|
21
|
+
hash.inject(indifferent_hash) do |par, (key,val)|
|
22
|
+
if key =~ /([^\[]+)\[([^\]]+)\](.*)/ # a[b] || a[b][c] ($1 == a, $2 == b, $3 == [c])
|
23
|
+
par[$1] ||= indifferent_hash
|
24
|
+
par[$1].merge_recursive nested("#{$2}#{$3}" => val)
|
25
|
+
else
|
26
|
+
par[key] = val
|
27
|
+
end
|
28
|
+
par
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def indifferent_hash
|
33
|
+
Hash.new {|h,k| h[k.to_s] if Symbol === k}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Hash
|
40
|
+
def merge_recursive(other)
|
41
|
+
update(other) do |key, old_value, new_value|
|
42
|
+
if Hash === old_value && Hash === new_value
|
43
|
+
old_value.merge_recursive(new_value)
|
44
|
+
else
|
45
|
+
new_value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/views/build.haml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
%h1
|
2
|
+
Built
|
3
|
+
&= @build.short_commit_identifier
|
4
|
+
= @build.successful? ? "successfully" : "and failed"
|
5
|
+
%blockquote
|
6
|
+
%p&= @build.commit_message
|
7
|
+
%p.meta<
|
8
|
+
%span.who<
|
9
|
+
by:
|
10
|
+
&= @build.commit_author.name
|
11
|
+
|
|
12
|
+
%span.when{ :title => @build.commited_at.iso8601 }<
|
13
|
+
&= pretty_date @build.commited_at
|
14
|
+
|
|
15
|
+
%span.what<
|
16
|
+
commit:
|
17
|
+
&= @build.commit_identifier
|
18
|
+
|
19
|
+
%h2 Build Output:
|
20
|
+
%pre.output
|
21
|
+
:preserve
|
22
|
+
#{bash_color_codes h(@build.output)}
|
data/views/error.haml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
.error
|
2
|
+
%h1
|
3
|
+
Whatever you do, DON'T PANIC!
|
4
|
+
|
5
|
+
%dl
|
6
|
+
%dt This is what happened:
|
7
|
+
%dd
|
8
|
+
%strong&= @error.message
|
9
|
+
%pre.backtrace= @error.backtrace.join("\n")
|
10
|
+
|
11
|
+
%dt What can I do?
|
12
|
+
%dd
|
13
|
+
Is your
|
14
|
+
%a{ :href => "http://integrityapp.com/configure" } config
|
15
|
+
ok? If not, try restarting integrity. If you think everything is fine,
|
16
|
+
then drop by our irc channel:
|
17
|
+
%a{ :href => "irc://irc.freenode.org:6667/integrity" } #integrity
|
18
|
+
on freenode, and we'll try to help.
|
19
|
+
|
20
|
+
%dt
|
21
|
+
What the hell is
|
22
|
+
= succeed "?" do
|
23
|
+
%strong Integrity
|
24
|
+
%dd
|
25
|
+
Integrity is your friendly
|
26
|
+
%a{ :href => "http://en.wikipedia.org/wiki/Continuous_integration" } Continuous Integration
|
27
|
+
server. If you want to know more about us, check our website at
|
28
|
+
= succeed "." do
|
29
|
+
%a{ :href => "http://integrityapp.com" } integrityapp.com
|
data/views/home.haml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
- if @projects.empty?
|
2
|
+
.blank_slate
|
3
|
+
%p None yet, huh?
|
4
|
+
%h1
|
5
|
+
Why don't you
|
6
|
+
= succeed "?" do
|
7
|
+
%a{ :href => "/new" } create your first project
|
8
|
+
- else
|
9
|
+
%ul#projects
|
10
|
+
- @projects.each do |project|
|
11
|
+
%li{ :class => cycle("even", "odd") + (project.building? ? ' building' : '') + (project.last_build ? (project.last_build.successful? ? ' success' : ' failed') : '') }
|
12
|
+
%a{ :href => project_url(project) }&= project.name
|
13
|
+
.meta
|
14
|
+
- if project.building?
|
15
|
+
= "Building for #{pretty_time_since(project.started_build_at)}"
|
16
|
+
- elsif project.last_build.nil?
|
17
|
+
Never built yet
|
18
|
+
- else
|
19
|
+
= "Built #{project.last_build.short_commit_identifier}"
|
20
|
+
= project.last_build.successful? ? "successfully" : "and failed"
|
21
|
+
%p#new
|
22
|
+
%a{ :href => "/new" } Add a new project
|