paraduct 0.0.1.beta5 → 0.0.1.beta6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/paraduct/cli.rb +9 -0
- data/lib/paraduct/configuration.rb +14 -9
- data/lib/paraduct/runner.rb +1 -15
- data/lib/paraduct/sync_utils.rb +20 -0
- data/lib/paraduct/templates/.paraduct_rsync_exclude.txt.tt +2 -0
- data/lib/paraduct/version.rb +1 -1
- data/lib/paraduct.rb +1 -0
- data/paraduct.gemspec +1 -0
- data/spec/.paraduct.yml +2 -0
- data/spec/.paraduct_rsync_exclude.txt +2 -0
- data/spec/paraduct/cli_spec.rb +42 -31
- data/spec/paraduct/runner_spec.rb +0 -28
- data/spec/paraduct/sync_utils_spec.rb +39 -0
- data/spec/support/contexts/stub_configuration.rb +16 -0
- data/spec/support/contexts/within_temp_dir.rb +13 -0
- data/spec/support/contexts/within_temp_work_dir.rb +2 -1
- metadata +29 -3
data/README.md
CHANGED
@@ -10,7 +10,8 @@ Paraduct (**parallel** + **parameterize** + **product**) is matrix test runner
|
|
10
10
|
[![Stories in Ready](https://badge.waffle.io/sue445/paraduct.svg?label=ready&title=Ready)](http://waffle.io/sue445/paraduct)
|
11
11
|
|
12
12
|
## Requirements
|
13
|
-
ruby 1.9+
|
13
|
+
* ruby 1.9+
|
14
|
+
* rsync
|
14
15
|
|
15
16
|
## Installation
|
16
17
|
|
data/lib/paraduct/cli.rb
CHANGED
@@ -5,6 +5,14 @@ module Paraduct
|
|
5
5
|
class CLI < Thor
|
6
6
|
include Thor::Actions
|
7
7
|
|
8
|
+
class_option :version, type: :boolean
|
9
|
+
|
10
|
+
desc "version", "Show paraduct version"
|
11
|
+
def version
|
12
|
+
puts Paraduct::VERSION
|
13
|
+
end
|
14
|
+
default_task :version
|
15
|
+
|
8
16
|
desc "test", "run matrix test"
|
9
17
|
def test
|
10
18
|
script = Paraduct.config.script
|
@@ -22,6 +30,7 @@ module Paraduct
|
|
22
30
|
desc "generate", "generate .paraduct.yml"
|
23
31
|
def generate
|
24
32
|
template(".paraduct.yml")
|
33
|
+
template(".paraduct_rsync_exclude.txt")
|
25
34
|
end
|
26
35
|
|
27
36
|
def self.source_root
|
@@ -5,29 +5,28 @@ module Paraduct
|
|
5
5
|
class Configuration
|
6
6
|
include Singleton
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
raise "not found .paraduct.yml" unless config_file.exist?
|
10
|
-
@config = YAML.load_file(config_file)
|
11
|
-
end
|
12
|
-
|
13
8
|
# @return [Pathname]
|
14
9
|
def variables
|
15
|
-
|
10
|
+
config_data[:variables]
|
16
11
|
end
|
17
12
|
|
18
13
|
# @return [String, Array<String>]
|
19
14
|
def script
|
20
|
-
|
15
|
+
config_data[:script]
|
21
16
|
end
|
22
17
|
|
23
18
|
# @return [Integer]
|
24
19
|
def max_threads
|
25
|
-
|
20
|
+
config_data[:max_threads] || 4
|
21
|
+
end
|
22
|
+
|
23
|
+
def rsync_option
|
24
|
+
config_data[:rsync_option] || {}
|
26
25
|
end
|
27
26
|
|
28
27
|
# @return [Pathname]
|
29
28
|
def work_dir
|
30
|
-
_work_dir =
|
29
|
+
_work_dir = config_data[:work_dir] || "tmp/paraduct_workspace"
|
31
30
|
root_dir.join(_work_dir)
|
32
31
|
end
|
33
32
|
|
@@ -40,5 +39,11 @@ module Paraduct
|
|
40
39
|
def root_dir
|
41
40
|
Pathname.pwd
|
42
41
|
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def config_data
|
46
|
+
@config_data ||= YAML.load_file(config_file).with_indifferent_access
|
47
|
+
end
|
43
48
|
end
|
44
49
|
end
|
data/lib/paraduct/runner.rb
CHANGED
@@ -16,7 +16,7 @@ module Paraduct
|
|
16
16
|
|
17
17
|
def setup_dir
|
18
18
|
FileUtils.mkdir_p(job_dir) unless job_dir.exist?
|
19
|
-
|
19
|
+
Paraduct::SyncUtils.copy_recursive(Paraduct.config.root_dir, job_dir)
|
20
20
|
Dir.chdir(job_dir)
|
21
21
|
end
|
22
22
|
|
@@ -48,20 +48,6 @@ module Paraduct
|
|
48
48
|
@params.map{ |key, value| "#{key}=#{value}" }.join(", ")
|
49
49
|
end
|
50
50
|
|
51
|
-
# @param source_dir [Pathname]
|
52
|
-
# @param destination_dir [Pathname]
|
53
|
-
def self.copy_recursive(source_dir, destination_dir)
|
54
|
-
FileUtils.mkdir_p(destination_dir)
|
55
|
-
source_dir.children.each do |source_child_dir|
|
56
|
-
begin
|
57
|
-
FileUtils.cp_r(source_child_dir, destination_dir)
|
58
|
-
rescue ArgumentError => e
|
59
|
-
# TODO: refactoring
|
60
|
-
raise unless e.message =~ /^cannot copy directory .+ to itself /
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
51
|
def self.capitalize_keys(params)
|
66
52
|
params.inject({}) do |res, (key, value)|
|
67
53
|
res[key.upcase] = value
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Paraduct
|
2
|
+
require "rsync"
|
3
|
+
|
4
|
+
class SyncUtils
|
5
|
+
# @param source_dir [Pathname]
|
6
|
+
# @param destination_dir [Pathname]
|
7
|
+
def self.copy_recursive(source_dir, destination_dir)
|
8
|
+
FileUtils.mkdir_p(destination_dir)
|
9
|
+
|
10
|
+
rsync_options = %W(
|
11
|
+
--recursive
|
12
|
+
--delete
|
13
|
+
--exclude-from=#{Paraduct.config.rsync_option[:exclude_from]}
|
14
|
+
)
|
15
|
+
result = Rsync.run(source_dir.to_s + "/", destination_dir, rsync_options)
|
16
|
+
raise result.error unless result.success?
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/paraduct/version.rb
CHANGED
data/lib/paraduct.rb
CHANGED
@@ -8,6 +8,7 @@ module Paraduct
|
|
8
8
|
autoload :Errors , 'paraduct/errors'
|
9
9
|
autoload :ParallelRunner , 'paraduct/parallel_runner'
|
10
10
|
autoload :Runner , 'paraduct/runner'
|
11
|
+
autoload :SyncUtils , 'paraduct/sync_utils'
|
11
12
|
autoload :TestResponse , 'paraduct/test_response'
|
12
13
|
autoload :VariableConverter, 'paraduct/variable_converter'
|
13
14
|
autoload :Version , 'paraduct/version'
|
data/paraduct.gemspec
CHANGED
data/spec/.paraduct.yml
CHANGED
data/spec/paraduct/cli_spec.rb
CHANGED
@@ -3,33 +3,41 @@ describe Paraduct::CLI do
|
|
3
3
|
|
4
4
|
let(:args){ [command] }
|
5
5
|
|
6
|
+
describe "#version" do
|
7
|
+
%w(version --version).each do |_command|
|
8
|
+
context "with #{_command}" do
|
9
|
+
let(:command){ _command }
|
10
|
+
|
11
|
+
it { expect{ subject }.to output("#{Paraduct::VERSION}\n").to_stdout }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
6
16
|
describe "#test" do
|
7
17
|
let(:command){ "test" }
|
8
18
|
|
9
|
-
include_context :
|
19
|
+
include_context :stub_configuration
|
20
|
+
include_context :within_temp_dir
|
10
21
|
|
11
22
|
context "successful test" do
|
23
|
+
let(:config_data) do
|
24
|
+
{
|
25
|
+
script: "./script/build_success.sh",
|
26
|
+
work_dir: "tmp/paraduct_workspace",
|
27
|
+
variables: {
|
28
|
+
ruby: ["1.9.3", "2.0.0"],
|
29
|
+
database: ["mysql", "postgresql"],
|
30
|
+
},
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
12
34
|
let(:script){ "./script/build_success.sh" }
|
13
35
|
let(:product_variables) do
|
14
36
|
[
|
15
|
-
{ "ruby" => "1.9.3", "database" => "mysql"
|
16
|
-
{ "ruby" => "1.9.3", "database" => "
|
17
|
-
{ "ruby" => "
|
18
|
-
{ "ruby" => "
|
19
|
-
{ "ruby" => "1.9.3", "database" => "postgresql", "rails" => "4.0.0" },
|
20
|
-
{ "ruby" => "1.9.3", "database" => "postgresql", "rails" => "4.1.0" },
|
21
|
-
{ "ruby" => "2.0.0", "database" => "mysql" , "rails" => "3.2.0" },
|
22
|
-
{ "ruby" => "2.0.0", "database" => "mysql" , "rails" => "4.0.0" },
|
23
|
-
{ "ruby" => "2.0.0", "database" => "mysql" , "rails" => "4.1.0" },
|
24
|
-
{ "ruby" => "2.0.0", "database" => "postgresql", "rails" => "3.2.0" },
|
25
|
-
{ "ruby" => "2.0.0", "database" => "postgresql", "rails" => "4.0.0" },
|
26
|
-
{ "ruby" => "2.0.0", "database" => "postgresql", "rails" => "4.1.0" },
|
27
|
-
{ "ruby" => "2.1.2", "database" => "mysql" , "rails" => "3.2.0" },
|
28
|
-
{ "ruby" => "2.1.2", "database" => "mysql" , "rails" => "4.0.0" },
|
29
|
-
{ "ruby" => "2.1.2", "database" => "mysql" , "rails" => "4.1.0" },
|
30
|
-
{ "ruby" => "2.1.2", "database" => "postgresql", "rails" => "3.2.0" },
|
31
|
-
{ "ruby" => "2.1.2", "database" => "postgresql", "rails" => "4.0.0" },
|
32
|
-
{ "ruby" => "2.1.2", "database" => "postgresql", "rails" => "4.1.0" },
|
37
|
+
{ "ruby" => "1.9.3", "database" => "mysql" },
|
38
|
+
{ "ruby" => "1.9.3", "database" => "postgresql" },
|
39
|
+
{ "ruby" => "2.0.0", "database" => "mysql" },
|
40
|
+
{ "ruby" => "2.0.0", "database" => "postgresql" },
|
33
41
|
]
|
34
42
|
end
|
35
43
|
|
@@ -46,9 +54,14 @@ describe Paraduct::CLI do
|
|
46
54
|
end
|
47
55
|
|
48
56
|
context "failure test" do
|
49
|
-
|
50
|
-
|
51
|
-
|
57
|
+
let(:config_data) do
|
58
|
+
{
|
59
|
+
script: %q(exit ${STATUS}),
|
60
|
+
work_dir: "tmp/paraduct_workspace",
|
61
|
+
variables: {
|
62
|
+
status: [0, 1],
|
63
|
+
},
|
64
|
+
}
|
52
65
|
end
|
53
66
|
|
54
67
|
it { expect{ subject }.to raise_error Paraduct::Errors::TestFailureError }
|
@@ -58,21 +71,19 @@ describe Paraduct::CLI do
|
|
58
71
|
describe "#generate" do
|
59
72
|
let(:command){ "generate" }
|
60
73
|
|
61
|
-
include_context
|
62
|
-
|
63
|
-
around do |example|
|
64
|
-
Dir.chdir(temp_dir) do
|
65
|
-
example.run
|
66
|
-
end
|
67
|
-
end
|
74
|
+
include_context :within_temp_dir
|
68
75
|
|
69
76
|
before do
|
70
77
|
# exercise
|
71
78
|
subject
|
72
79
|
end
|
73
80
|
|
74
|
-
|
81
|
+
%w(.paraduct.yml .paraduct_rsync_exclude.txt).each do |template_file|
|
82
|
+
describe "whether copy #{template_file}" do
|
83
|
+
let(:generated_config_file){ temp_dir_path.join(template_file) }
|
75
84
|
|
76
|
-
|
85
|
+
it { expect(generated_config_file).to be_exist }
|
86
|
+
end
|
87
|
+
end
|
77
88
|
end
|
78
89
|
end
|
@@ -69,34 +69,6 @@ DATABASE=mysql
|
|
69
69
|
it { should eq Pathname("/tmp/jobs/RUBY_1.9_DATABASE_mysql") }
|
70
70
|
end
|
71
71
|
|
72
|
-
describe "#copy_recursive" do
|
73
|
-
subject{ Paraduct::Runner.copy_recursive(source_dir, destination_dir) }
|
74
|
-
|
75
|
-
include_context "uses temp dir"
|
76
|
-
|
77
|
-
let(:source_dir) { temp_dir_path }
|
78
|
-
let(:destination_dir){ temp_dir_path.join("tmp/paraduct_workspace/RUBY_1.9_DATABASE_mysql") }
|
79
|
-
let(:copied_file) { destination_dir.join("build_success.sh") }
|
80
|
-
let(:not_copied_file){ destination_dir.join("tmp/paraduct_workspace/dummy.txt") }
|
81
|
-
|
82
|
-
before do
|
83
|
-
# setup
|
84
|
-
FileUtils.cp_r(spec_dir.join("script/tmp/paraduct_workspace"), source_dir)
|
85
|
-
FileUtils.cp_r(spec_dir.join("script/build_success.sh"), source_dir)
|
86
|
-
|
87
|
-
# exercise
|
88
|
-
subject
|
89
|
-
end
|
90
|
-
|
91
|
-
# after do
|
92
|
-
# puts `tree #{source_dir}`
|
93
|
-
# end
|
94
|
-
|
95
|
-
it { expect(destination_dir).to be_exist }
|
96
|
-
it { expect(copied_file).to be_exist }
|
97
|
-
it { expect(not_copied_file).not_to be_exist }
|
98
|
-
end
|
99
|
-
|
100
72
|
describe "#formatted_params" do
|
101
73
|
subject{ runner.formatted_params }
|
102
74
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
describe Paraduct::SyncUtils do
|
2
|
+
describe "#copy_recursive" do
|
3
|
+
subject{ Paraduct::SyncUtils.copy_recursive(source_dir, destination_dir) }
|
4
|
+
|
5
|
+
include_context :within_temp_dir
|
6
|
+
include_context :stub_configuration
|
7
|
+
|
8
|
+
let(:config_data) do
|
9
|
+
{
|
10
|
+
rsync_option: {
|
11
|
+
exclude_from: ".paraduct_rsync_exclude.txt",
|
12
|
+
},
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:source_dir) { temp_dir_path }
|
17
|
+
let(:destination_dir){ temp_dir_path.join("tmp/paraduct_workspace/RUBY_1.9_DATABASE_mysql") }
|
18
|
+
let(:copied_file) { destination_dir.join("build_success.sh") }
|
19
|
+
let(:not_copied_file){ destination_dir.join("tmp/paraduct_workspace/dummy.txt") }
|
20
|
+
|
21
|
+
before do
|
22
|
+
# setup
|
23
|
+
FileUtils.cp_r(spec_dir.join("script/tmp/paraduct_workspace"), source_dir)
|
24
|
+
FileUtils.cp(spec_dir.join("script/build_success.sh"), source_dir)
|
25
|
+
FileUtils.cp(spec_dir.join(".paraduct_rsync_exclude.txt"), source_dir)
|
26
|
+
|
27
|
+
# exercise
|
28
|
+
subject
|
29
|
+
end
|
30
|
+
|
31
|
+
# after do
|
32
|
+
# puts `tree #{source_dir}`
|
33
|
+
# end
|
34
|
+
|
35
|
+
it { expect(destination_dir).to be_exist }
|
36
|
+
it { expect(copied_file).to be_exist }
|
37
|
+
it { expect(not_copied_file).not_to be_exist }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
shared_context :stub_configuration do
|
2
|
+
before do
|
3
|
+
allow_any_instance_of(Paraduct::Configuration).to receive(:config_data){ config_data.stringify_keys.with_indifferent_access }
|
4
|
+
end
|
5
|
+
|
6
|
+
let(:config_data) do
|
7
|
+
{
|
8
|
+
script: %q(echo "NAME1=${NAME1}, NAME2=${NAME2}"),
|
9
|
+
work_dir: "tmp/paraduct_workspace",
|
10
|
+
variables: {
|
11
|
+
name1: ["value1a", "value1b"],
|
12
|
+
name2: ["value2a", "value2b"],
|
13
|
+
},
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
shared_context :within_temp_dir do
|
2
|
+
include_context "uses temp dir"
|
3
|
+
|
4
|
+
before do
|
5
|
+
# avoid "warning: conflicting chdir during another chdir block"
|
6
|
+
@current_dir = Pathname.pwd
|
7
|
+
Dir.chdir(temp_dir)
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
Dir.chdir(@current_dir)
|
12
|
+
end
|
13
|
+
end
|
@@ -6,7 +6,8 @@ shared_context :within_temp_work_dir do
|
|
6
6
|
@current_dir = Pathname.pwd
|
7
7
|
Dir.chdir(temp_dir)
|
8
8
|
FileUtils.cp_r(spec_dir.join("script"), temp_dir)
|
9
|
-
FileUtils.
|
9
|
+
FileUtils.cp(spec_dir.join(".paraduct.yml"), temp_dir)
|
10
|
+
FileUtils.cp(spec_dir.join(".paraduct_rsync_exclude.txt"), temp_dir)
|
10
11
|
end
|
11
12
|
|
12
13
|
after do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paraduct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta6
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rsync
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: thor
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -293,17 +309,21 @@ files:
|
|
293
309
|
- lib/paraduct/errors.rb
|
294
310
|
- lib/paraduct/parallel_runner.rb
|
295
311
|
- lib/paraduct/runner.rb
|
312
|
+
- lib/paraduct/sync_utils.rb
|
296
313
|
- lib/paraduct/templates/.paraduct.yml.tt
|
314
|
+
- lib/paraduct/templates/.paraduct_rsync_exclude.txt.tt
|
297
315
|
- lib/paraduct/test_response.rb
|
298
316
|
- lib/paraduct/variable_converter.rb
|
299
317
|
- lib/paraduct/version.rb
|
300
318
|
- paraduct.gemspec
|
301
319
|
- spec/.paraduct.yml
|
320
|
+
- spec/.paraduct_rsync_exclude.txt
|
302
321
|
- spec/.rubocop.yml
|
303
322
|
- spec/paraduct/cli_spec.rb
|
304
323
|
- spec/paraduct/configuration_spec.rb
|
305
324
|
- spec/paraduct/parallel_runner_spec.rb
|
306
325
|
- spec/paraduct/runner_spec.rb
|
326
|
+
- spec/paraduct/sync_utils_spec.rb
|
307
327
|
- spec/paraduct/test_response_spec.rb
|
308
328
|
- spec/paraduct/variable_converter_spec.rb
|
309
329
|
- spec/paraduct_spec.rb
|
@@ -311,7 +331,9 @@ files:
|
|
311
331
|
- spec/script/build_success.sh
|
312
332
|
- spec/script/tmp/paraduct_workspace/dummy.txt
|
313
333
|
- spec/spec_helper.rb
|
334
|
+
- spec/support/contexts/stub_configuration.rb
|
314
335
|
- spec/support/contexts/within_spec_dir.rb
|
336
|
+
- spec/support/contexts/within_temp_dir.rb
|
315
337
|
- spec/support/contexts/within_temp_work_dir.rb
|
316
338
|
- tmp/.gitkeep
|
317
339
|
homepage: https://github.com/sue445/paraduct
|
@@ -329,7 +351,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
329
351
|
version: '0'
|
330
352
|
segments:
|
331
353
|
- 0
|
332
|
-
hash:
|
354
|
+
hash: 3159191224660044510
|
333
355
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
334
356
|
none: false
|
335
357
|
requirements:
|
@@ -344,11 +366,13 @@ specification_version: 3
|
|
344
366
|
summary: matrix test runner
|
345
367
|
test_files:
|
346
368
|
- spec/.paraduct.yml
|
369
|
+
- spec/.paraduct_rsync_exclude.txt
|
347
370
|
- spec/.rubocop.yml
|
348
371
|
- spec/paraduct/cli_spec.rb
|
349
372
|
- spec/paraduct/configuration_spec.rb
|
350
373
|
- spec/paraduct/parallel_runner_spec.rb
|
351
374
|
- spec/paraduct/runner_spec.rb
|
375
|
+
- spec/paraduct/sync_utils_spec.rb
|
352
376
|
- spec/paraduct/test_response_spec.rb
|
353
377
|
- spec/paraduct/variable_converter_spec.rb
|
354
378
|
- spec/paraduct_spec.rb
|
@@ -356,6 +380,8 @@ test_files:
|
|
356
380
|
- spec/script/build_success.sh
|
357
381
|
- spec/script/tmp/paraduct_workspace/dummy.txt
|
358
382
|
- spec/spec_helper.rb
|
383
|
+
- spec/support/contexts/stub_configuration.rb
|
359
384
|
- spec/support/contexts/within_spec_dir.rb
|
385
|
+
- spec/support/contexts/within_temp_dir.rb
|
360
386
|
- spec/support/contexts/within_temp_work_dir.rb
|
361
387
|
has_rdoc:
|