vx-builder 0.0.29 → 0.1.0
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.
- checksums.yaml +4 -4
- data/lib/vx/builder/script/artifacts.rb +3 -3
- data/lib/vx/builder/script/env.rb +14 -3
- data/lib/vx/builder/script.rb +4 -0
- data/lib/vx/builder/task.rb +8 -6
- data/lib/vx/builder/version.rb +1 -1
- data/spec/lib/builder/script/artifacts_spec.rb +1 -1
- data/spec/lib/builder/task_spec.rb +9 -17
- data/spec/support/create.rb +9 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fb1d69bf511942769e1f87e6bd993061f05307e
|
4
|
+
data.tar.gz: b2aa4557949a81e0a62e98f4f870facb09c9f657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8aa727add24b3208c07ccb0db15eadfff5675049e03063b58eb7ede61903102aadc35ead9d076c0f965197a383b5b0aa2ea7466756d13e34f68f6e6253efa51
|
7
|
+
data.tar.gz: 8bb24fcbe8f1b88b65bffb1c29fa1612ece2b492bd038f80aaa84a548377a9044c020f744f9efd41d993c6c4ea762fbfdb4920c3b2c913109dcfb4846170e394
|
@@ -12,7 +12,7 @@ module Vx
|
|
12
12
|
rs = app.call env
|
13
13
|
|
14
14
|
if enabled?(env)
|
15
|
-
env.
|
15
|
+
env.after_script << "echo"
|
16
16
|
env.source.artifacts.attributes.map{|a| compile(a) }.each do |artifact|
|
17
17
|
find = FIND % artifact
|
18
18
|
prefix = env.task.artifacts_url_prefix
|
@@ -22,9 +22,9 @@ module Vx
|
|
22
22
|
curl -s -S -X PUT -T $i #{prefix}/$i > /dev/null
|
23
23
|
done
|
24
24
|
}
|
25
|
-
env.
|
25
|
+
env.after_script << cmd
|
26
26
|
end
|
27
|
-
env.
|
27
|
+
env.after_script << "echo"
|
28
28
|
end
|
29
29
|
|
30
30
|
rs
|
@@ -10,10 +10,10 @@ module Vx
|
|
10
10
|
env.init << "set -e"
|
11
11
|
env.init << "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
12
12
|
env.init << 'export LC_ALL=en_US.UTF8'
|
13
|
+
env.init << 'export DEBIAN_FRONTEND=noninteractive'
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
15
|
+
export_vars(env, env.init)
|
16
|
+
export_vars(env, env.after_script_init)
|
17
17
|
|
18
18
|
env.source.env.global.each do |e|
|
19
19
|
env.init << trace_sh_command("export #{e}")
|
@@ -21,6 +21,17 @@ module Vx
|
|
21
21
|
app.call(env)
|
22
22
|
end
|
23
23
|
|
24
|
+
private
|
25
|
+
|
26
|
+
def export_vars(env, collection)
|
27
|
+
collection << "export CI_JOB_ID=#{env.task.job_id}"
|
28
|
+
collection << "export CI_BUILD_ID=#{env.task.build_id}"
|
29
|
+
|
30
|
+
if b = env.task.branch
|
31
|
+
collection << "export CI_BRANCH=#{b}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
24
35
|
end
|
25
36
|
end
|
26
37
|
end
|
data/lib/vx/builder/script.rb
CHANGED
@@ -63,6 +63,8 @@ module Vx
|
|
63
63
|
|
64
64
|
def to_after_script
|
65
65
|
a = []
|
66
|
+
a << "\n# after script init"
|
67
|
+
a += env.after_script_init
|
66
68
|
a << "\n# after script"
|
67
69
|
a += env.after_script
|
68
70
|
a.join("\n")
|
@@ -102,6 +104,8 @@ module Vx
|
|
102
104
|
before_script: [],
|
103
105
|
script: [],
|
104
106
|
after_success: [],
|
107
|
+
|
108
|
+
after_script_init: [],
|
105
109
|
after_script: [],
|
106
110
|
|
107
111
|
source: source,
|
data/lib/vx/builder/task.rb
CHANGED
@@ -3,12 +3,14 @@ module Vx
|
|
3
3
|
class Task
|
4
4
|
|
5
5
|
attr_reader :name, :src, :sha, :deploy_key, :branch, :pull_request_id,
|
6
|
-
:cache_url_prefix, :artifacts_url_prefix
|
6
|
+
:cache_url_prefix, :artifacts_url_prefix, :job_id, :build_id
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@name = name
|
10
|
-
@src = src
|
11
|
-
@sha = sha
|
8
|
+
def initialize(options = {})
|
9
|
+
@name = options[:name]
|
10
|
+
@src = options[:src]
|
11
|
+
@sha = options[:sha]
|
12
|
+
@job_id = options[:job_id]
|
13
|
+
@build_id = options[:build_id]
|
12
14
|
@deploy_key = options[:deploy_key]
|
13
15
|
@branch = options[:branch]
|
14
16
|
@pull_request_id = options[:pull_request_id]
|
@@ -21,7 +23,7 @@ module Vx
|
|
21
23
|
private
|
22
24
|
|
23
25
|
def validate!
|
24
|
-
(name && src && sha && deploy_key && branch) or
|
26
|
+
(name && src && sha && deploy_key && branch && job_id && build_id) or
|
25
27
|
raise(MissingKeys)
|
26
28
|
end
|
27
29
|
|
data/lib/vx/builder/version.rb
CHANGED
@@ -2,26 +2,18 @@ require 'spec_helper'
|
|
2
2
|
require 'vx/common'
|
3
3
|
|
4
4
|
describe Vx::Builder::Task do
|
5
|
-
let(:task) {
|
6
|
-
described_class.new(
|
7
|
-
'name',
|
8
|
-
'source',
|
9
|
-
'sha',
|
10
|
-
deploy_key: 'deploy_key',
|
11
|
-
pull_request_id: '1',
|
12
|
-
cache_url_prefix: 'cache_url'
|
13
|
-
)
|
14
|
-
}
|
15
|
-
|
5
|
+
let(:task) { create :task, pull_request_id: 1 }
|
16
6
|
subject { task }
|
17
7
|
|
18
8
|
context "just created" do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
9
|
+
its(:name) { should eq 'name' }
|
10
|
+
its(:sha) { should eq 'b665f90239563c030f1b280a434b3d84daeda1bd' }
|
11
|
+
its(:deploy_key) { should be }
|
12
|
+
its(:cache_url_prefix){ should eq 'http://example.com' }
|
13
|
+
its(:artifacts_url_prefix){ should eq 'http://example.com' }
|
14
|
+
its(:job_id) { should eq 1 }
|
15
|
+
its(:build_id) { should eq 12 }
|
16
|
+
its(:pull_request_id) { should eq 1 }
|
25
17
|
end
|
26
18
|
|
27
19
|
end
|
data/spec/support/create.rb
CHANGED
@@ -8,13 +8,16 @@ def create(name, options = {})
|
|
8
8
|
when :task
|
9
9
|
msg = create(:message)
|
10
10
|
Vx::Builder::Task.new(
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
job_id: 1,
|
12
|
+
build_id: 12,
|
13
|
+
name: 'name',
|
14
|
+
src: msg.src,
|
15
|
+
sha: msg.sha,
|
14
16
|
deploy_key: msg.deploy_key,
|
15
17
|
branch: msg.branch,
|
16
|
-
cache_url_prefix: "http://example.com
|
17
|
-
artifacts_url_prefix: "http://example.com
|
18
|
+
cache_url_prefix: "http://example.com",
|
19
|
+
artifacts_url_prefix: "http://example.com",
|
20
|
+
pull_request_id: options[:pull_request_id]
|
18
21
|
)
|
19
22
|
|
20
23
|
when :source
|
@@ -30,6 +33,7 @@ def create(name, options = {})
|
|
30
33
|
before_script: [],
|
31
34
|
script: [],
|
32
35
|
after_script: [],
|
36
|
+
after_script_init: [],
|
33
37
|
source: options[:source] || create(:source),
|
34
38
|
after_success: [],
|
35
39
|
task: create(:task),
|