evrone-ci-router 0.2.0.pre0 → 0.2.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/evrone-ci-router +5 -0
- data/fixtures/jobs_publisher +13 -0
- data/lib/evrone/ci/router.rb +112 -37
- data/lib/evrone/ci/router/build.rb +29 -3
- data/lib/evrone/ci/router/build_matrix.rb +7 -1
- data/lib/evrone/ci/router/cli.rb +67 -0
- data/lib/evrone/ci/router/configuration.rb +7 -1
- data/lib/evrone/ci/router/consumers/builds_consumer.rb +1 -1
- data/lib/evrone/ci/router/initializers/amqp.rb +2 -1
- data/lib/evrone/ci/router/{queue.rb → script_builder.rb} +10 -6
- data/lib/evrone/ci/router/{middleware/travis → script_builder}/env.rb +1 -1
- data/lib/evrone/ci/router/{middleware/travis → script_builder}/ruby.rb +1 -1
- data/lib/evrone/ci/router/{middleware/travis → script_builder}/script.rb +1 -1
- data/lib/evrone/ci/router/travis.rb +2 -2
- data/lib/evrone/ci/router/version.rb +1 -1
- data/spec/lib/build_matrix_spec.rb +13 -2
- data/spec/lib/build_spec.rb +33 -0
- data/spec/lib/configuration_spec.rb +4 -2
- data/spec/lib/router_spec.rb +116 -0
- data/spec/lib/{queue_spec.rb → script_builder_spec.rb} +7 -7
- data/spec/lib/travis_spec.rb +2 -2
- metadata +18 -38
- data/bin/cli +0 -3
- data/bin/git_ssh +0 -3
- data/bin/jobs_publisher +0 -12
- data/bin/workers +0 -13
- data/lib/evrone/ci/router/middleware/create_build_matrix.rb +0 -54
- data/lib/evrone/ci/router/middleware/create_dirs.rb +0 -25
- data/lib/evrone/ci/router/middleware/fetch_commit_info.rb +0 -22
- data/lib/evrone/ci/router/middleware/fetch_source.rb +0 -36
- data/lib/evrone/ci/router/middleware/log_build.rb +0 -24
- data/lib/evrone/ci/router/middleware/update_build_status.rb +0 -75
- data/spec/lib/middleware/create_build_matrix_spec.rb +0 -73
- data/spec/lib/middleware/create_dirs_spec.rb +0 -26
- data/spec/lib/middleware/fetch_commit_info_spec.rb +0 -23
- data/spec/lib/middleware/fetch_source_spec.rb +0 -27
- data/spec/lib/middleware/log_build_spec.rb +0 -14
- data/spec/lib/middleware/update_build_status_spec.rb +0 -70
@@ -5,7 +5,9 @@ describe Evrone::CI::Router::BuildMatrix do
|
|
5
5
|
let(:attributes) { {
|
6
6
|
env: %w{ FOO=1 BAR=2 },
|
7
7
|
rvm: %w{ 1.8.7 1.9.3 2.0.0 },
|
8
|
-
scala: %w{ 2.9.2 2.10.1 }
|
8
|
+
scala: %w{ 2.9.2 2.10.1 },
|
9
|
+
before_script: "echo before_script",
|
10
|
+
script: "echo script"
|
9
11
|
} }
|
10
12
|
let(:travis) { create :travis, attributes: attributes }
|
11
13
|
let(:matrix) { described_class.new travis }
|
@@ -27,8 +29,17 @@ describe Evrone::CI::Router::BuildMatrix do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
context 'travises' do
|
32
|
+
subject { matrix.travises }
|
33
|
+
|
34
|
+
it "should copy script from source" do
|
35
|
+
expect(subject.map(&:script).uniq).to eq [["echo script"]]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should copy before_script from source" do
|
39
|
+
expect(subject.map(&:before_script).uniq).to eq [["echo before_script"]]
|
40
|
+
end
|
41
|
+
|
30
42
|
context "values" do
|
31
|
-
subject { matrix.travises }
|
32
43
|
|
33
44
|
it { should have(12).items }
|
34
45
|
|
data/spec/lib/build_spec.rb
CHANGED
@@ -26,6 +26,39 @@ describe Evrone::CI::Router::Build do
|
|
26
26
|
its(:log) { should eq data }
|
27
27
|
end
|
28
28
|
|
29
|
+
context "to_build_status_message" do
|
30
|
+
subject { build.to_build_status_message Evrone::CI::Router::Build::STARTED }
|
31
|
+
|
32
|
+
before do
|
33
|
+
build.matrix = ["rvm"]
|
34
|
+
build.jobs_count = 1
|
35
|
+
end
|
36
|
+
|
37
|
+
it { should be_an_instance_of(Evrone::CI::Message::BuildStatus) }
|
38
|
+
its(:build_id) { should eq build.message.id }
|
39
|
+
its(:status) { should eq 2 }
|
40
|
+
its(:tm) { should be }
|
41
|
+
its(:tm_usec) { should be }
|
42
|
+
its(:matrix) { should eq %w{ rvm } }
|
43
|
+
its(:jobs_count) { should eq 1 }
|
44
|
+
|
45
|
+
context "when commit_info exists" do
|
46
|
+
before do
|
47
|
+
build.commit_info = OpenStruct.new(
|
48
|
+
author: "author",
|
49
|
+
email: "email",
|
50
|
+
sha: 'sha',
|
51
|
+
message: "message"
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
its(:commit_author) { should eq 'author' }
|
56
|
+
its(:commit_author_email) { should eq 'email' }
|
57
|
+
its(:commit_sha) { should eq 'sha' }
|
58
|
+
its(:commit_message) { should eq 'message' }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
29
62
|
context "add_to_output" do
|
30
63
|
let(:data) { 'data' }
|
31
64
|
let(:messages) { Evrone::CI::Router::BuildLogsConsumer.messages }
|
@@ -16,7 +16,9 @@ describe Evrone::CI::Router::Configuration do
|
|
16
16
|
c.amqp_url = "2"
|
17
17
|
end
|
18
18
|
}
|
19
|
-
its(:timeout)
|
20
|
-
its(:amqp_url)
|
19
|
+
its(:timeout) { should eq 1 }
|
20
|
+
its(:amqp_url) { should eq "2" }
|
21
|
+
its(:workers) { should eq 1 }
|
22
|
+
its(:repo_dir_name) { should eq 'repo' }
|
21
23
|
end
|
22
24
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
describe Evrone::CI::Router do
|
6
|
+
let(:build) { create :build }
|
7
|
+
let(:path_prefix) { '/tmp/.test' }
|
8
|
+
let(:router) { described_class.new build, path_prefix }
|
9
|
+
subject { router }
|
10
|
+
|
11
|
+
before do
|
12
|
+
FileUtils.rm_rf path_prefix
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
FileUtils.rm_rf path_prefix
|
17
|
+
end
|
18
|
+
|
19
|
+
context "just created" do
|
20
|
+
its(:build) { should eq build }
|
21
|
+
its("path_prefix.to_s") { should eq path_prefix }
|
22
|
+
its("repo_dir.to_s") { should eq "/tmp/.test/repo/evrone/test-repo" }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "#perform" do
|
26
|
+
subject { router.perform }
|
27
|
+
it { should be_true }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "#update_build_status" do
|
31
|
+
let(:messages) { Evrone::CI::Router::BuildStatusConsumer.messages }
|
32
|
+
let(:first_message) { messages.first }
|
33
|
+
let(:last_message) { messages.last }
|
34
|
+
|
35
|
+
it "should delivery STARTED and FINISHED when success" do
|
36
|
+
router.update_build_status { true }
|
37
|
+
expect(messages).to have(2).items
|
38
|
+
expect(first_message.status).to eq Evrone::CI::Router::Build::STARTED
|
39
|
+
expect(last_message.status).to eq Evrone::CI::Router::Build::FINISHED
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should delivery STARTED and FAILED when failed" do
|
43
|
+
router.update_build_status { false }
|
44
|
+
expect(messages).to have(2).items
|
45
|
+
expect(first_message.status).to eq Evrone::CI::Router::Build::STARTED
|
46
|
+
expect(last_message.status).to eq Evrone::CI::Router::Build::FAILED
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should delivery STARTED and FAILED when exception raised" do
|
50
|
+
router.update_build_status { raise "Ignore Me" }
|
51
|
+
expect(messages).to have(2).items
|
52
|
+
expect(first_message.status).to eq Evrone::CI::Router::Build::STARTED
|
53
|
+
expect(last_message.status).to eq Evrone::CI::Router::Build::FAILED
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "#create_repo_dir" do
|
58
|
+
subject { router.create_repo_dir }
|
59
|
+
it "should create directory inside path_prefix" do
|
60
|
+
expect(subject).to be_true
|
61
|
+
expect(router.repo_dir).to be_directory
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "#fetch_repo" do
|
66
|
+
subject { router.fetch_repo }
|
67
|
+
it "should fetch repo" do
|
68
|
+
expect(subject).to be_true
|
69
|
+
expect(router.repo_dir.join(".git")).to be_directory
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "#assign_commit_info" do
|
74
|
+
subject { router.assign_commit_info }
|
75
|
+
before { mock_repo_dir }
|
76
|
+
|
77
|
+
it "should assign commit information to build" do
|
78
|
+
expect(subject).to be_true
|
79
|
+
expect(router.build.commit_info.marshal_dump).to eq(
|
80
|
+
:sha=>"687753389908e70801dd4ff5448be908642055c6",
|
81
|
+
:author=>"Dmitry Galinsky",
|
82
|
+
:email=>"dima.exe@gmail.com",
|
83
|
+
:message=>"test commit #3"
|
84
|
+
)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "#load_travis" do
|
89
|
+
subject { router.load_travis }
|
90
|
+
before { mock_repo_dir }
|
91
|
+
it "should build new travis instance from .travis.yml" do
|
92
|
+
expect(subject).to be_true
|
93
|
+
expect(router.travis).to be
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "#create_and_delivery_build_matrix" do
|
98
|
+
let(:messages) { Evrone::CI::Router::JobsConsumer.messages }
|
99
|
+
let(:message) { messages.first }
|
100
|
+
subject { router.create_and_delivery_build_matrix }
|
101
|
+
before do
|
102
|
+
stub(router).travis { create :travis }
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should create build matrix from source travis and delivery its to jobs" do
|
106
|
+
expect(subject).to be_true
|
107
|
+
expect(messages).to have(1).item
|
108
|
+
expect(message.job_id).to eq 1
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def mock_repo_dir
|
113
|
+
stub(router).repo_dir { Pathname.new fixture_path("repo") }
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Evrone::CI::Router::
|
3
|
+
describe Evrone::CI::Router::ScriptBuilder do
|
4
4
|
let(:travis) { create :travis }
|
5
|
-
let(:
|
5
|
+
let(:script_builder) { described_class.new travis }
|
6
6
|
let(:expected_before_script) {
|
7
|
-
s = [
|
7
|
+
s = []
|
8
8
|
s << "export LC_ALL=en_US.UTF8"
|
9
9
|
s << "eval \"$(rbenv init -)\" || true"
|
10
10
|
s << %{
|
@@ -28,22 +28,22 @@ describe Evrone::CI::Router::Queue do
|
|
28
28
|
s.join("\n")
|
29
29
|
}
|
30
30
|
let(:expected_script) {
|
31
|
-
s = [
|
31
|
+
s = []
|
32
32
|
trace s, "RAILS_ENV=test ls -1 && echo DONE!"
|
33
33
|
s.join("\n")
|
34
34
|
}
|
35
|
-
subject {
|
35
|
+
subject { script_builder }
|
36
36
|
|
37
37
|
its(:travis) { should eq travis }
|
38
38
|
|
39
39
|
context "to_before_script" do
|
40
|
-
subject {
|
40
|
+
subject { script_builder.to_before_script }
|
41
41
|
|
42
42
|
it { should eq expected_before_script }
|
43
43
|
end
|
44
44
|
|
45
45
|
context "to_script" do
|
46
|
-
subject {
|
46
|
+
subject { script_builder.to_script }
|
47
47
|
|
48
48
|
it { should eq expected_script }
|
49
49
|
end
|
data/spec/lib/travis_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evrone-ci-router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evrone-ci-common
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.0.
|
19
|
+
version: 0.2.0.pre1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.0.
|
26
|
+
version: 0.2.0.pre1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: evrone-ci-message
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2.0.
|
33
|
+
version: 0.2.0.pre1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2.0.
|
40
|
+
version: 0.2.0.pre1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: evrone-common-amqp
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,10 +126,7 @@ description: ' ci router '
|
|
126
126
|
email:
|
127
127
|
- dima.exe@gmail.com
|
128
128
|
executables:
|
129
|
-
-
|
130
|
-
- git_ssh
|
131
|
-
- jobs_publisher
|
132
|
-
- workers
|
129
|
+
- evrone-ci-router
|
133
130
|
extensions: []
|
134
131
|
extra_rdoc_files: []
|
135
132
|
files:
|
@@ -138,15 +135,14 @@ files:
|
|
138
135
|
- Gemfile
|
139
136
|
- README.md
|
140
137
|
- Rakefile
|
141
|
-
- bin/
|
142
|
-
- bin/git_ssh
|
143
|
-
- bin/jobs_publisher
|
144
|
-
- bin/workers
|
138
|
+
- bin/evrone-ci-router
|
145
139
|
- evrone-ci-router.gemspec
|
140
|
+
- fixtures/jobs_publisher
|
146
141
|
- fixtures/travis.yml
|
147
142
|
- lib/evrone/ci/router.rb
|
148
143
|
- lib/evrone/ci/router/build.rb
|
149
144
|
- lib/evrone/ci/router/build_matrix.rb
|
145
|
+
- lib/evrone/ci/router/cli.rb
|
150
146
|
- lib/evrone/ci/router/configuration.rb
|
151
147
|
- lib/evrone/ci/router/consumers/build_logs_consumer.rb
|
152
148
|
- lib/evrone/ci/router/consumers/build_status_consumer.rb
|
@@ -158,29 +154,18 @@ files:
|
|
158
154
|
- lib/evrone/ci/router/helper/logger.rb
|
159
155
|
- lib/evrone/ci/router/helper/trace_sh_command.rb
|
160
156
|
- lib/evrone/ci/router/initializers/amqp.rb
|
161
|
-
- lib/evrone/ci/router/
|
162
|
-
- lib/evrone/ci/router/
|
163
|
-
- lib/evrone/ci/router/
|
164
|
-
- lib/evrone/ci/router/
|
165
|
-
- lib/evrone/ci/router/middleware/log_build.rb
|
166
|
-
- lib/evrone/ci/router/middleware/travis/env.rb
|
167
|
-
- lib/evrone/ci/router/middleware/travis/ruby.rb
|
168
|
-
- lib/evrone/ci/router/middleware/travis/script.rb
|
169
|
-
- lib/evrone/ci/router/middleware/update_build_status.rb
|
170
|
-
- lib/evrone/ci/router/queue.rb
|
157
|
+
- lib/evrone/ci/router/script_builder.rb
|
158
|
+
- lib/evrone/ci/router/script_builder/env.rb
|
159
|
+
- lib/evrone/ci/router/script_builder/ruby.rb
|
160
|
+
- lib/evrone/ci/router/script_builder/script.rb
|
171
161
|
- lib/evrone/ci/router/travis.rb
|
172
162
|
- lib/evrone/ci/router/travis/serializable.rb
|
173
163
|
- lib/evrone/ci/router/version.rb
|
174
164
|
- spec/lib/build_matrix_spec.rb
|
175
165
|
- spec/lib/build_spec.rb
|
176
166
|
- spec/lib/configuration_spec.rb
|
177
|
-
- spec/lib/
|
178
|
-
- spec/lib/
|
179
|
-
- spec/lib/middleware/fetch_commit_info_spec.rb
|
180
|
-
- spec/lib/middleware/fetch_source_spec.rb
|
181
|
-
- spec/lib/middleware/log_build_spec.rb
|
182
|
-
- spec/lib/middleware/update_build_status_spec.rb
|
183
|
-
- spec/lib/queue_spec.rb
|
167
|
+
- spec/lib/router_spec.rb
|
168
|
+
- spec/lib/script_builder_spec.rb
|
184
169
|
- spec/lib/travis_spec.rb
|
185
170
|
- spec/spec_helper.rb
|
186
171
|
- spec/support/create.rb
|
@@ -214,13 +199,8 @@ test_files:
|
|
214
199
|
- spec/lib/build_matrix_spec.rb
|
215
200
|
- spec/lib/build_spec.rb
|
216
201
|
- spec/lib/configuration_spec.rb
|
217
|
-
- spec/lib/
|
218
|
-
- spec/lib/
|
219
|
-
- spec/lib/middleware/fetch_commit_info_spec.rb
|
220
|
-
- spec/lib/middleware/fetch_source_spec.rb
|
221
|
-
- spec/lib/middleware/log_build_spec.rb
|
222
|
-
- spec/lib/middleware/update_build_status_spec.rb
|
223
|
-
- spec/lib/queue_spec.rb
|
202
|
+
- spec/lib/router_spec.rb
|
203
|
+
- spec/lib/script_builder_spec.rb
|
224
204
|
- spec/lib/travis_spec.rb
|
225
205
|
- spec/spec_helper.rb
|
226
206
|
- spec/support/create.rb
|
data/bin/cli
DELETED
data/bin/git_ssh
DELETED
data/bin/jobs_publisher
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.expand_path("../../lib/evrone/ci/router", __FILE__)
|
4
|
-
|
5
|
-
require File.expand_path("../../spec/support/fixture", __FILE__)
|
6
|
-
require File.expand_path("../../spec/support/create", __FILE__)
|
7
|
-
|
8
|
-
require 'evrone/ci/message/testing'
|
9
|
-
|
10
|
-
include Evrone::CI
|
11
|
-
|
12
|
-
Router::BuildsConsumer.publish Message::PerformBuild.test_message
|