capsulecd 1.0.0 → 1.0.1
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/capsulecd/base/configuration.rb +10 -10
- data/lib/capsulecd/base/engine.rb +5 -5
- data/lib/capsulecd/base/runner/circleci.rb +30 -30
- data/lib/capsulecd/error.rb +0 -8
- data/lib/capsulecd/ruby/ruby_engine.rb +6 -3
- data/lib/capsulecd/ruby/ruby_helper.rb +8 -1
- data/lib/capsulecd/version.rb +1 -1
- data/spec/lib/capsulecd/chef/chef_engine_spec.rb +16 -0
- data/spec/lib/capsulecd/node/node_engine_spec.rb +17 -0
- data/spec/lib/capsulecd/python/python_engine_spec.rb +17 -0
- data/spec/lib/capsulecd/ruby/ruby_engine_spec.rb +16 -0
- data/spec/lib/capsulecd/ruby/ruby_helper_spec.rb +51 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 846c1711f0ae0a45b11b3be3a3475b4ec7435d26
|
4
|
+
data.tar.gz: 766b95a987357b57d02ac101e5333c72c1db1c57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78d44d3b319f7c3b6c67ed766836a0b4cc2679a1b85df54d0100052977255979fd9dbfde4c85799d4e2ec0e6674df9fef29b4cc871bc99e2ddc7f442d90a4129
|
7
|
+
data.tar.gz: 4d3fef2e36f78caa58f66134311eae35c8911ddbb1d850db1409c29d4faec4d4920d640a7f5dc7395d281fcb7eed41fe1218b9cfde36550e6e79eb463ed58a94
|
@@ -96,20 +96,20 @@ module CapsuleCD
|
|
96
96
|
|
97
97
|
|
98
98
|
def populate_runner_overrides
|
99
|
-
@runner = :circleci unless ENV['CIRCLECI'].to_s.empty?
|
99
|
+
# @runner = :circleci unless ENV['CIRCLECI'].to_s.empty?
|
100
100
|
populate_runner
|
101
101
|
end
|
102
102
|
|
103
103
|
def populate_runner
|
104
|
-
if (@runner == :circleci)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
104
|
+
# if (@runner == :circleci)
|
105
|
+
# # parse the PR# from the environment variable, eg. https://github.com/AnalogJ/cookbook_analogj_test/pull/9
|
106
|
+
# @runner_pull_request ||= File.basename(URI.parse(ENV['CI_PULL_REQUEST']).path).to_i # => baz
|
107
|
+
# @runner_sha ||= ENV['CIRCLE_SHA1']
|
108
|
+
# @runner_branch ||= ENV['CIRCLE_BRANCH']
|
109
|
+
# @runner_clone_url ||= 'https://github.com/' + ENV['CIRCLE_PROJECT_USERNAME'] + '/' + ENV['CIRCLE_PROJECT_REPONAME'] + '.git'
|
110
|
+
# @runner_repo_name ||= ENV['CIRCLE_PROJECT_REPONAME']
|
111
|
+
# @runner_repo_full_name ||= ENV['CIRCLE_PROJECT_USERNAME'] + '/' + ENV['CIRCLE_PROJECT_REPONAME']
|
112
|
+
# end
|
113
113
|
end
|
114
114
|
|
115
115
|
def populate_env_overrides
|
@@ -14,12 +14,12 @@ module CapsuleCD
|
|
14
14
|
fail CapsuleCD::Error::SourceUnspecifiedError, 'No source defined.'
|
15
15
|
end
|
16
16
|
|
17
|
-
if @config.runner == :circleci
|
18
|
-
|
19
|
-
|
20
|
-
else
|
17
|
+
# if @config.runner == :circleci
|
18
|
+
# require_relative 'runner/circleci'
|
19
|
+
# self.class.send(:include, CapsuleCD::Runner::Circleci)
|
20
|
+
# else
|
21
21
|
self.class.send(:include, CapsuleCD::Runner::Default)
|
22
|
-
end
|
22
|
+
# end
|
23
23
|
end
|
24
24
|
|
25
25
|
def start
|
@@ -2,36 +2,36 @@ require 'uri'
|
|
2
2
|
module CapsuleCD
|
3
3
|
module Runner
|
4
4
|
module Circleci
|
5
|
-
def runner_retrieve_payload(_options)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
5
|
+
# def runner_retrieve_payload(_options)
|
6
|
+
# puts 'circleci runner_retrieve_payload'
|
7
|
+
#
|
8
|
+
# # circleci only works with github, no need to parse @options[:source]
|
9
|
+
# # here are the environmental variables we need to handle:
|
10
|
+
# # https://circleci.com/docs/environment-variables
|
11
|
+
#
|
12
|
+
# if @config.runner_pull_request.to_s.empty?
|
13
|
+
# puts 'This is not a pull request. No automatic continuous deployment processing required. Continuous Integration testing will continue.'
|
14
|
+
# @runner_is_pullrequest = false
|
15
|
+
# # make this as similar to the pull request payload as possible.
|
16
|
+
# payload = {
|
17
|
+
# 'head' => {
|
18
|
+
# 'sha' => @config.runner_sha,
|
19
|
+
# 'ref' => @config.runner_branch,
|
20
|
+
# 'repo' => {
|
21
|
+
# 'clone_url' => @config.runner_clone_url,
|
22
|
+
# 'name' => @config.runner_repo_name,
|
23
|
+
# 'full_name' => @config.runner_repo_full_name
|
24
|
+
# }
|
25
|
+
# }
|
26
|
+
# }
|
27
|
+
#
|
28
|
+
# payload
|
29
|
+
# else
|
30
|
+
# @runner_is_pullrequest = true
|
31
|
+
# pull_request_number = @config.runner_pull_request.to_i
|
32
|
+
# @source_client.pull_request(@config.runner_repo_full_name, pull_request_number)
|
33
|
+
# end
|
34
|
+
# end
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/capsulecd/error.rb
CHANGED
@@ -39,13 +39,5 @@ module CapsuleCD
|
|
39
39
|
# Raised when an error occurs while uploading package.
|
40
40
|
class ReleasePackageError < BaseError; end
|
41
41
|
|
42
|
-
# Gracefully handle any errors raised by CapsuleCD, and exit with a failure
|
43
|
-
# status code.
|
44
|
-
# @param [CapsuleCD::Error::BaseError] ex
|
45
|
-
def self.handle_exception(ex)
|
46
|
-
puts ex.message
|
47
|
-
# Configuration.output.puts_red(ex.message)
|
48
|
-
exit false
|
49
|
-
end
|
50
42
|
end
|
51
43
|
end
|
@@ -11,10 +11,10 @@ module CapsuleCD
|
|
11
11
|
super
|
12
12
|
gemspec_path = CapsuleCD::Ruby::RubyHelper.get_gemspec_path(@source_git_local_path)
|
13
13
|
|
14
|
-
# check for
|
15
|
-
gemspec_data = CapsuleCD::Ruby::RubyHelper.
|
14
|
+
# check for required VERSION file
|
15
|
+
gemspec_data = CapsuleCD::Ruby::RubyHelper.get_gemspec_data(@source_git_local_path)
|
16
16
|
|
17
|
-
if !
|
17
|
+
if !File.exist?(CapsuleCD::Ruby::RubyHelper.version_filepath(@source_git_local_path, gemspec_data.name))
|
18
18
|
fail CapsuleCD::Error::BuildPackageInvalid, 'version.rb file is required to process Ruby gem'
|
19
19
|
end
|
20
20
|
|
@@ -68,6 +68,9 @@ module CapsuleCD
|
|
68
68
|
unless external.value.success?
|
69
69
|
fail CapsuleCD::Error::BuildPackageFailed, 'gem build failed. Check gemspec file and dependencies'
|
70
70
|
end
|
71
|
+
unless File.exist?(@source_git_local_path + "/#{gemspec_data.name}-#{next_version.to_s}.gem")
|
72
|
+
fail CapsuleCD::Error::BuildPackageFailed, "gem build failed. #{gemspec_data.name}-#{next_version.to_s}.gem not found"
|
73
|
+
end
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
@@ -27,6 +27,9 @@ module CapsuleCD
|
|
27
27
|
self.load_gemspec_data(self.get_gemspec_path(repo_path))
|
28
28
|
end
|
29
29
|
|
30
|
+
##################################################################################################################
|
31
|
+
# protected/private methods.
|
32
|
+
|
30
33
|
# since the Gem::Specification class is basically eval'ing the gemspec file, and the gemspec file is doing a require
|
31
34
|
# to load the version.rb file, the version.rb file is cached in memory. We're going to try to get around that issue
|
32
35
|
# by parsing the gemspec file in a forked process.
|
@@ -49,9 +52,13 @@ module CapsuleCD
|
|
49
52
|
end
|
50
53
|
|
51
54
|
def self.load_gemspec_data(gemspec_path)
|
52
|
-
|
55
|
+
gemspec_data = self.execute_in_child do
|
53
56
|
Gem::Specification::load(gemspec_path)
|
54
57
|
end
|
58
|
+
if !gemspec_data
|
59
|
+
fail CapsuleCD::Error::BuildPackageInvalid, '*.gemspec could not be parsed.'
|
60
|
+
end
|
61
|
+
return gemspec_data
|
55
62
|
end
|
56
63
|
|
57
64
|
|
data/lib/capsulecd/version.rb
CHANGED
@@ -58,6 +58,22 @@ describe 'CapsuleCD::Chef::ChefEngine', :chef do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
describe '#release_step' do
|
62
|
+
let(:engine) do
|
63
|
+
require 'capsulecd/chef/chef_engine'
|
64
|
+
CapsuleCD::Chef::ChefEngine.new(source: :github,
|
65
|
+
package_type: :chef)
|
66
|
+
end
|
67
|
+
let(:config_double) { CapsuleCD::Configuration.new }
|
68
|
+
describe 'when no chef_supermarket_username or chef_supermarket_key provided' do
|
69
|
+
it 'should raise an error' do
|
70
|
+
engine.instance_variable_set(:@config, config_double)
|
71
|
+
|
72
|
+
expect{engine.release_step}.to raise_error(CapsuleCD::Error::ReleaseCredentialsMissing)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
61
77
|
describe 'integration tests' do
|
62
78
|
let(:engine) do
|
63
79
|
require 'capsulecd/chef/chef_engine'
|
@@ -57,6 +57,23 @@ describe 'CapsuleCD::Node::NodeEngine', :node do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
describe '#release_step' do
|
61
|
+
let(:engine) do
|
62
|
+
require 'capsulecd/node/node_engine'
|
63
|
+
CapsuleCD::Node::NodeEngine.new(source: :github,
|
64
|
+
package_type: :node)
|
65
|
+
end
|
66
|
+
let(:config_double) { CapsuleCD::Configuration.new }
|
67
|
+
describe 'when no npm_auth_token provided' do
|
68
|
+
it 'should raise an error' do
|
69
|
+
engine.instance_variable_set(:@config, config_double)
|
70
|
+
|
71
|
+
expect{engine.release_step}.to raise_error(CapsuleCD::Error::ReleaseCredentialsMissing)
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
60
77
|
describe 'integration tests' do
|
61
78
|
let(:engine) do
|
62
79
|
require 'capsulecd/node/node_engine'
|
@@ -63,6 +63,23 @@ describe 'CapsuleCD::Python::PythonEngine', :python do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
describe '#release_step' do
|
67
|
+
let(:engine) do
|
68
|
+
require 'capsulecd/python/python_engine'
|
69
|
+
CapsuleCD::Python::PythonEngine.new(source: :github,
|
70
|
+
package_type: :python)
|
71
|
+
end
|
72
|
+
let(:config_double) { CapsuleCD::Configuration.new }
|
73
|
+
describe 'when no pypi_username or no pypi_password provided' do
|
74
|
+
it 'should raise an error' do
|
75
|
+
engine.instance_variable_set(:@config, config_double)
|
76
|
+
|
77
|
+
expect{engine.release_step}.to raise_error(CapsuleCD::Error::ReleaseCredentialsMissing)
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
66
83
|
describe 'integration tests' do
|
67
84
|
let(:engine) do
|
68
85
|
require 'capsulecd/python/python_engine'
|
@@ -72,6 +72,22 @@ describe 'CapsuleCD::Ruby::RubyEngine', :ruby do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
describe '#release_step' do
|
76
|
+
let(:engine) do
|
77
|
+
require 'capsulecd/ruby/ruby_engine'
|
78
|
+
CapsuleCD::Ruby::RubyEngine.new(source: :github,
|
79
|
+
package_type: :ruby)
|
80
|
+
end
|
81
|
+
let(:config_double) { CapsuleCD::Configuration.new }
|
82
|
+
describe 'when no rubygems_api_key provided' do
|
83
|
+
it 'should raise an error' do
|
84
|
+
engine.instance_variable_set(:@config, config_double)
|
85
|
+
|
86
|
+
expect{engine.release_step}.to raise_error(CapsuleCD::Error::ReleaseCredentialsMissing)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
75
91
|
describe 'integration tests' do
|
76
92
|
let(:engine) do
|
77
93
|
require 'capsulecd/ruby/ruby_engine'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'CapsuleCD::Ruby::RubyHelper', :ruby do
|
4
|
+
subject{
|
5
|
+
CapsuleCD::Ruby::RubyHelper
|
6
|
+
}
|
7
|
+
describe '#version_filepath' do
|
8
|
+
it 'default should generate the correct path to version.rb' do
|
9
|
+
expect(subject.version_filepath('/tmp','capsulecd')).to eql('/tmp/lib/capsulecd/version.rb')
|
10
|
+
end
|
11
|
+
it 'with custom version filename should generate the correct path' do
|
12
|
+
expect(subject.version_filepath('/tmp','capsulecd', 'VERSION.rb')).to eql('/tmp/lib/capsulecd/VERSION.rb')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#get_gemspec_path' do
|
17
|
+
describe 'without a gemspec file' do
|
18
|
+
it 'should raise an error' do
|
19
|
+
expect{subject.get_gemspec_path(test_directory)}.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'with a valid gemspec file' do
|
24
|
+
it 'should generate correct gemspec path' do
|
25
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
26
|
+
|
27
|
+
expect(subject.get_gemspec_path(test_directory)).to eql(test_directory + '/gem_analogj_test.gemspec')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#get_gemspec_data' do
|
33
|
+
it 'should parse gemspec data' do
|
34
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
35
|
+
gemspec_data = subject.get_gemspec_data(test_directory)
|
36
|
+
expect(gemspec_data.name).to eql('gem_analogj_test')
|
37
|
+
expect(gemspec_data.version.to_s).to eql('0.1.3')
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'with an invalid gemspec file' do
|
41
|
+
it 'should raise an error' do
|
42
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
43
|
+
FileUtils.rm(test_directory + '/lib/gem_analogj_test/version.rb')
|
44
|
+
|
45
|
+
expect{subject.get_gemspec_data(test_directory)}.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capsulecd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Kulatunga (AnalogJ)
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- spec/lib/capsulecd/node/node_engine_spec.rb
|
188
188
|
- spec/lib/capsulecd/python/python_engine_spec.rb
|
189
189
|
- spec/lib/capsulecd/ruby/ruby_engine_spec.rb
|
190
|
+
- spec/lib/capsulecd/ruby/ruby_helper_spec.rb
|
190
191
|
- spec/spec_helper.rb
|
191
192
|
- spec/support/file_system.rb
|
192
193
|
- spec/support/package_types.rb
|
@@ -276,6 +277,7 @@ test_files:
|
|
276
277
|
- spec/lib/capsulecd/node/node_engine_spec.rb
|
277
278
|
- spec/lib/capsulecd/python/python_engine_spec.rb
|
278
279
|
- spec/lib/capsulecd/ruby/ruby_engine_spec.rb
|
280
|
+
- spec/lib/capsulecd/ruby/ruby_helper_spec.rb
|
279
281
|
- spec/spec_helper.rb
|
280
282
|
- spec/support/file_system.rb
|
281
283
|
- spec/support/package_types.rb
|