bob 0.1 → 0.4.0
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.rdoc +2 -46
- data/Rakefile +10 -18
- data/bob.gemspec +15 -14
- data/deps.rip +1 -0
- data/lib/bob.rb +13 -15
- data/lib/bob/builder.rb +25 -36
- data/lib/bob/{background_engines.rb → engine.rb} +3 -3
- data/lib/bob/engine/threaded.rb +145 -0
- data/lib/bob/scm.rb +4 -12
- data/lib/bob/scm/abstract.rb +41 -27
- data/lib/bob/scm/git.rb +18 -44
- data/lib/bob/scm/svn.rb +30 -0
- data/lib/bob/test.rb +3 -0
- data/lib/bob/test/builder_stub.rb +34 -0
- data/lib/bob/test/repo.rb +163 -0
- data/test/bob_test.rb +3 -2
- data/test/deps.rip +3 -0
- data/test/engine/threaded_test.rb +52 -0
- data/test/git_test.rb +26 -0
- data/test/helper.rb +10 -13
- data/test/mixin/scm.rb +46 -0
- data/test/svn_test.rb +31 -0
- data/test/test_test.rb +26 -0
- metadata +19 -49
- data/lib/bob/background_engines/foreground.rb +0 -6
- data/lib/core_ext/object.rb +0 -7
- data/test/helper/buildable_stub.rb +0 -55
- data/test/helper/git_helper.rb +0 -48
data/test/git_test.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class BobGitTest < Test::Unit::TestCase
|
4
|
+
include ScmTest
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@repo = GitRepo.new
|
10
|
+
@repo.create
|
11
|
+
end
|
12
|
+
|
13
|
+
def path(uri, branch="master")
|
14
|
+
SCM::Git.new(uri, branch).dir_for("commit").
|
15
|
+
sub(Bob.directory, "").to_s[1..-1]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_converts_repo_uri_into_path
|
19
|
+
assert_equal "git-github-com-integrity-bob-master/commit",
|
20
|
+
path("git://github.com/integrity/bob")
|
21
|
+
assert_equal "git-example-org-foo-repo-master/commit",
|
22
|
+
path("git@example.org:~foo/repo")
|
23
|
+
assert_equal "tmp-repo-git-master/commit", path("/tmp/repo.git")
|
24
|
+
assert_equal "tmp-repo-git-foo/commit", path("/tmp/repo.git", "foo")
|
25
|
+
end
|
26
|
+
end
|
data/test/helper.rb
CHANGED
@@ -8,25 +8,22 @@ begin
|
|
8
8
|
rescue LoadError
|
9
9
|
end
|
10
10
|
|
11
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"),
|
12
|
-
File.expand_path(File.dirname(__FILE__) + "/../test/helper"))
|
13
|
-
|
14
11
|
require "bob"
|
15
|
-
require "
|
16
|
-
require "
|
17
|
-
require "buildable_stub"
|
18
|
-
|
19
|
-
Bob.logger = Logger.new("/dev/null")
|
20
|
-
Bob.engine = Bob::BackgroundEngines::Foreground
|
21
|
-
Bob.directory = File.expand_path(File.dirname(__FILE__) + "/../tmp")
|
12
|
+
require "bob/test"
|
13
|
+
require "mixin/scm"
|
22
14
|
|
23
15
|
class Test::Unit::TestCase
|
24
16
|
include Bob
|
25
|
-
include
|
17
|
+
include Bob::Test
|
26
18
|
|
27
|
-
attr_reader :repo
|
19
|
+
attr_reader :repo
|
28
20
|
|
29
21
|
def setup
|
30
|
-
|
22
|
+
Bob.logger = Logger.new("/dev/null")
|
23
|
+
Bob.engine = Bob::Engine::Foreground
|
24
|
+
Bob.directory = Pathname(__FILE__).dirname.join("..", "tmp").expand_path
|
25
|
+
|
26
|
+
Bob.directory.rmtree if Bob.directory.directory?
|
27
|
+
Bob.directory.mkdir
|
31
28
|
end
|
32
29
|
end
|
data/test/mixin/scm.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module ScmTest
|
2
|
+
include Bob::Test
|
3
|
+
|
4
|
+
def test_successful_build
|
5
|
+
repo.add_successful_commit
|
6
|
+
|
7
|
+
commit_id = repo.commits.last["identifier"]
|
8
|
+
|
9
|
+
buildable = BuilderStub.for(@repo, commit_id)
|
10
|
+
buildable.build
|
11
|
+
|
12
|
+
assert_equal :successful, buildable.status
|
13
|
+
assert_equal "Running tests...\n", buildable.output
|
14
|
+
assert_equal "This commit will work", buildable.commit_info["message"]
|
15
|
+
assert_equal commit_id, buildable.commit_info["identifier"]
|
16
|
+
assert buildable.commit_info["committed_at"].is_a?(Time)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_failed_build
|
20
|
+
repo.add_failing_commit
|
21
|
+
|
22
|
+
commit_id = repo.commits.last["identifier"]
|
23
|
+
buildable = BuilderStub.for(@repo, commit_id)
|
24
|
+
|
25
|
+
buildable.build
|
26
|
+
|
27
|
+
assert_equal :failed, buildable.status
|
28
|
+
assert_equal "Running tests...\n", buildable.output
|
29
|
+
assert_equal "This commit will fail", buildable.commit_info["message"]
|
30
|
+
assert_equal commit_id, buildable.commit_info["identifier"]
|
31
|
+
assert buildable.commit_info["committed_at"].is_a?(Time)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_head
|
35
|
+
repo.add_failing_commit
|
36
|
+
repo.add_successful_commit
|
37
|
+
|
38
|
+
buildable = BuilderStub.for(@repo, :head)
|
39
|
+
|
40
|
+
buildable.build
|
41
|
+
|
42
|
+
assert_equal :successful, buildable.status
|
43
|
+
assert_equal "Running tests...\n", buildable.output
|
44
|
+
assert_equal repo.head, buildable.commit_info["identifier"]
|
45
|
+
end
|
46
|
+
end
|
data/test/svn_test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class BobSvnTest < Test::Unit::TestCase
|
4
|
+
include ScmTest
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@repo = SvnRepo.new
|
10
|
+
@repo.create
|
11
|
+
end
|
12
|
+
|
13
|
+
def path(uri)
|
14
|
+
SCM::Svn.new(uri, "").dir_for("commit").
|
15
|
+
sub(Bob.directory, "").to_s[1..-1]
|
16
|
+
end
|
17
|
+
|
18
|
+
test "converts svn repo uri into a path" do
|
19
|
+
assert_equal "http-rubygems-rubyforge-org-svn/commit",
|
20
|
+
path("http://rubygems.rubyforge.org/svn/")
|
21
|
+
|
22
|
+
assert_equal "svn-rubyforge-org-var-svn-rubygems/commit",
|
23
|
+
path("svn://rubyforge.org/var/svn/rubygems")
|
24
|
+
|
25
|
+
assert_equal "svn-ssh-developername-rubyforge-org-var-svn-rubygems/commit",
|
26
|
+
path("svn+ssh://developername@rubyforge.org/var/svn/rubygems")
|
27
|
+
|
28
|
+
assert_equal "home-user-code-repo/commit",
|
29
|
+
path("/home/user/code/repo")
|
30
|
+
end
|
31
|
+
end
|
data/test/test_test.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class BobTestTest < Test::Unit::TestCase
|
4
|
+
def assert_scm_repo(repo)
|
5
|
+
repo.create
|
6
|
+
|
7
|
+
assert_equal 1, repo.commits.size
|
8
|
+
assert_equal "First commit", repo.commits.first["message"]
|
9
|
+
|
10
|
+
repo.add_failing_commit
|
11
|
+
assert_equal 2, repo.commits.size
|
12
|
+
assert_equal "This commit will fail", repo.commits.last["message"]
|
13
|
+
assert_equal repo.commits.last["identifier"], repo.head
|
14
|
+
assert repo.short_head
|
15
|
+
|
16
|
+
repo.add_successful_commit
|
17
|
+
assert_equal 3, repo.commits.size
|
18
|
+
assert_equal "This commit will work", repo.commits.last["message"]
|
19
|
+
assert_equal repo.commits.last["identifier"], repo.head
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_scm_repo
|
23
|
+
assert_scm_repo(GitRepo.new)
|
24
|
+
assert_scm_repo(SvnRepo.new)
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.0
|
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-10-10 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -23,46 +23,6 @@ dependencies:
|
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: "0"
|
25
25
|
version:
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: sr-mg
|
28
|
-
type: :development
|
29
|
-
version_requirement:
|
30
|
-
version_requirements: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: "0"
|
35
|
-
version:
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: contest
|
38
|
-
type: :development
|
39
|
-
version_requirement:
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: "0"
|
45
|
-
version:
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: redgreen
|
48
|
-
type: :development
|
49
|
-
version_requirement:
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: "0"
|
55
|
-
version:
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: ruby-debug
|
58
|
-
type: :development
|
59
|
-
version_requirement:
|
60
|
-
version_requirements: !ruby/object:Gem::Requirement
|
61
|
-
requirements:
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: "0"
|
65
|
-
version:
|
66
26
|
description: Bob the Builder will build your code. Simple.
|
67
27
|
email: info@integrityapp.com
|
68
28
|
executables: []
|
@@ -77,20 +37,30 @@ files:
|
|
77
37
|
- README.rdoc
|
78
38
|
- Rakefile
|
79
39
|
- bob.gemspec
|
40
|
+
- deps.rip
|
80
41
|
- lib/bob.rb
|
81
|
-
- lib/bob/background_engines.rb
|
82
|
-
- lib/bob/background_engines/foreground.rb
|
83
42
|
- lib/bob/builder.rb
|
43
|
+
- lib/bob/engine.rb
|
44
|
+
- lib/bob/engine/threaded.rb
|
84
45
|
- lib/bob/scm.rb
|
85
46
|
- lib/bob/scm/abstract.rb
|
86
47
|
- lib/bob/scm/git.rb
|
87
|
-
- lib/
|
48
|
+
- lib/bob/scm/svn.rb
|
49
|
+
- lib/bob/test.rb
|
50
|
+
- lib/bob/test/builder_stub.rb
|
51
|
+
- lib/bob/test/repo.rb
|
88
52
|
- test/bob_test.rb
|
53
|
+
- test/deps.rip
|
54
|
+
- test/engine/threaded_test.rb
|
55
|
+
- test/git_test.rb
|
89
56
|
- test/helper.rb
|
90
|
-
- test/
|
91
|
-
- test/
|
57
|
+
- test/mixin/scm.rb
|
58
|
+
- test/svn_test.rb
|
59
|
+
- test/test_test.rb
|
92
60
|
has_rdoc: true
|
93
61
|
homepage: http://integrityapp.com
|
62
|
+
licenses: []
|
63
|
+
|
94
64
|
post_install_message:
|
95
65
|
rdoc_options: []
|
96
66
|
|
@@ -111,9 +81,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
81
|
requirements: []
|
112
82
|
|
113
83
|
rubyforge_project: integrity
|
114
|
-
rubygems_version: 1.3.
|
84
|
+
rubygems_version: 1.3.3
|
115
85
|
signing_key:
|
116
|
-
specification_version:
|
86
|
+
specification_version: 3
|
117
87
|
summary: Bob builds!
|
118
88
|
test_files: []
|
119
89
|
|
data/lib/core_ext/object.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module TestHelper
|
2
|
-
module BuildableStub
|
3
|
-
attr_reader :repo, :builds, :metadata
|
4
|
-
|
5
|
-
def initialize(repo)
|
6
|
-
@repo = repo
|
7
|
-
@builds = {}
|
8
|
-
@metadata = {}
|
9
|
-
end
|
10
|
-
|
11
|
-
def build_script
|
12
|
-
"./test"
|
13
|
-
end
|
14
|
-
|
15
|
-
def start_building(commit_id, commit_info)
|
16
|
-
@metadata[commit_id] = commit_info
|
17
|
-
end
|
18
|
-
|
19
|
-
def finish_building(commit_id, status, output)
|
20
|
-
@builds[commit_id] = [status ? :successful : :failed, output]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class GitBuildableStub
|
25
|
-
include BuildableStub
|
26
|
-
|
27
|
-
def kind
|
28
|
-
:git
|
29
|
-
end
|
30
|
-
|
31
|
-
def uri
|
32
|
-
repo.path
|
33
|
-
end
|
34
|
-
|
35
|
-
def branch
|
36
|
-
"master"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class SvnBuildableStub
|
41
|
-
include BuildableStub
|
42
|
-
|
43
|
-
def kind
|
44
|
-
:svn
|
45
|
-
end
|
46
|
-
|
47
|
-
def uri
|
48
|
-
"file://#{SvnRepo.server_root}/#{repo.name}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def branch
|
52
|
-
""
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/test/helper/git_helper.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/abstract_scm_helper"
|
2
|
-
|
3
|
-
module TestHelper
|
4
|
-
class GitRepo < AbstractSCMRepo
|
5
|
-
def create
|
6
|
-
FileUtils.mkdir_p @path
|
7
|
-
|
8
|
-
Dir.chdir(@path) do
|
9
|
-
system 'git init &>/dev/null'
|
10
|
-
system 'git config user.name "John Doe"'
|
11
|
-
system 'git config user.email "johndoe@example.org"'
|
12
|
-
system 'echo "just a test repo" >> README'
|
13
|
-
add 'README &>/dev/null'
|
14
|
-
commit "First commit"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def commits
|
19
|
-
Dir.chdir(@path) do
|
20
|
-
commits = `git log --pretty=oneline`.collect { |l| l.split(" ").first }
|
21
|
-
commits.inject([]) do |commits, sha1|
|
22
|
-
format = "---%n:message: >-%n %s%n:timestamp: %ci%n" +
|
23
|
-
":identifier: %H%n:author: %n :name: %an%n :email: %ae%n"
|
24
|
-
commits << YAML.load(`git show -s --pretty=format:"#{format}" #{sha1}`)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def head
|
30
|
-
Dir.chdir(@path) do
|
31
|
-
`git log --pretty=format:%H | head -1`.chomp
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def short_head
|
36
|
-
head[0..6]
|
37
|
-
end
|
38
|
-
|
39
|
-
protected
|
40
|
-
def add(file)
|
41
|
-
system "git add #{file}"
|
42
|
-
end
|
43
|
-
|
44
|
-
def commit(message)
|
45
|
-
system %Q{git commit -m "#{message}" &>/dev/null}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|