alphasights-integrity 0.1.9.8 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/AUTHORS +35 -0
- data/CHANGES +21 -3
- data/LICENSE +20 -0
- data/README.md +10 -52
- data/config/config.sample.yml +4 -0
- data/config/heroku/.gems +1 -1
- data/config/heroku/integrity-config.rb +1 -0
- data/integrity.gemspec +6 -11
- data/lib/integrity.rb +4 -4
- data/lib/integrity/app.rb +1 -1
- data/lib/integrity/build.rb +8 -18
- data/lib/integrity/commit.rb +13 -8
- data/lib/integrity/helpers/pretty_output.rb +8 -0
- data/lib/integrity/helpers/urls.rb +3 -3
- data/lib/integrity/installer.rb +20 -11
- data/lib/integrity/migrations.rb +43 -13
- data/lib/integrity/notifier.rb +1 -1
- data/lib/integrity/notifier/base.rb +2 -2
- data/lib/integrity/notifier/test/fixtures.rb +12 -6
- data/lib/integrity/project.rb +34 -38
- data/lib/integrity/project/push.rb +4 -5
- data/test/acceptance/api_test.rb +1 -1
- data/test/acceptance/browse_project_test.rb +12 -6
- data/test/acceptance/build_notifications_test.rb +26 -2
- data/test/acceptance/installer_test.rb +1 -1
- data/test/acceptance/manual_build_project_test.rb +2 -2
- data/test/acceptance/notifier_test_test.rb +37 -0
- data/test/acceptance/stylesheet_test.rb +2 -1
- data/test/helpers.rb +3 -2
- data/test/unit/build_test.rb +11 -46
- data/test/unit/commit_test.rb +37 -28
- data/test/unit/helpers_test.rb +16 -0
- data/test/unit/migrations_test.rb +6 -4
- data/test/unit/project_test.rb +64 -95
- data/views/_commit_info.haml +6 -10
- data/views/home.haml +3 -2
- data/views/integrity.sass +24 -4
- data/views/project.haml +5 -4
- metadata +6 -20
- data/lib/integrity/helpers/gravatar.rb +0 -16
- data/lib/integrity/project_builder.rb +0 -56
- data/lib/integrity/scm.rb +0 -19
- data/lib/integrity/scm/git.rb +0 -84
- data/lib/integrity/scm/git/uri.rb +0 -57
- data/test/unit/project_builder_test.rb +0 -118
- data/test/unit/scm_test.rb +0 -54
data/views/_commit_info.haml
CHANGED
@@ -12,18 +12,14 @@
|
|
12
12
|
%p.meta<
|
13
13
|
%span.who<
|
14
14
|
%strong&= commit.author.name
|
15
|
-
|
16
|
-
|
15
|
+
- if commit.build
|
16
|
+
%span.when{ :title => commit.committed_at }<
|
17
|
+
= pretty_date_time(commit.build.updated_at)
|
17
18
|
%br
|
18
19
|
%span.what<
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
&= commit.url
|
23
|
-
- else
|
24
|
-
%span{ :title => commit.identifier }<
|
25
|
-
&= commit.short_identifier
|
26
|
-
|
20
|
+
commit:
|
21
|
+
%a{ :href => commit.uri }>
|
22
|
+
&== #{commit.identifier}
|
27
23
|
%h2 Build Output:
|
28
24
|
%pre.output
|
29
25
|
:preserve
|
data/views/home.haml
CHANGED
@@ -11,9 +11,10 @@
|
|
11
11
|
%li{ :class => cycle("even", "odd") + ' ' + project.status.to_s }
|
12
12
|
%a{ :href => project_path(project) }&= project.name
|
13
13
|
.meta
|
14
|
-
-
|
14
|
+
- case project.status
|
15
|
+
- when :building
|
15
16
|
Building!
|
16
|
-
-
|
17
|
+
- when :blank
|
17
18
|
Never built yet
|
18
19
|
- else
|
19
20
|
%img.floating_gravatar{ gravatar_attrs(project.last_commit.author, 20) }
|
data/views/integrity.sass
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
!success_color = #337022
|
18
18
|
!failed_bg = #fba
|
19
19
|
!failed_color = #f10
|
20
|
+
!building_bg = #ccc
|
21
|
+
!building_color = #777
|
20
22
|
|
21
23
|
html
|
22
24
|
:background-color = !page_bg
|
@@ -241,8 +243,6 @@ a
|
|
241
243
|
:border-bottom = 1px "solid" !rule_color
|
242
244
|
&.odd
|
243
245
|
:background = !content_bg - #080808
|
244
|
-
&.building
|
245
|
-
:background transparent url(/spinner.gif) no-repeat scroll right
|
246
246
|
a
|
247
247
|
:font-size 2em
|
248
248
|
:padding .25em
|
@@ -253,6 +253,8 @@ a
|
|
253
253
|
:color = !success_color
|
254
254
|
&.failed
|
255
255
|
:color = !failed_color
|
256
|
+
&.building
|
257
|
+
:color = !building_color
|
256
258
|
.meta
|
257
259
|
:position absolute
|
258
260
|
:right .6em
|
@@ -261,12 +263,12 @@ a
|
|
261
263
|
:font-size 0.8em
|
262
264
|
:color = !light_color
|
263
265
|
:text-align right
|
264
|
-
&.building .meta
|
265
|
-
:right 1.6em
|
266
266
|
&.success .meta
|
267
267
|
:color = !success_color
|
268
268
|
&.failed .meta
|
269
269
|
:color = !failed_color
|
270
|
+
&.building .meta
|
271
|
+
:color = !building_color
|
270
272
|
|
271
273
|
|
272
274
|
#previous_builds
|
@@ -301,6 +303,14 @@ a
|
|
301
303
|
:color = !failed_bg - #444
|
302
304
|
&:hover
|
303
305
|
:background-color = !failed_bg + #222
|
306
|
+
&.building a
|
307
|
+
:background-color = !building_bg
|
308
|
+
:border-color = !building_bg - #222
|
309
|
+
:color = !building_color
|
310
|
+
.attribution
|
311
|
+
:color = !building_bg - #444
|
312
|
+
&:hover
|
313
|
+
:background-color = !building_bg + #222
|
304
314
|
|
305
315
|
|
306
316
|
#build, #last_build
|
@@ -345,6 +355,16 @@ a
|
|
345
355
|
:background-color = !failed_bg - #555
|
346
356
|
:color #fff
|
347
357
|
|
358
|
+
&.building
|
359
|
+
h1, blockquote
|
360
|
+
:background-color = !building_bg
|
361
|
+
:border-color = (!building_bg - #222) (!building_bg + #111) (!building_bg + #111) (!building_bg - #222)
|
362
|
+
h1
|
363
|
+
:color = !building_color
|
364
|
+
:background transparent url(/spinner.gif) no-repeat scroll right
|
365
|
+
.meta
|
366
|
+
:color = !building_color - #444
|
367
|
+
|
348
368
|
h1
|
349
369
|
:margin-top .5em
|
350
370
|
:margin-bottom 0
|
data/views/project.haml
CHANGED
@@ -14,9 +14,8 @@
|
|
14
14
|
|
15
15
|
%form{ :action => project_path(@project, :builds), :method => :post }
|
16
16
|
%p.submit.manual-build
|
17
|
-
%button{ :type => :submit, :title => "Fetch the last commit and build it" }<
|
18
|
-
|
19
|
-
in the repository (or rebuild the latest)
|
17
|
+
%button{ :type => :submit, :title => "Fetch the last commit from the remote repository and build it" }<
|
18
|
+
Fetch and build
|
20
19
|
|
21
20
|
- unless @project.previous_commits.empty?
|
22
21
|
%h2 Previous builds
|
@@ -28,4 +27,6 @@
|
|
28
27
|
%strong.build<
|
29
28
|
&== Build #{commit.short_identifier}
|
30
29
|
%span.attribution<
|
31
|
-
== by #{commit.author.name}
|
30
|
+
== by #{commit.author.name}
|
31
|
+
-if commit.build
|
32
|
+
= pretty_date_time commit.build.updated_at
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alphasights-integrity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
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: 2009-
|
13
|
+
date: 2009-05-14 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version_requirement:
|
20
20
|
version_requirements: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- - "
|
22
|
+
- - "="
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: 0.9.1.1
|
25
25
|
version:
|
@@ -103,16 +103,6 @@ dependencies:
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: "0"
|
105
105
|
version:
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
|
-
name: mocha
|
108
|
-
type: :development
|
109
|
-
version_requirement:
|
110
|
-
version_requirements: !ruby/object:Gem::Requirement
|
111
|
-
requirements:
|
112
|
-
- - ">="
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
version: "0"
|
115
|
-
version:
|
116
106
|
- !ruby/object:Gem::Dependency
|
117
107
|
name: webrat
|
118
108
|
type: :development
|
@@ -203,7 +193,9 @@ extra_rdoc_files: []
|
|
203
193
|
|
204
194
|
files:
|
205
195
|
- .gitignore
|
196
|
+
- AUTHORS
|
206
197
|
- CHANGES
|
198
|
+
- LICENSE
|
207
199
|
- README.md
|
208
200
|
- Rakefile
|
209
201
|
- bin/integrity
|
@@ -228,7 +220,6 @@ files:
|
|
228
220
|
- lib/integrity/helpers/rendering.rb
|
229
221
|
- lib/integrity/helpers/resources.rb
|
230
222
|
- lib/integrity/helpers/urls.rb
|
231
|
-
- lib/integrity/helpers/gravatar.rb
|
232
223
|
- lib/integrity/installer.rb
|
233
224
|
- lib/integrity/migrations.rb
|
234
225
|
- lib/integrity/notifier.rb
|
@@ -239,10 +230,6 @@ files:
|
|
239
230
|
- lib/integrity/project.rb
|
240
231
|
- lib/integrity/project/notifiers.rb
|
241
232
|
- lib/integrity/project/push.rb
|
242
|
-
- lib/integrity/project_builder.rb
|
243
|
-
- lib/integrity/scm.rb
|
244
|
-
- lib/integrity/scm/git.rb
|
245
|
-
- lib/integrity/scm/git/uri.rb
|
246
233
|
- public/buttons.css
|
247
234
|
- public/reset.css
|
248
235
|
- public/spinner.gif
|
@@ -257,6 +244,7 @@ files:
|
|
257
244
|
- test/acceptance/installer_test.rb
|
258
245
|
- test/acceptance/manual_build_project_test.rb
|
259
246
|
- test/acceptance/not_found_page_test.rb
|
247
|
+
- test/acceptance/notifier_test_test.rb
|
260
248
|
- test/acceptance/project_syndication_test.rb
|
261
249
|
- test/acceptance/stylesheet_test.rb
|
262
250
|
- test/acceptance/unauthorized_page_test.rb
|
@@ -279,9 +267,7 @@ files:
|
|
279
267
|
- test/unit/migrations_test.rb
|
280
268
|
- test/unit/notifier/base_test.rb
|
281
269
|
- test/unit/notifier_test.rb
|
282
|
-
- test/unit/project_builder_test.rb
|
283
270
|
- test/unit/project_test.rb
|
284
|
-
- test/unit/scm_test.rb
|
285
271
|
- views/_commit_info.haml
|
286
272
|
- views/build.haml
|
287
273
|
- views/error.haml
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Integrity
|
2
|
-
module Helpers
|
3
|
-
module Gravatar
|
4
|
-
def gravatar_attrs(author, size=40)
|
5
|
-
# size = 40 unless %w(20 30 40 50).include?(size)
|
6
|
-
if author.email.nil?
|
7
|
-
{:src => "gravatar-#{size}.png", :title => 'Unknown author'}
|
8
|
-
else
|
9
|
-
email_digest = Digest::MD5.hexdigest(author.email)
|
10
|
-
source = "http://gravatar.com/avatar/#{email_digest}?s=#{size}"
|
11
|
-
{:src => source, :title => author.name}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require "forwardable"
|
2
|
-
|
3
|
-
module Integrity
|
4
|
-
class ProjectBuilder
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
attr_accessor :project, :scm
|
8
|
-
def_delegators :project, :name, :uri, :command, :branch
|
9
|
-
|
10
|
-
def self.build(commit)
|
11
|
-
new(commit.project).build(commit)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.delete_working_directory(project)
|
15
|
-
new(project).delete_code
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(project)
|
19
|
-
@project = project
|
20
|
-
@scm = SCM.new(uri, branch, export_directory)
|
21
|
-
end
|
22
|
-
|
23
|
-
def build(commit)
|
24
|
-
build = commit.build
|
25
|
-
build.start!
|
26
|
-
|
27
|
-
Integrity.log "Building #{commit.identifier} (#{branch}) of #{name} in" +
|
28
|
-
"#{export_directory} using #{scm.name}"
|
29
|
-
|
30
|
-
scm.with_revision(commit.identifier) do
|
31
|
-
Integrity.log "Running `#{command}` in #{scm.working_directory}"
|
32
|
-
|
33
|
-
IO.popen("(cd #{scm.working_directory} && #{command}) 2>&1", "r") {
|
34
|
-
|output| build.output = output.read }
|
35
|
-
build.successful = $?.success?
|
36
|
-
end
|
37
|
-
|
38
|
-
build
|
39
|
-
ensure
|
40
|
-
build.complete!
|
41
|
-
commit.update_attributes(scm.info(commit.identifier) || {})
|
42
|
-
project.enabled_notifiers.each { |notifier| notifier.notify_of_build(build) }
|
43
|
-
end
|
44
|
-
|
45
|
-
def delete_code
|
46
|
-
FileUtils.rm_r export_directory
|
47
|
-
rescue Errno::ENOENT
|
48
|
-
nil
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
def export_directory
|
53
|
-
Integrity.config[:export_directory] / "#{SCM.working_tree_path(uri)}-#{branch}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/lib/integrity/scm.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Integrity
|
2
|
-
module SCM
|
3
|
-
class SCMUnknownError < StandardError; end
|
4
|
-
|
5
|
-
def self.new(uri, *args)
|
6
|
-
scm_class_for(uri).new(uri, *args)
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.working_tree_path(uri)
|
10
|
-
scm_class_for(uri).working_tree_path(uri)
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
def self.scm_class_for(uri)
|
15
|
-
return Git if uri.scheme == "git" || uri.path =~ /\.git\/?/
|
16
|
-
raise SCMUnknownError, "could not find any SCM based on URI '#{uri.to_s}'"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/integrity/scm/git.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
module Integrity
|
2
|
-
module SCM
|
3
|
-
class Git
|
4
|
-
require File.dirname(__FILE__) / "git/uri"
|
5
|
-
|
6
|
-
attr_reader :uri, :branch, :working_directory
|
7
|
-
|
8
|
-
def self.working_tree_path(uri)
|
9
|
-
Git::URI.new(uri).working_tree_path
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(uri, branch, working_directory=nil)
|
13
|
-
@uri = uri.to_s
|
14
|
-
@branch = branch.to_s
|
15
|
-
@working_directory = working_directory
|
16
|
-
end
|
17
|
-
|
18
|
-
def with_revision(revision)
|
19
|
-
fetch_code
|
20
|
-
checkout(revision)
|
21
|
-
yield
|
22
|
-
end
|
23
|
-
|
24
|
-
def name
|
25
|
-
self.class.name.split("::").last
|
26
|
-
end
|
27
|
-
|
28
|
-
def head
|
29
|
-
log "Getting the HEAD of '#{uri}' at '#{branch}'"
|
30
|
-
`git ls-remote --heads #{uri} #{branch} | awk '{print $1}'`.chomp
|
31
|
-
end
|
32
|
-
|
33
|
-
def info(revision)
|
34
|
-
format = %Q(---%n:author: %an <%ae>%n:message: >-%n %s%n:committed_at: %ci%n)
|
35
|
-
YAML.load(`cd #{working_directory} && git show -s --pretty=format:"#{format}" #{revision}`)
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def fetch_code
|
41
|
-
clone unless cloned?
|
42
|
-
checkout unless on_branch?
|
43
|
-
pull
|
44
|
-
end
|
45
|
-
|
46
|
-
def clone
|
47
|
-
log "Cloning #{uri} to #{working_directory}"
|
48
|
-
`git clone #{uri} #{working_directory} &>/dev/null`
|
49
|
-
end
|
50
|
-
|
51
|
-
def checkout(treeish=nil)
|
52
|
-
strategy = case
|
53
|
-
when treeish then treeish
|
54
|
-
when local_branches.include?(branch) then branch
|
55
|
-
else "origin/#{branch}"
|
56
|
-
end
|
57
|
-
|
58
|
-
log "Checking-out #{strategy}"
|
59
|
-
`cd #{working_directory} && git reset --hard #{strategy} &>/dev/null`
|
60
|
-
end
|
61
|
-
|
62
|
-
def pull
|
63
|
-
log "Pull-ing in #{working_directory}"
|
64
|
-
`cd #{working_directory} && git pull &>/dev/null`
|
65
|
-
end
|
66
|
-
|
67
|
-
def local_branches
|
68
|
-
`cd #{working_directory} && git branch`.split("\n").map {|b| b.delete("*").strip }
|
69
|
-
end
|
70
|
-
|
71
|
-
def cloned?
|
72
|
-
File.directory?(working_directory / ".git")
|
73
|
-
end
|
74
|
-
|
75
|
-
def on_branch?
|
76
|
-
File.basename(`cd #{working_directory} && git symbolic-ref HEAD &>/dev/null`).chomp == branch
|
77
|
-
end
|
78
|
-
|
79
|
-
def log(message)
|
80
|
-
Integrity.log("Git") { message }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module Integrity
|
2
|
-
module SCM
|
3
|
-
class Git
|
4
|
-
# From the git-pull man page:
|
5
|
-
#
|
6
|
-
# GIT URLS
|
7
|
-
# One of the following notations can be used to name the remote repository:
|
8
|
-
#
|
9
|
-
# rsync://host.xz/path/to/repo.git/
|
10
|
-
# http://host.xz/path/to/repo.git/
|
11
|
-
# git://host.xz/~user/path/to/repo.git/
|
12
|
-
# ssh://[user@]host.xz[:port]/path/to/repo.git/
|
13
|
-
# ssh://[user@]host.xz/path/to/repo.git/
|
14
|
-
# ssh://[user@]host.xz/~user/path/to/repo.git/
|
15
|
-
# ssh://[user@]host.xz/~/path/to/repo.git
|
16
|
-
#
|
17
|
-
# SSH is the default transport protocol over the network. You can optionally
|
18
|
-
# specify which user to log-in as, and an alternate, scp-like syntax is also
|
19
|
-
# supported
|
20
|
-
#
|
21
|
-
# Both syntaxes support username expansion, as does the native git protocol,
|
22
|
-
# but only the former supports port specification. The following three are
|
23
|
-
# identical to the last three above, respectively:
|
24
|
-
#
|
25
|
-
# [user@]host.xz:/path/to/repo.git/
|
26
|
-
# [user@]host.xz:~user/path/to/repo.git/
|
27
|
-
# [user@]host.xz:path/to/repo.git
|
28
|
-
#
|
29
|
-
class URI
|
30
|
-
def initialize(uri_string)
|
31
|
-
@uri = Addressable::URI.parse(uri_string)
|
32
|
-
end
|
33
|
-
|
34
|
-
def working_tree_path
|
35
|
-
strip_extension(path).gsub("/", "-")
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def strip_extension(string)
|
41
|
-
uri = Pathname.new(string)
|
42
|
-
if uri.extname.any?
|
43
|
-
uri = Pathname.new(string)
|
44
|
-
string.gsub(Regexp.new("#{uri.extname}\/?"), "")
|
45
|
-
else
|
46
|
-
string
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def path
|
51
|
-
path = @uri.path
|
52
|
-
path.gsub(/\~[a-zA-Z0-9]*\//, "").gsub(/^\//, "")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|