vx-builder 0.5.61 → 0.5.62

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vx/builder/script_builder_v2/clone.rb +1 -2
  3. data/lib/vx/builder/task.rb +3 -3
  4. data/lib/vx/builder/version.rb +1 -1
  5. data/lib/vx/builder.rb +0 -5
  6. data/spec/fixtures/script_builder_v2/simple.sh +1 -1
  7. data/spec/fixtures/script_builder_v2/simple.yml +85 -30
  8. data/spec/fixtures/test_key1 +27 -0
  9. data/spec/fixtures/test_key2 +27 -0
  10. data/spec/lib/builder/task_spec.rb +1 -1
  11. data/spec/support/create.rb +3 -1
  12. metadata +6 -38
  13. data/lib/vx/builder/script_builder/base.rb +0 -77
  14. data/lib/vx/builder/script_builder/cache.rb +0 -95
  15. data/lib/vx/builder/script_builder/clojure.rb +0 -34
  16. data/lib/vx/builder/script_builder/defaults.rb +0 -34
  17. data/lib/vx/builder/script_builder/deploy.rb +0 -34
  18. data/lib/vx/builder/script_builder/env.rb +0 -50
  19. data/lib/vx/builder/script_builder/go.rb +0 -60
  20. data/lib/vx/builder/script_builder/java.rb +0 -31
  21. data/lib/vx/builder/script_builder/nodejs.rb +0 -64
  22. data/lib/vx/builder/script_builder/parallel.rb +0 -19
  23. data/lib/vx/builder/script_builder/prepare.rb +0 -94
  24. data/lib/vx/builder/script_builder/python.rb +0 -82
  25. data/lib/vx/builder/script_builder/ruby.rb +0 -92
  26. data/lib/vx/builder/script_builder/rust.rb +0 -48
  27. data/lib/vx/builder/script_builder/scala.rb +0 -50
  28. data/lib/vx/builder/script_builder/services.rb +0 -26
  29. data/lib/vx/builder/script_builder/timeouts.rb +0 -21
  30. data/lib/vx/builder/script_builder.rb +0 -145
  31. data/spec/lib/builder/script_builder/cache_spec.rb +0 -12
  32. data/spec/lib/builder/script_builder/clojure_spec.rb +0 -34
  33. data/spec/lib/builder/script_builder/env_spec.rb +0 -22
  34. data/spec/lib/builder/script_builder/java_spec.rb +0 -23
  35. data/spec/lib/builder/script_builder/prepare_spec.rb +0 -46
  36. data/spec/lib/builder/script_builder/python_spec.rb +0 -32
  37. data/spec/lib/builder/script_builder/ruby_spec.rb +0 -39
  38. data/spec/lib/builder/script_builder/scala_spec.rb +0 -33
  39. data/spec/lib/builder/script_builder_spec.rb +0 -60
