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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f04d4731464414b121f1418f4fada916c797e3b
4
- data.tar.gz: 1d7c01fe5104d38d215cfb806245943376d8d39a
3
+ metadata.gz: 2fb1d69bf511942769e1f87e6bd993061f05307e
4
+ data.tar.gz: b2aa4557949a81e0a62e98f4f870facb09c9f657
5
5
  SHA512:
6
- metadata.gz: 54df9e7aa3c473ae2564e07b4f8bf4acd6917d98c46bdd551bdbddda5c88b22bd2d5501891f66a0e8f916f84b2763336e85e6f0e862ff16594bdcaeb51c0bbb6
7
- data.tar.gz: 527e9b0e283e7976ed50e04b7dede18412345711165f9bfbb9098624c823c282b31a507e3a5d68586e0693d816081152b440a8ae368afb283a2f1fcb268c2098
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.after_success << "echo"
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.after_success << cmd
25
+ env.after_script << cmd
26
26
  end
27
- env.after_success << "echo"
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
- if b = env.task.branch
15
- env.init << "export CI_BRANCH=#{b}"
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
@@ -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,
@@ -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(name, src, sha, options = {})
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
 
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module Builder
3
- VERSION = "0.0.29"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ describe Vx::Builder::Script::Artifacts do
12
12
 
13
13
  it "should create upload script" do
14
14
  subject
15
- expect(env.after_success).to_not be_empty
15
+ expect(env.after_script).to_not be_empty
16
16
  end
17
17
 
18
18
  end
@@ -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
- let(:name) { should eq 'name' }
20
- let(:source) { should eq 'source' }
21
- let(:sha) { should eq 'sha' }
22
- let(:deploy_key) { should eq 'deploy_key' }
23
- let(:pull_request_id) { should eq '1' }
24
- let(:cache_url_prefix){ should eq 'cache_url' }
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
@@ -8,13 +8,16 @@ def create(name, options = {})
8
8
  when :task
9
9
  msg = create(:message)
10
10
  Vx::Builder::Task.new(
11
- 'name',
12
- msg.src,
13
- msg.sha,
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),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.29
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky