citrus-core 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.citrus/config.rb +3 -0
  3. data/.gitignore +21 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +9 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +10 -0
  9. data/Rakefile +9 -0
  10. data/citrus-core.gemspec +25 -0
  11. data/examples/bootstrap.rb +40 -0
  12. data/examples/payload.json +1 -0
  13. data/examples/web.rb +53 -0
  14. data/lib/citrus/core.rb +37 -0
  15. data/lib/citrus/core/build.rb +16 -0
  16. data/lib/citrus/core/cached_code_fetcher.rb +34 -0
  17. data/lib/citrus/core/changeset.rb +25 -0
  18. data/lib/citrus/core/commit.rb +20 -0
  19. data/lib/citrus/core/commit_changes.rb +15 -0
  20. data/lib/citrus/core/configuration.rb +17 -0
  21. data/lib/citrus/core/configuration_loader.rb +26 -0
  22. data/lib/citrus/core/configuration_validator.rb +13 -0
  23. data/lib/citrus/core/execute_build_service.rb +30 -0
  24. data/lib/citrus/core/git_adapter.rb +43 -0
  25. data/lib/citrus/core/github_adapter.rb +21 -0
  26. data/lib/citrus/core/publisher.rb +23 -0
  27. data/lib/citrus/core/repository.rb +13 -0
  28. data/lib/citrus/core/test_result.rb +24 -0
  29. data/lib/citrus/core/test_runner.rb +32 -0
  30. data/lib/citrus/core/version.rb +5 -0
  31. data/lib/citrus/core/workspace_builder.rb +27 -0
  32. data/spec/build_spec.rb +13 -0
  33. data/spec/cached_code_fetcher_spec.rb +69 -0
  34. data/spec/changeset_spec.rb +15 -0
  35. data/spec/citrus_spec.rb +18 -0
  36. data/spec/cofiguration_loader_spec.rb +27 -0
  37. data/spec/cofiguration_spec.rb +11 -0
  38. data/spec/cofiguration_validator_spec.rb +28 -0
  39. data/spec/commit_changes_spec.rb +15 -0
  40. data/spec/commit_spec.rb +21 -0
  41. data/spec/execute_build_service_spec.rb +76 -0
  42. data/spec/fixtures/github_push_data.json +143 -0
  43. data/spec/fixtures/repo/.citrus/config.rb +3 -0
  44. data/spec/github_adapter_spec.rb +16 -0
  45. data/spec/publisher_spec.rb +26 -0
  46. data/spec/repository_spec.rb +11 -0
  47. data/spec/spec_helper.rb +11 -0
  48. data/spec/test_result_spec.rb +20 -0
  49. data/spec/test_runner_spec.rb +44 -0
  50. data/spec/workspace_builder_spec.rb +55 -0
  51. metadata +167 -0
