vx-router 0.2.0.pre28

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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +9 -0
  5. data/LICENSE.txt +276 -0
  6. data/Rakefile +46 -0
  7. data/bin/vx-router +5 -0
  8. data/fixtures/jobs_publisher +13 -0
  9. data/fixtures/travis.yml +5 -0
  10. data/lib/vx/router.rb +158 -0
  11. data/lib/vx/router/build.rb +80 -0
  12. data/lib/vx/router/cli.rb +53 -0
  13. data/lib/vx/router/configuration.rb +27 -0
  14. data/lib/vx/router/consumers/build_logs_consumer.rb +13 -0
  15. data/lib/vx/router/consumers/build_status_consumer.rb +13 -0
  16. data/lib/vx/router/consumers/builds_consumer.rb +27 -0
  17. data/lib/vx/router/consumers/job_status_consumer.rb +13 -0
  18. data/lib/vx/router/consumers/jobs_consumer.rb +13 -0
  19. data/lib/vx/router/ext/array.rb +5 -0
  20. data/lib/vx/router/ext/string.rb +9 -0
  21. data/lib/vx/router/helper/config.rb +11 -0
  22. data/lib/vx/router/helper/logger.rb +11 -0
  23. data/lib/vx/router/helper/trace_sh_command.rb +12 -0
  24. data/lib/vx/router/initializers/amqp.rb +3 -0
  25. data/lib/vx/router/script_builder.rb +98 -0
  26. data/lib/vx/router/script_builder/databases.rb +28 -0
  27. data/lib/vx/router/script_builder/env.rb +21 -0
  28. data/lib/vx/router/script_builder/prepare.rb +58 -0
  29. data/lib/vx/router/script_builder/ruby.rb +68 -0
  30. data/lib/vx/router/script_builder/script.rb +22 -0
  31. data/lib/vx/router/script_builder/webdav_cache.rb +80 -0
  32. data/lib/vx/router/version.rb +5 -0
  33. data/spec/lib/build_spec.rb +123 -0
  34. data/spec/lib/configuration_spec.rb +23 -0
  35. data/spec/lib/router_spec.rb +80 -0
  36. data/spec/lib/script_builder/prepare_spec.rb +44 -0
  37. data/spec/lib/script_builder/webdav_cache_spec.rb +80 -0
  38. data/spec/lib/script_builder_spec.rb +36 -0
  39. data/spec/spec_helper.rb +17 -0
  40. data/spec/support/create.rb +40 -0
  41. data/spec/support/fixture.rb +7 -0
  42. data/spec/support/last_build_log_message.rb +3 -0
  43. data/spec/support/shared_examples/update_build_status_message.rb +5 -0
  44. data/vx-router.gemspec +32 -0
  45. metadata +225 -0
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'vx/common/spawn'
3
+ require 'fileutils'
4
+
5
+ describe Vx::Router::ScriptBuilder::Prepare do
6
+ let(:path) { '/tmp/.test' }
7
+ let(:app) { ->(_) { _ } }
8
+ let(:build) { create :build }
9
+ let(:env) { OpenStruct.new build: build, init: [] }
10
+ let(:mid) { described_class.new app }
11
+
12
+ subject { mid.call env }
13
+
14
+ before do
15
+ FileUtils.rm_rf path
16
+ FileUtils.mkdir_p path
17
+ end
18
+
19
+ after { FileUtils.rm_rf path }
20
+
21
+ it { should eq env }
22
+ its(:init) { should_not be_empty }
23
+
24
+ context "run compiled script" do
25
+ include Vx::Common::Spawn
26
+
27
+ let(:script) { "set -e\nset -x\n" + env.init.join("\n") }
28
+ before { mid.call env }
29
+
30
+ it "should be success" do
31
+
32
+ code = spawn script, chdir: path do |out|
33
+ puts " ===> #{out}"
34
+ end
35
+
36
+ expect(code).to eq 0
37
+ expect(File).to be_readable("#{path}/data/evrone/test-repo/git_ssh")
38
+ expect(File).to be_readable("#{path}/data/evrone/test-repo/key")
39
+ expect(File).to be_directory("#{path}/code/evrone/test-repo/.git")
40
+ expect(File).to be_readable("#{path}/code/evrone/test-repo/Rakefile")
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+ require 'vx/common/spawn'
3
+ require 'fileutils'
4
+
5
+ describe Vx::Router::ScriptBuilder::WebdavCache do
6
+ let(:path) { '/tmp/.test' }
7
+ let(:app) { ->(_) { _ } }
8
+ let(:build) { create :build, branch: "feature" }
9
+ let(:config) { create :configuration }
10
+ let(:env) { OpenStruct.new(
11
+ build: build,
12
+ init: [],
13
+ configuration: config,
14
+ after_script: [],
15
+ cache_key: ['rvm-1.9.3']
16
+ )}
17
+ let(:mid) { described_class.new app }
18
+
19
+ subject { mid.call env }
20
+
21
+ before do
22
+ FileUtils.rm_rf path
23
+ FileUtils.mkdir_p path
24
+
25
+ Vx::Router.configure do |c|
26
+ c.webdav_cache_url = 'http://localhost:8080'
27
+ end
28
+ end
29
+
30
+ after { FileUtils.rm_rf path }
31
+
32
+ it { should eq env }
33
+ its(:init) { should_not be_empty }
34
+ its(:after_script) { should_not be_empty }
35
+ its(:webdav_push_url) { should eq "http://localhost:8080/evrone/test-repo/feature/rvm-1.9.3.tgz" }
36
+ its(:webdav_fetch_url) { should eq(
37
+ ["http://localhost:8080/evrone/test-repo/feature/rvm-1.9.3.tgz",
38
+ "http://localhost:8080/evrone/test-repo/master/rvm-1.9.3.tgz"]
39
+ ) }
40
+
41
+ context "execute command" do
42
+ include Vx::Common::Spawn
43
+
44
+ let(:init_script) { env.init.join("\n") }
45
+ let(:after_script) { env.after_script.join("\n") }
46
+
47
+ before do
48
+ mid.call env
49
+ init_script.gsub!("$HOME/cached", path)
50
+ after_script.gsub!("$HOME/cached", path)
51
+ end
52
+
53
+ it "should be success" do
54
+ out = ""
55
+
56
+ code = spawn(init_script, chdir: path) do |o|
57
+ out << o
58
+ puts " ===> #{o}"
59
+ end
60
+ expect(code).to eq 0
61
+
62
+ code = spawn(after_script, chdir: path) do |o|
63
+ out << o
64
+ puts " ===> #{o}"
65
+ end
66
+ expect(code).to eq 0
67
+
68
+ #twice
69
+ code = spawn(after_script, chdir: path) do |o|
70
+ out << o
71
+ puts " ===> #{o}"
72
+ end
73
+ expect(code).to eq 0
74
+
75
+ #expect(out).to match("adding /tmp/.test to cache")
76
+ #expect(out).to match("casher successfuly downloaded")
77
+ end
78
+ end
79
+ end
80
+
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vx::Router::ScriptBuilder do
4
+ let(:build) { create :build }
5
+ let(:config) { create :configuration }
6
+ let(:script_builder) { described_class.new build, config }
7
+ subject { script_builder }
8
+
9
+ context "just created" do
10
+ its(:configuration) { should eq config }
11
+ its(:build) { should eq build }
12
+ end
13
+
14
+ context "to_before_script" do
15
+ subject { script_builder.to_before_script }
16
+
17
+ it { should_not be_empty }
18
+ end
19
+
20
+ context "to_script" do
21
+ subject { script_builder.to_script }
22
+
23
+ it { should_not be_empty }
24
+ end
25
+
26
+ context "to_after_script" do
27
+ subject { script_builder.to_after_script }
28
+
29
+ it { should_not be_empty }
30
+ end
31
+
32
+ def trace(s, cmd)
33
+ s << "echo #{Shellwords.escape "$ " + cmd}"
34
+ s << cmd
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path '../../lib/vx/router', __FILE__
2
+
3
+ Bundler.require(:test)
4
+ require 'rspec/autorun'
5
+ require 'vx/common/amqp/testing'
6
+ require 'vx/message/testing'
7
+
8
+ Dir[File.expand_path("../..", __FILE__) + "/spec/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :rr
12
+
13
+ config.before(:each) do
14
+ Vx::Common::AMQP::Testing.clear
15
+ Vx::Router.reset_config!
16
+ end
17
+ end
@@ -0,0 +1,40 @@
1
+ require 'yaml'
2
+
3
+ def create(who, *args)
4
+
5
+ options = args.last.is_a?(Hash) ? args.pop : {}
6
+
7
+ case who
8
+
9
+ when :local_repo
10
+ Vx::Router.root.join("fixtures/repo").to_s
11
+
12
+ when :configuration
13
+ klass = Vx::BuildConfiguration
14
+ configuration = nil
15
+ if options[:yaml]
16
+ configuration = klass.from_yaml options[:yaml]
17
+ elsif options[:attributes]
18
+ configuration = klass.from_attributes options[:attributes]
19
+ else
20
+ klass.from_yaml fixture("travis.yml")
21
+ end
22
+
23
+ when :message
24
+ name = args.shift
25
+
26
+ klass = Vx::Message.const_get name
27
+ klass.test_message options
28
+
29
+ when :build
30
+ message = options[:message] || create(:message, 'PerformBuild', options)
31
+ Vx::Router::Build.new message
32
+
33
+ when :git
34
+ build = args.shift
35
+ path = args.shift
36
+ SCM::Git.new build.src, build.sha, path, deploy_key: build.deploy_key, &build.method(:add_to_output)
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,7 @@
1
+ def fixture(name)
2
+ File.read fixture_path(name)
3
+ end
4
+
5
+ def fixture_path(name)
6
+ Vx::Router.root.join("fixtures", name.to_s)
7
+ end
@@ -0,0 +1,3 @@
1
+ def last_build_log_message
2
+ Vx::Router::BuildLogsConsumer.messages.last
3
+ end
@@ -0,0 +1,5 @@
1
+ shared_examples "UpdateBuildStatus message" do
2
+ its(:build_id) { should eq build.message.id }
3
+ its(:tm) { should be }
4
+ its(:tm_usec) { should be }
5
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require File.expand_path('../lib/vx/router/version.rb', __FILE__)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vx-router"
8
+ spec.version = Vx::Router::VERSION
9
+ spec.authors = ["Dmitry Galinsky"]
10
+ spec.email = ["dima.exe@gmail.com"]
11
+ spec.description = %q{ ci router }
12
+ spec.summary = %q{ ci router }
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'vx-common', "= #{Vx::Router::VERSION}"
22
+ spec.add_runtime_dependency 'vx-message', "= #{Vx::Router::VERSION}"
23
+ spec.add_runtime_dependency 'vx-build_configuration', "= #{Vx::Router::VERSION}"
24
+
25
+ spec.add_runtime_dependency 'vx-common-amqp', '~> 0.2.5'
26
+ spec.add_runtime_dependency 'hashr', '= 0.0.22'
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.3"
29
+ spec.add_development_dependency "rake"
30
+ spec.add_development_dependency "rspec"
31
+ spec.add_development_dependency "rr"
32
+ end
metadata ADDED
@@ -0,0 +1,225 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vx-router
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0.pre28
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Galinsky
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vx-common
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0.pre28
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0.pre28
27
+ - !ruby/object:Gem::Dependency
28
+ name: vx-message
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0.pre28
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0.pre28
41
+ - !ruby/object:Gem::Dependency
42
+ name: vx-build_configuration
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.0.pre28
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.0.pre28
55
+ - !ruby/object:Gem::Dependency
56
+ name: vx-common-amqp
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.0.22
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.0.22
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rr
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: ' ci router '
140
+ email:
141
+ - dima.exe@gmail.com
142
+ executables:
143
+ - vx-router
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - .gitignore
148
+ - .rspec
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - Rakefile
152
+ - bin/vx-router
153
+ - fixtures/jobs_publisher
154
+ - fixtures/travis.yml
155
+ - lib/vx/router.rb
156
+ - lib/vx/router/build.rb
157
+ - lib/vx/router/cli.rb
158
+ - lib/vx/router/configuration.rb
159
+ - lib/vx/router/consumers/build_logs_consumer.rb
160
+ - lib/vx/router/consumers/build_status_consumer.rb
161
+ - lib/vx/router/consumers/builds_consumer.rb
162
+ - lib/vx/router/consumers/job_status_consumer.rb
163
+ - lib/vx/router/consumers/jobs_consumer.rb
164
+ - lib/vx/router/ext/array.rb
165
+ - lib/vx/router/ext/string.rb
166
+ - lib/vx/router/helper/config.rb
167
+ - lib/vx/router/helper/logger.rb
168
+ - lib/vx/router/helper/trace_sh_command.rb
169
+ - lib/vx/router/initializers/amqp.rb
170
+ - lib/vx/router/script_builder.rb
171
+ - lib/vx/router/script_builder/databases.rb
172
+ - lib/vx/router/script_builder/env.rb
173
+ - lib/vx/router/script_builder/prepare.rb
174
+ - lib/vx/router/script_builder/ruby.rb
175
+ - lib/vx/router/script_builder/script.rb
176
+ - lib/vx/router/script_builder/webdav_cache.rb
177
+ - lib/vx/router/version.rb
178
+ - spec/lib/build_spec.rb
179
+ - spec/lib/configuration_spec.rb
180
+ - spec/lib/router_spec.rb
181
+ - spec/lib/script_builder/prepare_spec.rb
182
+ - spec/lib/script_builder/webdav_cache_spec.rb
183
+ - spec/lib/script_builder_spec.rb
184
+ - spec/spec_helper.rb
185
+ - spec/support/create.rb
186
+ - spec/support/fixture.rb
187
+ - spec/support/last_build_log_message.rb
188
+ - spec/support/shared_examples/update_build_status_message.rb
189
+ - vx-router.gemspec
190
+ homepage: ''
191
+ licenses:
192
+ - MIT
193
+ metadata: {}
194
+ post_install_message:
195
+ rdoc_options: []
196
+ require_paths:
197
+ - lib
198
+ required_ruby_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - '>'
206
+ - !ruby/object:Gem::Version
207
+ version: 1.3.1
208
+ requirements: []
209
+ rubyforge_project:
210
+ rubygems_version: 2.1.11
211
+ signing_key:
212
+ specification_version: 4
213
+ summary: ci router
214
+ test_files:
215
+ - spec/lib/build_spec.rb
216
+ - spec/lib/configuration_spec.rb
217
+ - spec/lib/router_spec.rb
218
+ - spec/lib/script_builder/prepare_spec.rb
219
+ - spec/lib/script_builder/webdav_cache_spec.rb
220
+ - spec/lib/script_builder_spec.rb
221
+ - spec/spec_helper.rb
222
+ - spec/support/create.rb
223
+ - spec/support/fixture.rb
224
+ - spec/support/last_build_log_message.rb
225
+ - spec/support/shared_examples/update_build_status_message.rb