fulmar 1.8.0 → 1.8.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/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +12 -0
- data/Gemfile +10 -0
- data/README.md +2 -0
- data/Rakefile +9 -0
- data/fulmar.gemspec +1 -1
- data/lib/fulmar/domain/service/dependency_service.rb +33 -15
- data/lib/fulmar/domain/service/helper/common_helper.rb +5 -0
- data/lib/fulmar/infrastructure/service/ssh_config_service.rb +4 -1
- data/lib/fulmar/infrastructure/service/transfer/rsync.rb +6 -0
- data/lib/fulmar/service/helper_service.rb +1 -0
- data/lib/fulmar/version.rb +1 -1
- data/spec/lib/fulmar/service/helper_service_spec.rb +51 -0
- data/spec/spec_helper.rb +84 -0
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3a5a9c3fcc0eac8bf2f866acb574bc6e26b3daf
|
4
|
+
data.tar.gz: b37c35df4992fa35e0b98338b8306d87da6b95b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f91dc05ce99316148331c754ef94b195667f77d7a66736fdc335d13101b5b65e04c388252a85dee7065e46f4b88cb9f8180e317a660b9c5955a37f902e40df
|
7
|
+
data.tar.gz: 6d02384db532a177e53890693f17e33764be59bcec4dc19d4479cbda553dcddbc1a75798110809ad72ef0e94ebf5fe5d6708a2db8014295ab13dca50c5e0aac3
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -2,3 +2,13 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in fulmar.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'rake'
|
8
|
+
gem 'rspec'
|
9
|
+
gem 'fakefs', require: 'fakefs/safe'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test, :development do
|
13
|
+
gem 'rubocop', require: false
|
14
|
+
end
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Fulmar
|
2
2
|
|
3
|
+
[](https://travis-ci.org/CORE4/fulmar)
|
4
|
+
|
3
5
|
Fulmar is a task manager for deployments. It is build on top of rake to use its powerful
|
4
6
|
task system and adds host and environment configuration. It provides methods to easily
|
5
7
|
access the current deployment configuration and simplifies especially file transfers and
|
data/Rakefile
ADDED
data/fulmar.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
22
|
|
23
23
|
spec.add_runtime_dependency 'rake', '~>10'
|
24
|
-
spec.add_runtime_dependency 'rugged', '~>
|
24
|
+
spec.add_runtime_dependency 'rugged', '~> 0.23.0'
|
25
25
|
spec.add_runtime_dependency 'mysql2', '~>0.3'
|
26
26
|
spec.add_runtime_dependency 'fulmar-shell', '~>1', '>=1.4.0'
|
27
27
|
spec.add_runtime_dependency 'ruby_wings', '~>0.1', '>=0.1.1'
|
@@ -14,10 +14,18 @@ module Fulmar
|
|
14
14
|
@config.dependencies(env).each_pair do |_key, data|
|
15
15
|
next unless data[:type].blank? || data[:type] == 'git'
|
16
16
|
shell.quiet = true
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
if Dir.exist? "#{data[:path]}/.git"
|
19
|
+
shell.run 'git fetch -q', in: data[:path]
|
20
|
+
else
|
21
|
+
shell.run "git clone #{data[:source]} #{data[:path]} -q"
|
22
|
+
shell.last_error.each do |line|
|
23
|
+
puts line unless line.include? 'already exists and is not an empty directory'
|
24
|
+
end
|
20
25
|
end
|
26
|
+
|
27
|
+
git = Rugged::Repository.new(data[:path])
|
28
|
+
checkout(git, data)
|
21
29
|
end
|
22
30
|
end
|
23
31
|
|
@@ -26,16 +34,7 @@ module Fulmar
|
|
26
34
|
next unless data[:type].blank? || data[:type] == 'git'
|
27
35
|
git = Rugged::Repository.new(data[:path])
|
28
36
|
|
29
|
-
|
30
|
-
if git.branches.select { |b| b.name.split('/').last == data[:ref] }.any?
|
31
|
-
checkout_branch(git, data[:ref])
|
32
|
-
elsif git.tags.map(&:name).include?(data[:ref])
|
33
|
-
git.checkout("refs/tags/#{data[:ref]}")
|
34
|
-
elsif data[:ref].match(/^[a-zA-Z0-9]{40}$/) && git.exists?(data[:ref])
|
35
|
-
git.checkout(data[:ref])
|
36
|
-
else
|
37
|
-
fail "Cannot find ref #{data[:ref]} in repo #{data[:path]}"
|
38
|
-
end
|
37
|
+
checkout(git, data)
|
39
38
|
|
40
39
|
# Pull
|
41
40
|
shell = Fulmar::Infrastructure::Service::ShellService.new data[:path]
|
@@ -47,11 +46,30 @@ module Fulmar
|
|
47
46
|
|
48
47
|
protected
|
49
48
|
|
50
|
-
def
|
49
|
+
def checkout(git, dependency)
|
50
|
+
# Switch to the configured branch/tag/commit
|
51
|
+
if git.branches.select { |b| b.name.split('/').last == dependency[:ref] }.any?
|
52
|
+
checkout_branch(git, dependency[:ref])
|
53
|
+
elsif git.tags.map(&:name).include?(dependency[:ref])
|
54
|
+
git.checkout("refs/tags/#{dependency[:ref]}")
|
55
|
+
elsif dependency[:ref].match(/^[a-zA-Z0-9]{40}$/) && git.exists?(dependency[:ref])
|
56
|
+
git.checkout(dependency[:ref])
|
57
|
+
else
|
58
|
+
fail "Cannot find ref #{dependency[:ref]} in repo #{dependency[:path]}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def checkout_branch(git, branch, remote = 'origin')
|
51
63
|
if git.branches.collect(&:name).include? branch
|
52
64
|
git.checkout(branch)
|
53
65
|
else
|
54
|
-
|
66
|
+
remote_branch = git.branches.find do |b|
|
67
|
+
b.name == "#{remote}/#{branch}"
|
68
|
+
end
|
69
|
+
|
70
|
+
new_branch = git.branches.create(branch, remote_branch.name)
|
71
|
+
new_branch.upstream=(remote_branch)
|
72
|
+
|
55
73
|
git.checkout(new_branch)
|
56
74
|
end
|
57
75
|
end
|
@@ -9,14 +9,17 @@ module Fulmar
|
|
9
9
|
module CommonHelper
|
10
10
|
attr_accessor :environment
|
11
11
|
|
12
|
+
# @return [Hash]
|
12
13
|
def full_configuration
|
13
14
|
configuration.configuration
|
14
15
|
end
|
15
16
|
|
17
|
+
# @return [Fulmar::Domain::Service::ConfigurationService]
|
16
18
|
def configuration
|
17
19
|
(@_config_service ||= Fulmar::Domain::Service::ConfigurationService.instance)
|
18
20
|
end
|
19
21
|
|
22
|
+
# @return [Fulmar::Domain::Model::Project]
|
20
23
|
def project
|
21
24
|
full_configuration[:project]
|
22
25
|
end
|
@@ -27,10 +30,12 @@ module Fulmar
|
|
27
30
|
storage['composer'].execute(command, arguments)
|
28
31
|
end
|
29
32
|
|
33
|
+
# @return [Fulmar::Shell]
|
30
34
|
def local_shell
|
31
35
|
storage['local_shell'] ||= new_shell(configuration[:local_path])
|
32
36
|
end
|
33
37
|
|
38
|
+
# @return [Fulmar::Shell]
|
34
39
|
def remote_shell
|
35
40
|
storage['remote_shell'] ||= new_shell(configuration[:remote_path], configuration.ssh_user_and_host)
|
36
41
|
end
|
@@ -7,6 +7,7 @@ module Fulmar
|
|
7
7
|
class SSHConfigService
|
8
8
|
CONFIG_FILE = "#{ENV['HOME']}/.ssh/config"
|
9
9
|
KNOWN_HOST_FILE = "#{ENV['HOME']}/.ssh/known_hosts"
|
10
|
+
# @todo: Get rid of this layer (Version 2?)
|
10
11
|
CONFIG_MAP = {
|
11
12
|
hostname: 'Hostname',
|
12
13
|
port: 'Port',
|
@@ -14,7 +15,9 @@ module Fulmar
|
|
14
15
|
proxycommand: 'ProxyCommand',
|
15
16
|
checkhostip: 'CheckHostIP',
|
16
17
|
stricthostkeychecking: 'StrictHostKeyChecking',
|
17
|
-
identityfile: 'IdentityFile'
|
18
|
+
identityfile: 'IdentityFile',
|
19
|
+
userknownhostfile: 'UserKnownHostsFile',
|
20
|
+
loglevel: 'LogLevel'
|
18
21
|
}
|
19
22
|
|
20
23
|
def initialize(config)
|
@@ -48,6 +48,12 @@ module Fulmar
|
|
48
48
|
"rsync #{rsync_command_options.join(' ')} '#{from}/' '#{to}'"
|
49
49
|
end
|
50
50
|
|
51
|
+
# Gets the absolute release path
|
52
|
+
# @return [String] the release directory
|
53
|
+
def release_path
|
54
|
+
@config[:remote_path]
|
55
|
+
end
|
56
|
+
|
51
57
|
protected
|
52
58
|
|
53
59
|
# Assembles all rsync command line parameters from the configuration options
|
data/lib/fulmar/version.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'fulmar/service/helper_service'
|
2
|
+
|
3
|
+
describe Fulmar::Service::HelperService, fakefs: true do
|
4
|
+
BASE_PATH = '/srv/fulmar/service/helper_service_spec'
|
5
|
+
|
6
|
+
def stub_test_files(base_path)
|
7
|
+
4.times do |i|
|
8
|
+
path = ''
|
9
|
+
|
10
|
+
i.times do |n|
|
11
|
+
path << "/folder_d#{(n + 1)}"
|
12
|
+
end
|
13
|
+
|
14
|
+
FileUtils.mkdir_p("#{base_path}#{path}")
|
15
|
+
|
16
|
+
File.open("#{base_path}#{path}/file_d#{(i)}", 'w') do |f|
|
17
|
+
f.write 'TEST CONTENT'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
stub_test_files(BASE_PATH)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#reverse_file_lookup' do
|
27
|
+
it 'should return the path to the file' do
|
28
|
+
file = described_class.reverse_file_lookup("#{BASE_PATH}/folder_d1/folder_d2/folder_d3", 'file_d1')
|
29
|
+
expect(file).to eq("#{BASE_PATH}/folder_d1/file_d1")
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should return the path to the file' do
|
33
|
+
file = described_class.reverse_file_lookup("#{BASE_PATH}/folder_d1/folder_d2", 'file_d2')
|
34
|
+
expect(file).to eq("#{BASE_PATH}/folder_d1/folder_d2/file_d2")
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# The file is located in a child directory of the given path
|
39
|
+
it 'should return false' do
|
40
|
+
file = described_class.reverse_file_lookup("#{BASE_PATH}/folder_d1/folder_d2/folder_d3", 'file_d4')
|
41
|
+
expect(file).to eq(false)
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# The file does not exist
|
46
|
+
it 'should return false' do
|
47
|
+
file = described_class.reverse_file_lookup("#{BASE_PATH}/folder_d1/folder_d2", 'file_d9')
|
48
|
+
expect(file).to eq(false)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'fakefs/spec_helpers'
|
2
|
+
|
3
|
+
Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.include FakeFS::SpecHelpers, fakefs: true
|
7
|
+
|
8
|
+
# rspec-expectations config goes here. You can use an alternate
|
9
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
10
|
+
# assertions if you prefer.
|
11
|
+
config.expect_with :rspec do |expectations|
|
12
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
13
|
+
# and `failure_message` of custom matchers include text for helper methods
|
14
|
+
# defined using `chain`, e.g.:
|
15
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
16
|
+
# # => "be bigger than 2 and smaller than 4"
|
17
|
+
# ...rather than:
|
18
|
+
# # => "be bigger than 2"
|
19
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
20
|
+
end
|
21
|
+
|
22
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
23
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
24
|
+
config.mock_with :rspec do |mocks|
|
25
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
26
|
+
# a real object. This is generally recommended, and will default to
|
27
|
+
# `true` in RSpec 4.
|
28
|
+
mocks.verify_partial_doubles = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# The settings below are suggested to provide a good initial experience
|
32
|
+
# with RSpec, but feel free to customize to your heart's content.
|
33
|
+
=begin
|
34
|
+
# These two settings work together to allow you to limit a spec run
|
35
|
+
# to individual examples or groups you care about by tagging them with
|
36
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
37
|
+
# get run.
|
38
|
+
config.filter_run :focus
|
39
|
+
config.run_all_when_everything_filtered = true
|
40
|
+
|
41
|
+
# Allows RSpec to persist some state between runs in order to support
|
42
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
43
|
+
# you configure your source control system to ignore this file.
|
44
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
45
|
+
|
46
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
47
|
+
# recommended. For more details, see:
|
48
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
49
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
50
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
51
|
+
config.disable_monkey_patching!
|
52
|
+
|
53
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
54
|
+
# be too noisy due to issues in dependencies.
|
55
|
+
config.warnings = true
|
56
|
+
|
57
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
58
|
+
# file, and it's useful to allow more verbose output when running an
|
59
|
+
# individual spec file.
|
60
|
+
if config.files_to_run.one?
|
61
|
+
# Use the documentation formatter for detailed output,
|
62
|
+
# unless a formatter has already been configured
|
63
|
+
# (e.g. via a command-line flag).
|
64
|
+
config.default_formatter = 'doc'
|
65
|
+
end
|
66
|
+
|
67
|
+
# Print the 10 slowest examples and example groups at the
|
68
|
+
# end of the spec run, to help surface which specs are running
|
69
|
+
# particularly slow.
|
70
|
+
config.profile_examples = 10
|
71
|
+
|
72
|
+
# Run specs in random order to surface order dependencies. If you find an
|
73
|
+
# order dependency and want to debug it, you can fix the order by providing
|
74
|
+
# the seed, which is printed after each run.
|
75
|
+
# --seed 1234
|
76
|
+
config.order = :random
|
77
|
+
|
78
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
79
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
80
|
+
# test failures related to randomization by passing the same `--seed` value
|
81
|
+
# as the one that triggered the failure.
|
82
|
+
Kernel.srand config.seed
|
83
|
+
=end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fulmar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Siegl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -45,20 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
49
|
-
- - "<="
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: 0.22.1
|
48
|
+
version: 0.23.0
|
52
49
|
type: :runtime
|
53
50
|
prerelease: false
|
54
51
|
version_requirements: !ruby/object:Gem::Requirement
|
55
52
|
requirements:
|
56
53
|
- - "~>"
|
57
54
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
59
|
-
- - "<="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.22.1
|
55
|
+
version: 0.23.0
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
57
|
name: mysql2
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,10 +131,14 @@ extensions: []
|
|
137
131
|
extra_rdoc_files: []
|
138
132
|
files:
|
139
133
|
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".travis.yml"
|
140
137
|
- CODE_OF_CONDUCT.md
|
141
138
|
- Gemfile
|
142
139
|
- LICENSE.txt
|
143
140
|
- README.md
|
141
|
+
- Rakefile
|
144
142
|
- bin/fulmar
|
145
143
|
- fulmar.gemspec
|
146
144
|
- lib/fulmar/domain/model/project.rb
|
@@ -180,6 +178,8 @@ files:
|
|
180
178
|
- lib/fulmar/service/logger_service.rb
|
181
179
|
- lib/fulmar/task_manager.rb
|
182
180
|
- lib/fulmar/version.rb
|
181
|
+
- spec/lib/fulmar/service/helper_service_spec.rb
|
182
|
+
- spec/spec_helper.rb
|
183
183
|
- test/rsync_with_versions.rb
|
184
184
|
homepage: https://github.com/CORE4/fulmar
|
185
185
|
licenses:
|
@@ -206,4 +206,6 @@ signing_key:
|
|
206
206
|
specification_version: 4
|
207
207
|
summary: A deployment task manager.
|
208
208
|
test_files:
|
209
|
+
- spec/lib/fulmar/service/helper_service_spec.rb
|
210
|
+
- spec/spec_helper.rb
|
209
211
|
- test/rsync_with_versions.rb
|