@@ -0,0 +1,143 @@
1
+ {
2
+ "after":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
3
+ "before":"17c497ccc7cca9c2f735aa07e9e3813060ce9a6a",
4
+ "commits":[
5
+ {
6
+ "added":[
7
+
8
+ ],
9
+ "author":{
10
+ "email":"lolwut@noway.biz",
11
+ "name":"Garen Torikian",
12
+ "username":"octokitty"
13
+ },
14
+ "committer":{
15
+ "email":"lolwut@noway.biz",
16
+ "name":"Garen Torikian",
17
+ "username":"octokitty"
18
+ },
19
+ "distinct":true,
20
+ "id":"c441029cf673f84c8b7db52d0a5944ee5c52ff89",
21
+ "message":"Test",
22
+ "modified":[
23
+ "README.md"
24
+ ],
25
+ "removed":[
26
+
27
+ ],
28
+ "timestamp":"2013-02-22T13:50:07-08:00",
29
+ "url":"https://github.com/octokitty/testing/commit/c441029cf673f84c8b7db52d0a5944ee5c52ff89"
30
+ },
31
+ {
32
+ "added":[
33
+
34
+ ],
35
+ "author":{
36
+ "email":"lolwut@noway.biz",
37
+ "name":"Garen Torikian",
38
+ "username":"octokitty"
39
+ },
40
+ "committer":{
41
+ "email":"lolwut@noway.biz",
42
+ "name":"Garen Torikian",
43
+ "username":"octokitty"
44
+ },
45
+ "distinct":true,
46
+ "id":"36c5f2243ed24de58284a96f2a643bed8c028658",
47
+ "message":"This is me testing the windows client.",
48
+ "modified":[
49
+ "README.md"
50
+ ],
51
+ "removed":[
52
+
53
+ ],
54
+ "timestamp":"2013-02-22T14:07:13-08:00",
55
+ "url":"https://github.com/octokitty/testing/commit/36c5f2243ed24de58284a96f2a643bed8c028658"
56
+ },
57
+ {
58
+ "added":[
59
+ "words/madame-bovary.txt"
60
+ ],
61
+ "author":{
62
+ "email":"lolwut@noway.biz",
63
+ "name":"Garen Torikian",
64
+ "username":"octokitty"
65
+ },
66
+ "committer":{
67
+ "email":"lolwut@noway.biz",
68
+ "name":"Garen Torikian",
69
+ "username":"octokitty"
70
+ },
71
+ "distinct":true,
72
+ "id":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
73
+ "message":"Rename madame-bovary.txt to words/madame-bovary.txt",
74
+ "modified":[
75
+
76
+ ],
77
+ "removed":[
78
+ "madame-bovary.txt"
79
+ ],
80
+ "timestamp":"2013-03-12T08:14:29-07:00",
81
+ "url":"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb"
82
+ }
83
+ ],
84
+ "compare":"https://github.com/octokitty/testing/compare/17c497ccc7cc...1481a2de7b2a",
85
+ "created":false,
86
+ "deleted":false,
87
+ "forced":false,
88
+ "head_commit":{
89
+ "added":[
90
+ "words/madame-bovary.txt"
91
+ ],
92
+ "author":{
93
+ "email":"lolwut@noway.biz",
94
+ "name":"Garen Torikian",
95
+ "username":"octokitty"
96
+ },
97
+ "committer":{
98
+ "email":"lolwut@noway.biz",
99
+ "name":"Garen Torikian",
100
+ "username":"octokitty"
101
+ },
102
+ "distinct":true,
103
+ "id":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
104
+ "message":"Rename madame-bovary.txt to words/madame-bovary.txt",
105
+ "modified":[
106
+
107
+ ],
108
+ "removed":[
109
+ "madame-bovary.txt"
110
+ ],
111
+ "timestamp":"2013-03-12T08:14:29-07:00",
112
+ "url":"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb"
113
+ },
114
+ "pusher":{
115
+ "name":"none"
116
+ },
117
+ "ref":"refs/heads/master",
118
+ "repository":{
119
+ "created_at":1332977768,
120
+ "description":"",
121
+ "fork":false,
122
+ "forks":0,
123
+ "has_downloads":true,
124
+ "has_issues":true,
125
+ "has_wiki":true,
126
+ "homepage":"",
127
+ "id":3860742,
128
+ "language":"Ruby",
129
+ "master_branch":"master",
130
+ "name":"testing",
131
+ "open_issues":2,
132
+ "owner":{
133
+ "email":"lolwut@noway.biz",
134
+ "name":"octokitty"
135
+ },
136
+ "private":false,
137
+ "pushed_at":1363295520,
138
+ "size":2156,
139
+ "stargazers":1,
140
+ "url":"https://github.com/octokitty/testing",
141
+ "watchers":1
142
+ }
143
+ }
@@ -0,0 +1,3 @@
1
+ Citrus::Configuration.describe do |c|
2
+ c.build_script = "ruby -I. sample_test.rb"
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Citrus::Core::GithubAdapter do
4
+
5
+ subject { described_class.new }
6
+
7
+ let(:push_data) { Pathname.new(File.dirname(__FILE__)).join('fixtures/github_push_data.json').read }
8
+
9
+ context '#create_changeset_from_push_data' do
10
+ let(:changeset) { subject.create_changeset_from_push_data(push_data) }
11
+
12
+ specify { expect(changeset.repository_url).to eql('https://github.com/octokitty/testing') }
13
+ specify { expect(changeset.head).to eql('1481a2de7b2a7d02428ad93446ab166be7793fbb') }
14
+ end
15
+
16
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ class Subscriber
4
+ def foo; end
5
+ end
6
+
7
+ describe Citrus::Core::Publisher do
8
+
9
+ subject { described_class.extend(described_class) }
10
+ let(:subscriber) { fake(:subscriber) }
11
+
12
+ it 'should notify added subscribers on publish' do
13
+ subject.add_subscriber(subscriber)
14
+ subject.publish(:foo)
15
+
16
+ expect(subscriber).to have_received.foo
17
+ end
18
+
19
+ it 'should pass silently when subscriber does not respond to event' do
20
+ expect {
21
+ subject.add_subscriber(subscriber)
22
+ subject.publish(:foo)
23
+ }.to_not raise_error(NoMethodError)
24
+ end
25
+
26
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Citrus::Core::Repository do
4
+
5
+ subject { described_class.new(url) }
6
+
7
+ let(:url) { 'file:///repo' }
8
+
9
+ it { should respond_to(:url) }
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'bogus/rspec'
2
+ require 'fakefs/spec_helpers'
3
+ require 'citrus/core'
4
+
5
+ RSpec.configure do |config|
6
+ config.order = 'random'
7
+ end
8
+
9
+ Bogus.configure do |config|
10
+ config.search_modules << Citrus::Core
11
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Citrus::Core::TestResult do
4
+
5
+ it 'should be successful for zero exit code value' do
6
+ subject = described_class.new(0)
7
+ expect(subject.success?).to be_true
8
+ end
9
+
10
+ it 'should be failure for non-zero exit code value' do
11
+ subject = described_class.new(1)
12
+ expect(subject.failure?).to be_true
13
+ end
14
+
15
+ it 'should have IO like output' do
16
+ subject = described_class.new(0)
17
+ expect(subject.output).to respond_to(:rewind)
18
+ end
19
+
20
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ class Subscriber
4
+ def output_received(data); end
5
+ end
6
+
7
+ describe Citrus::Core::TestRunner do
8
+
9
+ subject { described_class.new }
10
+
11
+ let(:configuration) { fake(:configuration, build_script: 'hostname') }
12
+ let(:path) { Pathname.new('/') }
13
+ let(:process) { fake { ChildProcess::AbstractProcess } }
14
+ let(:subscriber) { fake(:subscriber) }
15
+
16
+ context '#start' do
17
+ context do
18
+ before { stub(ChildProcess).build(configuration.build_script) { process } }
19
+
20
+ it 'spawns child process' do
21
+ expect(process).to have_received.start
22
+ end
23
+
24
+ it 'should return test result' do
25
+ expect(subject.start(configuration, path)).to be_kind_of(Citrus::Core::TestResult)
26
+ end
27
+
28
+ it 'should wait for process to finish' do
29
+ expect(process).to have_received.wait
30
+ end
31
+ end
32
+
33
+ it 'should publish output_received event when process produced output' do
34
+ subject.add_subscriber(subscriber)
35
+ subject.start(configuration, path)
36
+ expect(subscriber).to have_received.output_received(`hostname`)
37
+ end
38
+ end
39
+
40
+ it 'should allow adding subscribers' do
41
+ expect(subject).to respond_to(:add_subscriber)
42
+ end
43
+
44
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Citrus::Core::WorkspaceBuilder do
4
+
5
+ subject { described_class.new(build_root, code_fetcher) }
6
+
7
+ let(:build) { fake(:build) }
8
+ let(:changeset) { fake(:changeset) }
9
+ let(:code_fetcher) { fake(:cached_code_fetcher) }
10
+
11
+ context '#create_workspace' do
12
+ include FakeFS::SpecHelpers
13
+
14
+ let(:result) { subject.create_workspace(build) }
15
+
16
+ context do
17
+ let(:build_root) { fake(:pathname) }
18
+ let(:workspace_path) { fake(:pathname) }
19
+
20
+ before do
21
+ stub(build_root).join(any_args) { workspace_path }
22
+ stub(build).changeset { changeset }
23
+ result
24
+ end
25
+
26
+ it 'should return workspace path' do
27
+ expect(result).to eql(workspace_path)
28
+ end
29
+
30
+ it 'should fetch code needed for build into workspace' do
31
+ expect(code_fetcher).to have_received.fetch(changeset, workspace_path)
32
+ end
33
+ end
34
+
35
+ context do
36
+ let(:build_root) { Pathname.new('/build_root') }
37
+ let(:uuid) { SecureRandom.uuid }
38
+
39
+ before { stub(build).uuid { uuid } }
40
+
41
+ it 'should create build directory under build root' do
42
+ expect(result.to_s).to match %r{\A#{build_root}}
43
+ end
44
+
45
+ it 'should create workspace in directories partitioned by date' do
46
+ expect(result.dirname.to_s).to match %r{\A/build_root/\d{4}/\d{2}/\d{2}\Z}
47
+ end
48
+
49
+ it 'should create workspace named after builds uuid' do
50
+ expect(result.basename.to_s).to eql(uuid)
51
+ end
52
+ end
53
+ end
54
+
55
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: citrus-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Paweł Pacana
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: childprocess
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: fakefs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bogus
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.4
69
+ description: Citrus continous integration core components.
70
+ email:
71
+ - pawel.pacana@syswise.eu
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .citrus/config.rb
77
+ - .gitignore
78
+ - .rspec
79
+ - .travis.yml
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - citrus-core.gemspec
85
+ - examples/bootstrap.rb
86
+ - examples/payload.json
87
+ - examples/web.rb
88
+ - lib/citrus/core.rb
89
+ - lib/citrus/core/build.rb
90
+ - lib/citrus/core/cached_code_fetcher.rb
91
+ - lib/citrus/core/changeset.rb
92
+ - lib/citrus/core/commit.rb
93
+ - lib/citrus/core/commit_changes.rb
94
+ - lib/citrus/core/configuration.rb
95
+ - lib/citrus/core/configuration_loader.rb
96
+ - lib/citrus/core/configuration_validator.rb
97
+ - lib/citrus/core/execute_build_service.rb
98
+ - lib/citrus/core/git_adapter.rb
99
+ - lib/citrus/core/github_adapter.rb
100
+ - lib/citrus/core/publisher.rb
101
+ - lib/citrus/core/repository.rb
102
+ - lib/citrus/core/test_result.rb
103
+ - lib/citrus/core/test_runner.rb
104
+ - lib/citrus/core/version.rb
105
+ - lib/citrus/core/workspace_builder.rb
106
+ - spec/build_spec.rb
107
+ - spec/cached_code_fetcher_spec.rb
108
+ - spec/changeset_spec.rb
109
+ - spec/citrus_spec.rb
110
+ - spec/cofiguration_loader_spec.rb
111
+ - spec/cofiguration_spec.rb
112
+ - spec/cofiguration_validator_spec.rb
113
+ - spec/commit_changes_spec.rb
114
+ - spec/commit_spec.rb
115
+ - spec/execute_build_service_spec.rb
116
+ - spec/fixtures/github_push_data.json
117
+ - spec/fixtures/repo/.citrus/config.rb
118
+ - spec/github_adapter_spec.rb
119
+ - spec/publisher_spec.rb
120
+ - spec/repository_spec.rb
121
+ - spec/spec_helper.rb
122
+ - spec/test_result_spec.rb
123
+ - spec/test_runner_spec.rb
124
+ - spec/workspace_builder_spec.rb
125
+ homepage: http://citrus-ci.org
126
+ licenses: []
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.0.3
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Citrus continous integration core components.
148
+ test_files:
149
+ - spec/build_spec.rb
150
+ - spec/cached_code_fetcher_spec.rb
151
+ - spec/changeset_spec.rb
152
+ - spec/citrus_spec.rb
153
+ - spec/cofiguration_loader_spec.rb
154
+ - spec/cofiguration_spec.rb
155
+ - spec/cofiguration_validator_spec.rb
156
+ - spec/commit_changes_spec.rb
157
+ - spec/commit_spec.rb
158
+ - spec/execute_build_service_spec.rb
159
+ - spec/fixtures/github_push_data.json
160
+ - spec/fixtures/repo/.citrus/config.rb
161
+ - spec/github_adapter_spec.rb
162
+ - spec/publisher_spec.rb
163
+ - spec/repository_spec.rb
164
+ - spec/spec_helper.rb
165
+ - spec/test_result_spec.rb
166
+ - spec/test_runner_spec.rb
167
+ - spec/workspace_builder_spec.rb