@@ -1,145 +0,0 @@
1
- require 'vx/common'
2
-
3
- module Vx
4
- module Builder
5
- class ScriptBuilder
6
-
7
- autoload :Base, File.expand_path("../script_builder/base", __FILE__)
8
- autoload :Env, File.expand_path("../script_builder/env", __FILE__)
9
- autoload :Ruby, File.expand_path("../script_builder/ruby", __FILE__)
10
- autoload :Go, File.expand_path("../script_builder/go", __FILE__)
11
- autoload :Nodejs, File.expand_path("../script_builder/nodejs", __FILE__)
12
- autoload :Java, File.expand_path("../script_builder/java", __FILE__)
13
- autoload :Scala, File.expand_path("../script_builder/scala", __FILE__)
14
- autoload :Clojure, File.expand_path("../script_builder/clojure", __FILE__)
15
- autoload :Rust, File.expand_path("../script_builder/rust", __FILE__)
16
- autoload :Python, File.expand_path("../script_builder/python", __FILE__)
17
- autoload :Prepare, File.expand_path("../script_builder/prepare", __FILE__)
18
- autoload :Databases, File.expand_path("../script_builder/databases", __FILE__)
19
- autoload :Cache, File.expand_path("../script_builder/cache", __FILE__)
20
- autoload :Services, File.expand_path("../script_builder/services", __FILE__)
21
- autoload :Deploy, File.expand_path("../script_builder/deploy", __FILE__)
22
- autoload :Timeouts, File.expand_path("../script_builder/timeouts", __FILE__)
23
- autoload :Defaults, File.expand_path("../script_builder/defaults", __FILE__)
24
- autoload :Parallel, File.expand_path("../script_builder/parallel", __FILE__)
25
-
26
- include Common::Helper::Middlewares
27
-
28
- middlewares do
29
- use Builder::ScriptBuilder::Timeouts
30
- use Builder::ScriptBuilder::Cache
31
- use Builder::ScriptBuilder::Env
32
- use Builder::ScriptBuilder::Parallel
33
- use Builder::ScriptBuilder::Services
34
- use Builder::ScriptBuilder::Prepare
35
-
36
- use Builder::ScriptBuilder::Java
37
- use Builder::ScriptBuilder::Scala
38
- use Builder::ScriptBuilder::Clojure
39
- use Builder::ScriptBuilder::Ruby
40
- use Builder::ScriptBuilder::Go
41
- use Builder::ScriptBuilder::Nodejs
42
- use Builder::ScriptBuilder::Rust
43
- use Builder::ScriptBuilder::Python
44
-
45
- use Builder::ScriptBuilder::Deploy
46
- use Builder::ScriptBuilder::Defaults
47
- end
48
-
49
- attr_reader :source, :task
50
-
51
- def initialize(task, source)
52
- @source = source
53
- @task = task
54
- end
55
-
56
- def image
57
- source.image.first
58
- end
59
-
60
- def to_before_script
61
- a = []
62
- a << "\n# init"
63
- a += env.init
64
-
65
- a << "\n# before install"
66
- a += env.before_install
67
-
68
- a << "\n# announce"
69
- a += env.announce
70
-
71
- a << "\n# install"
72
- a += env.install
73
-
74
- a << "\n# before script"
75
- a += env.before_script
76
-
77
- a.join("\n")
78
- end
79
-
80
- def to_after_script
81
- a = []
82
- a << "\n# after script init"
83
- a += env.after_script_init
84
-
85
- a << "\n# after script"
86
- a += env.after_script
87
- a.join("\n")
88
- end
89
-
90
- def to_script
91
- a = []
92
-
93
- a << "\n# script"
94
- a += env.script
95
-
96
- a << "\n# after success"
97
- a += env.after_success
98
-
99
- a.join("\n")
100
- end
101
-
102
- def vexor
103
- source.vexor
104
- end
105
-
106
- private
107
-
108
- def env
109
- @env ||= run_middlewares(default_env) {|_| _ }
110
- end
111
-
112
- def default_env
113
- OpenStruct.new(
114
- # initialization, repo does not exists
115
- init: [],
116
-
117
- # before instalation, using for system setup
118
- before_install: [],
119
-
120
- # instalation, using for application setup
121
- install: [],
122
-
123
- # announce software and services version
124
- announce: [],
125
-
126
- before_script: [],
127
- script: [],
128
- after_success: [],
129
-
130
- after_script_init: [],
131
- after_script: [],
132
-
133
- before_deploy: [],
134
- deploy: [],
135
-
136
- source: source,
137
- task: task,
138
- cache_key: [],
139
- cached_directories: source.cache.directories,
140
- )
141
- end
142
-
143
- end
144
- end
145
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder::Cache do
4
- let(:app) { ->(env) { env } }
5
- let(:script) { described_class.new app }
6
- let(:env) { create :env }
7
- let(:run) { script.call env }
8
- subject { run }
9
-
10
- it { should eq env }
11
-
12
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder::Clojure do
4
- let(:app) { ->(env) { env } }
5
- let(:script) { described_class.new app }
6
- let(:source) { create :source, name: "clojure.yml" }
7
- let(:env) { create :env, source: source }
8
- let(:run) { script.call env }
9
- subject { run }
10
-
11
- it { should eq env }
12
-
13
- context "run it" do
14
- subject { env }
15
-
16
- context "should be success" do
17
- before { run }
18
- its(:announce) { should_not be_empty }
19
- its(:install) { should_not be_empty }
20
- its(:script) { should be_empty }
21
- end
22
-
23
- context "when script is empty" do
24
- before do
25
- env.source.script.clear
26
- run
27
- end
28
- its(:script) { should_not be_empty }
29
- end
30
-
31
-
32
- end
33
-
34
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder::Env do
4
- let(:app) { ->(_) { 0 } }
5
- let(:script) { described_class.new app }
6
- let(:env) { create :env }
7
- let(:run) { script.call env }
8
- subject { run }
9
-
10
- it { should eq 0 }
11
-
12
- context "run it" do
13
- let(:command) { create :command_from_env, env: env }
14
- before { run }
15
-
16
- it "should be success" do
17
- system( %{bash -l -c "#{command}" } )
18
- expect($?.to_i).to eq 0
19
- end
20
- end
21
-
22
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder::Java do
4
- let(:app) { ->(env) { env } }
5
- let(:script) { described_class.new app }
6
- let(:source) { create :source, name: "scala.yml" }
7
- let(:env) { create :env, source: source }
8
- let(:run) { script.call env }
9
- subject { run }
10
-
11
- it { should eq env }
12
-
13
- context "run it" do
14
- subject { env }
15
-
16
- context "should be success" do
17
- before { run }
18
- its(:before_install) { should_not be_empty }
19
- end
20
-
21
- end
22
-
23
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
- require 'tmpdir'
3
- require 'fileutils'
4
-
5
- describe Vx::Builder::ScriptBuilder::Prepare do
6
- let(:path) { Dir.tmpdir }
7
-
8
- before { FileUtils.rm_rf(path) }
9
- after { FileUtils.rm_rf(path) }
10
-
11
- def new_command(options = {})
12
- options[:task] ||= create(:task)
13
- options[:env] ||= create(:env, task: options[:task])
14
- options[:app] ||= ->(_) { 0 }
15
- options[:script] ||= described_class.new options[:app]
16
- options[:script].call(options[:env])
17
-
18
- options[:cmd] ||= create(:command_from_env, env: options[:env])
19
- options[:cmd]
20
- end
21
-
22
- it "should successfuly run command" do
23
- cmd = new_command
24
- Dir.chdir(path) do
25
- system( cmd )
26
- end
27
- expect($?.to_i).to eq 0
28
- end
29
-
30
- it "should be fail if reference if not in tree" do
31
- cmd = new_command(task: create(:task, sha: '8f53c077072674972e21c82a286acc07fada0000'))
32
- Dir.chdir(path) do
33
- system( cmd )
34
- end
35
- expect($?.to_i).to_not eq 0
36
- end
37
-
38
- it "should successfuly run for pull request" do
39
- cmd = new_command task: create(:task, pull_request_id: 1)
40
- Dir.chdir(path) do
41
- system( cmd )
42
- end
43
- expect($?.to_i).to eq 0
44
- end
45
-
46
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder::Python do
4
- let(:app) { ->(env) { env } }
5
- let(:script) { described_class.new app }
6
- let(:source) { create :source, name: "python.yml" }
7
- let(:env) { create :env, source: source }
8
- let(:run) { script.call env }
9
- subject { run }
10
-
11
- it { should eq env }
12
-
13
- context "run it" do
14
- subject { env }
15
-
16
- context "should be success" do
17
- before { run }
18
- its(:announce) { should_not be_empty }
19
- its(:install) { should_not be_empty }
20
- its(:script) { should be_empty }
21
- end
22
-
23
- context "when script is empty" do
24
- before do
25
- env.source.script.clear
26
- run
27
- end
28
- its(:script) { should_not be_empty }
29
- end
30
- end
31
-
32
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder::Ruby do
4
- let(:app) { ->(env) { env } }
5
- let(:script) { described_class.new app }
6
- let(:env) { create :env }
7
- let(:run) { script.call env }
8
- subject { run }
9
-
10
- it { should eq env }
11
-
12
- context "run it" do
13
- let(:command) { create :command_from_env, env: env }
14
- subject { env }
15
-
16
- context "should be success" do
17
- before do
18
- stub(env.source).install { [] }
19
- run
20
- end
21
-
22
- its(:before_install) { should_not be_empty }
23
- its(:announce) { should_not be_empty }
24
- its(:install) { should_not be_empty }
25
- its(:cached_directories) { should eq %w{ ~/.rubygems } }
26
- end
27
-
28
- context "when script is empty" do
29
- before do
30
- env.source.script.clear
31
- run
32
- end
33
- its(:script) { should_not be_empty }
34
- end
35
-
36
-
37
- end
38
-
39
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder::Scala do
4
- let(:app) { ->(env) { env } }
5
- let(:script) { described_class.new app }
6
- let(:source) { create :source, name: "scala.yml" }
7
- let(:env) { create :env, source: source }
8
- let(:run) { script.call env }
9
- subject { run }
10
-
11
- it { should eq env }
12
-
13
- context "run it" do
14
- subject { env }
15
-
16
- context "should be success" do
17
- before { run }
18
- its(:announce) { should_not be_empty }
19
- its(:cached_directories) { should eq %w{ ~/.sbt ~/.ivy2 } }
20
- end
21
-
22
- context "when script is empty" do
23
- before do
24
- env.source.script.clear
25
- run
26
- end
27
- its(:script) { should_not be_empty }
28
- end
29
-
30
-
31
- end
32
-
33
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::Builder::ScriptBuilder do
4
- let(:task) { create :task }
5
- let(:source) { create :source }
6
- let(:script) { described_class.new task, source }
7
- subject { script }
8
-
9
- context "just created" do
10
- its(:source) { should eq source }
11
- its(:task) { should eq task }
12
- end
13
-
14
- context "#image" do
15
- subject { script.image }
16
- it { should eq 'one' }
17
- end
18
-
19
- context "vexor" do
20
- it "should avaialble timeout and read_timeout attributes" do
21
- expect(script.vexor.timeout).to eq 10
22
- expect(script.vexor.read_timeout).to eq 20
23
-
24
- simple_source = create :source, name: "simple.yml"
25
- simple_script = described_class.new task, simple_source
26
- expect(simple_script.vexor.timeout).to be_nil
27
- expect(simple_script.vexor.read_timeout).to be_nil
28
- end
29
- end
30
-
31
- context "parallel" do
32
- it "should create parallel jobs" do
33
- matrix = Vx::Builder::MatrixBuilder.new(source)
34
- configurations = matrix.build
35
- configuration = configurations[1]
36
- expect(configuration.parallel).to eq 3
37
- expect(configuration.parallel_job_number).to eq 1
38
- parallel_script = described_class.new task, configuration
39
- content = parallel_script.to_before_script
40
- expect(content).to match("CI_PARALLEL_JOBS\=3")
41
- expect(content).to match("CI_PARALLEL_JOB_NUMBER\=1")
42
- end
43
- end
44
-
45
- context "#to_before_script" do
46
- subject { script.to_before_script }
47
- it { should be }
48
- end
49
-
50
- context "#to_after_script" do
51
- subject { script.to_after_script }
52
- it { should be }
53
- end
54
-
55
- context "#to_script" do
56
- subject { script.to_script }
57
- it { should be }
58
- end
59
-
60
- end