depengine 3.0.20 → 3.0.21
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/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +52 -0
- data/Gemfile.lock +16 -1
- data/Rakefile +9 -9
- data/bin/cdb_crypt +2 -2
- data/bin/de +1 -1
- data/bin/depengine +2 -2
- data/bin/spec_setup +2 -2
- data/depengine.gemspec +22 -21
- data/lib/depengine/asserter/url.rb +8 -9
- data/lib/depengine/cli.rb +12 -14
- data/lib/depengine/dsl/cdb.rb +16 -17
- data/lib/depengine/dsl/deployment.rb +42 -50
- data/lib/depengine/dsl/dweb.rb +10 -11
- data/lib/depengine/dsl/executor.rb +5 -5
- data/lib/depengine/dsl/fileops.rb +3 -4
- data/lib/depengine/dsl/helper.rb +26 -28
- data/lib/depengine/dsl/iis.rb +21 -24
- data/lib/depengine/dsl/patch.rb +22 -46
- data/lib/depengine/dsl/publisher.rb +14 -14
- data/lib/depengine/dsl/remote.rb +11 -13
- data/lib/depengine/dsl/repository.rb +19 -21
- data/lib/depengine/dsl/template.rb +19 -19
- data/lib/depengine/dsl/zip.rb +24 -24
- data/lib/depengine/helper/cli_helper.rb +9 -11
- data/lib/depengine/helper/hudson.rb +15 -19
- data/lib/depengine/helper/mail.rb +19 -25
- data/lib/depengine/helper/properties.rb +33 -52
- data/lib/depengine/helper/smb.rb +19 -25
- data/lib/depengine/helper/validations.rb +7 -7
- data/lib/depengine/helper/yaml.rb +7 -9
- data/lib/depengine/log/log.rb +3 -6
- data/lib/depengine/processor/erb_template.rb +42 -47
- data/lib/depengine/processor/fileops.rb +39 -48
- data/lib/depengine/processor/local_execute.rb +6 -4
- data/lib/depengine/processor/properties.rb +34 -56
- data/lib/depengine/processor/sed.rb +8 -12
- data/lib/depengine/processor/tags.rb +9 -10
- data/lib/depengine/processor/template.rb +27 -32
- data/lib/depengine/processor/zip.rb +16 -20
- data/lib/depengine/provider/cdb.rb +64 -71
- data/lib/depengine/provider/cdb_filesystem.rb +18 -26
- data/lib/depengine/provider/git.rb +37 -42
- data/lib/depengine/provider/repository.rb +161 -176
- data/lib/depengine/publisher/dweb.rb +74 -90
- data/lib/depengine/publisher/iis.rb +23 -30
- data/lib/depengine/publisher/rsync.rb +14 -17
- data/lib/depengine/publisher/samba.rb +12 -14
- data/lib/depengine/publisher/sftp.rb +51 -61
- data/lib/depengine/publisher/ssh.rb +19 -22
- data/lib/depengine/publisher/tomcat.rb +19 -21
- data/lib/depengine/reporter/cdb.rb +2 -3
- data/lib/depengine/version.rb +1 -1
- data/lib/depengine.rb +1 -2
- data/spec/cdb_spec.rb +8 -10
- data/spec/demo_recipe/recipes/demo.rb +10 -10
- data/spec/deployhelper_spec.rb +20 -21
- data/spec/fileops_spec.rb +11 -12
- data/spec/git_spec.rb +8 -4
- data/spec/helper_spec.rb +75 -75
- data/spec/junit.rb +47 -49
- data/spec/local_execute.rb +7 -7
- data/spec/log_spec.rb +17 -18
- data/spec/properties_spec.rb +13 -15
- data/spec/recipe_spec.rb +15 -16
- data/spec/repository_spec.rb +20 -20
- data/spec/ssh_spec.rb +18 -19
- data/spec/template_spec.rb +30 -30
- data/spec/zip_spec.rb +7 -7
- metadata +18 -2
@@ -4,104 +4,94 @@ module Publisher
|
|
4
4
|
attr_accessor :remote_user
|
5
5
|
attr_accessor :ssh_key_file
|
6
6
|
|
7
|
-
def copy(source, target,
|
8
|
-
Helper.validates_presence_of remote_host,
|
9
|
-
Helper.validates_presence_of remote_user,
|
10
|
-
Helper.validates_presence_of ssh_key_file,
|
11
|
-
|
12
|
-
|
7
|
+
def copy(source, target, _options = {})
|
8
|
+
Helper.validates_presence_of remote_host, 'Remote Host not set'
|
9
|
+
Helper.validates_presence_of remote_user, 'Remote User not set'
|
10
|
+
Helper.validates_presence_of ssh_key_file, 'SSH-Keyfile not set'
|
11
|
+
|
13
12
|
# check ssh keyfile
|
14
|
-
|
13
|
+
unless File.file? ssh_key_file
|
15
14
|
$log.writer.error "Can not find SSH keyfile #{ssh_key_file}"
|
16
15
|
exit 1
|
17
16
|
end
|
18
17
|
|
19
18
|
source_last = source.split('/').last
|
20
19
|
target_last = target.split('/').last
|
21
|
-
|
20
|
+
unless source_last == target_last
|
22
21
|
if not target.end_with?('/')
|
23
22
|
target = target + '/' + source_last
|
24
23
|
else
|
25
24
|
target = target + source_last
|
26
25
|
end
|
27
26
|
end
|
28
|
-
|
27
|
+
|
29
28
|
begin
|
30
|
-
|
31
|
-
### delete directory
|
32
|
-
if File.directory?(source)
|
29
|
+
|
30
|
+
### delete directory
|
31
|
+
if File.directory?(source)
|
33
32
|
Net::SFTP.start(remote_host, remote_user, \
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
auth_methods: ['publickey'], \
|
34
|
+
forward_agent: false, \
|
35
|
+
keys: ssh_key_file, \
|
36
|
+
timeout: 90) do |sftp|
|
37
|
+
|
38
|
+
# delete all files in target, but not the target-dir itself
|
39
|
+
$log.writer.debug "Cleaning remote directory #{target}"
|
40
|
+
sftp.rm_r!(target, delete_root: true)
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
|
46
|
-
### copy files
|
44
|
+
### copy files
|
47
45
|
Net::SFTP.start(remote_host, remote_user, \
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
sftp.upload!(source, target)
|
46
|
+
auth_methods: ['publickey'], \
|
47
|
+
forward_agent: false, \
|
48
|
+
keys: ssh_key_file, \
|
49
|
+
timeout: 90) do |sftp|
|
55
50
|
|
51
|
+
sftp.upload!(source, target)
|
56
52
|
|
57
53
|
end
|
58
|
-
rescue
|
54
|
+
rescue => e
|
59
55
|
$log.writer.error "Can not upload files to #{target}"
|
60
56
|
$log.writer.error e.message
|
61
|
-
|
57
|
+
# $log.writer.error e.backtrace.join("\n")
|
62
58
|
exit 1
|
63
59
|
end
|
64
|
-
|
65
60
|
end
|
66
61
|
|
62
|
+
def chmod(path, permissions, options = {})
|
63
|
+
Helper.validates_presence_of remote_host, 'Remote Host not set'
|
64
|
+
Helper.validates_presence_of remote_user, 'Remote User not set'
|
65
|
+
Helper.validates_presence_of ssh_key_file, 'SSH-Keyfile not set'
|
67
66
|
|
68
|
-
def chmod(path, permissions, options={})
|
69
|
-
Helper.validates_presence_of remote_host, "Remote Host not set"
|
70
|
-
Helper.validates_presence_of remote_user, "Remote User not set"
|
71
|
-
Helper.validates_presence_of ssh_key_file, "SSH-Keyfile not set"
|
72
|
-
|
73
67
|
# check ssh keyfile
|
74
|
-
|
68
|
+
unless File.file? ssh_key_file
|
75
69
|
$log.writer.error "Can not find SSH keyfile #{ssh_key_file}"
|
76
70
|
exit 1
|
77
71
|
end
|
78
72
|
|
79
73
|
Net::SFTP.start(remote_host, remote_user, \
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
$log.writer.debug "Set permissions"
|
86
|
-
|
87
|
-
if options[:recursive]
|
88
|
-
sftp.dir.entries(path).each do |entry|
|
89
|
-
next if entry.name == '.' or entry.name == '..'
|
90
|
-
child_path = File.join(path, entry.name)
|
91
|
-
|
92
|
-
sftp.setstat!(child_path, :permissions => permissions)
|
93
|
-
end
|
94
|
-
|
95
|
-
sftp.setstat!(path, :permissions => permissions)
|
96
|
-
|
97
|
-
else
|
98
|
-
sftp.setstat!(path, :permissions => permissions)
|
99
|
-
end
|
100
|
-
end
|
74
|
+
auth_methods: ['publickey'], \
|
75
|
+
forward_agent: false, \
|
76
|
+
keys: ssh_key_file, \
|
77
|
+
timeout: 90) do |sftp|
|
101
78
|
|
102
|
-
|
79
|
+
$log.writer.debug 'Set permissions'
|
103
80
|
|
81
|
+
if options[:recursive]
|
82
|
+
sftp.dir.entries(path).each do |entry|
|
83
|
+
next if entry.name == '.' or entry.name == '..'
|
84
|
+
child_path = File.join(path, entry.name)
|
104
85
|
|
86
|
+
sftp.setstat!(child_path, permissions: permissions)
|
87
|
+
end
|
88
|
+
|
89
|
+
sftp.setstat!(path, permissions: permissions)
|
90
|
+
|
91
|
+
else
|
92
|
+
sftp.setstat!(path, permissions: permissions)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
105
96
|
end
|
106
97
|
end
|
107
|
-
|
@@ -5,52 +5,51 @@ module Publisher
|
|
5
5
|
attr_accessor :ssh_key_file
|
6
6
|
|
7
7
|
def remote_execute(command)
|
8
|
-
Helper.validates_presence_of remote_user,
|
9
|
-
Helper.validates_presence_of remote_host,
|
10
|
-
Helper.validates_presence_of ssh_key_file,
|
11
|
-
Helper.validates_presence_of command,
|
8
|
+
Helper.validates_presence_of remote_user, 'Remote User not set'
|
9
|
+
Helper.validates_presence_of remote_host, 'Remote Host not set'
|
10
|
+
Helper.validates_presence_of ssh_key_file, 'SSH keyfile not set'
|
11
|
+
Helper.validates_presence_of command, 'No valid remote command given'
|
12
12
|
|
13
13
|
result = ''
|
14
14
|
# joined_filename = File.join(File.dirname($exec_file_path), ssh_key_file)
|
15
15
|
# ssh_key_file = joined_filename
|
16
16
|
|
17
|
-
|
17
|
+
unless File.file? ssh_key_file
|
18
18
|
$log.writer.error "Can not find SSH keyfile #{ssh_key_file}"
|
19
19
|
exit 1
|
20
20
|
end
|
21
21
|
|
22
22
|
Net::SSH.start(remote_host, remote_user, \
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
session.open_channel do |
|
28
|
-
|
29
|
-
|
23
|
+
auth_methods: ['publickey'], \
|
24
|
+
forward_agent: true, \
|
25
|
+
keys: ssh_key_file, \
|
26
|
+
timeout: 30) do |session|
|
27
|
+
session.open_channel do |channel|
|
28
|
+
channel.exec command do |ch, success|
|
29
|
+
unless success
|
30
30
|
$log.writer.error "could not execute remote command: '#{command}'"
|
31
31
|
exit 1
|
32
32
|
end
|
33
33
|
|
34
|
-
ch.on_data do |
|
34
|
+
ch.on_data do |_ch, data| # STDOUT of command
|
35
35
|
if data
|
36
36
|
$log.writer.debug data.strip
|
37
37
|
result << data
|
38
38
|
else
|
39
|
-
$log.writer.info
|
39
|
+
$log.writer.info 'Warning: Maybe successfully executed but no output found'
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
ch.on_extended_data do |
|
44
|
-
$log.writer.error
|
43
|
+
ch.on_extended_data do |_ch, type, data| # STDERR of command
|
44
|
+
$log.writer.error 'could not execute command'
|
45
45
|
$log.writer.error data
|
46
46
|
$log.writer.error type
|
47
47
|
exit 1
|
48
48
|
end
|
49
49
|
|
50
|
-
ch.on_close do |
|
50
|
+
ch.on_close do |_ch|
|
51
51
|
# result << "all done, closing!"
|
52
52
|
end
|
53
|
-
|
54
53
|
end
|
55
54
|
end
|
56
55
|
end
|
@@ -58,15 +57,13 @@ module Publisher
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def remove_old_releases(path, num_of_releases_to_keep, release_name_shema)
|
61
|
-
releases = remote_execute("ls #{path}").split("\n").
|
62
|
-
num_to_remove = releases.size-num_of_releases_to_keep
|
60
|
+
releases = remote_execute("ls #{path}").split("\n").select { |dir| dir =~ release_name_shema }.sort
|
61
|
+
num_to_remove = releases.size - num_of_releases_to_keep
|
63
62
|
releases_to_delete = releases.take(num_to_remove < 0 ? 0 : num_to_remove)
|
64
63
|
releases_to_delete.each do |dir|
|
65
64
|
$log.writer.debug "removing #{path}/#{dir}"
|
66
65
|
remote_execute("rm -rf #{path}/#{dir}")
|
67
66
|
end
|
68
67
|
end
|
69
|
-
|
70
68
|
end
|
71
69
|
end
|
72
|
-
|
@@ -10,36 +10,34 @@ module Publisher
|
|
10
10
|
attr_accessor :check_host
|
11
11
|
attr_accessor :worker
|
12
12
|
|
13
|
-
def deploy(
|
14
|
-
Helper.validates_presence_of servers,
|
15
|
-
Helper.validates_presence_of runners,
|
16
|
-
Helper.validates_presence_of initd_script,
|
17
|
-
Helper.validates_presence_of application_name,
|
18
|
-
Helper.validates_presence_of catalina_home,
|
19
|
-
Helper.validates_presence_of tomcat_context,
|
20
|
-
Helper.validates_presence_of logfilename,
|
21
|
-
Helper.validates_presence_of check_host,
|
13
|
+
def deploy(_options = {})
|
14
|
+
Helper.validates_presence_of servers, 'servers not set'
|
15
|
+
Helper.validates_presence_of runners, 'runners not set'
|
16
|
+
Helper.validates_presence_of initd_script, 'initd_script not set'
|
17
|
+
Helper.validates_presence_of application_name, 'application_name not set'
|
18
|
+
Helper.validates_presence_of catalina_home, 'catalina_home not set'
|
19
|
+
Helper.validates_presence_of tomcat_context, 'tomcat_context not set'
|
20
|
+
Helper.validates_presence_of logfilename, 'logfilename not set'
|
21
|
+
Helper.validates_presence_of check_host, 'check_host not set'
|
22
22
|
|
23
23
|
servers.each do |server|
|
24
24
|
$log.writer.info "========== Processing #{server}"
|
25
25
|
is_runner = runners.include?(server)
|
26
26
|
if is_runner
|
27
27
|
$log.writer.info "Stopping tomcat on #{server}"
|
28
|
-
stdout = worker.remote_execute("sudo #{initd_script} stop", :
|
28
|
+
stdout = worker.remote_execute("sudo #{initd_script} stop", remote_host: server)
|
29
29
|
$log.writer.info stdout
|
30
30
|
end
|
31
|
-
$log.writer.info
|
32
|
-
worker.rsync("target/#{application_name}/", "#{catalina_home}/webapps/#{tomcat_context}", :
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
31
|
+
$log.writer.info 'Deploying to webapp'
|
32
|
+
worker.rsync("target/#{application_name}/", "#{catalina_home}/webapps/#{tomcat_context}", remote_host: server)
|
33
|
+
next unless is_runner
|
34
|
+
$log.writer.info "Starting tomcat on #{server}"
|
35
|
+
stdout = worker.remote_execute("sudo #{initd_script} start", remote_host: server)
|
36
|
+
$log.writer.info stdout
|
37
|
+
stdout = worker.remote_execute("sleep 10; tail -50 #{catalina_home}/logs/#{logfilename}", remote_host: server)
|
38
|
+
$log.writer.debug stdout
|
39
|
+
worker.assert_url_response_of(check_host: check_host)
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
45
|
-
|
@@ -4,11 +4,10 @@ module Reporter
|
|
4
4
|
attr_accessor :worker
|
5
5
|
|
6
6
|
def set_version
|
7
|
-
Helper.validates_presence_of version,
|
7
|
+
Helper.validates_presence_of version, 'version not set'
|
8
8
|
|
9
9
|
worker.set_cdb_parameter('deployed_version', version)
|
10
|
-
worker.set_cdb_parameter('last_deployment_date', Time.now.strftime(
|
10
|
+
worker.set_cdb_parameter('last_deployment_date', Time.now.strftime('%m/%d/%Y-%I:%M%p'))
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
data/lib/depengine/version.rb
CHANGED
data/lib/depengine.rb
CHANGED
@@ -17,8 +17,7 @@ require 'csv'
|
|
17
17
|
require 'zlib'
|
18
18
|
require 'optparse'
|
19
19
|
|
20
|
-
|
21
|
-
Dir[File.join( File.dirname(__FILE__), '**/*.rb' )].sort.each { |file| require file }
|
20
|
+
Dir[File.join(File.dirname(__FILE__), '**/*.rb')].sort.each { |file| require file }
|
22
21
|
|
23
22
|
# Global variables
|
24
23
|
$exec_file_path = __FILE__
|
data/spec/cdb_spec.rb
CHANGED
@@ -10,19 +10,18 @@ $exec_file_path = __FILE__
|
|
10
10
|
$log = Log::DeploymentLogger.new
|
11
11
|
$log.writer.level = Log4r::DEBUG
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe 'the cdb backend' do
|
14
14
|
include Provider
|
15
15
|
path_to_cdb = File.join(File.dirname(__FILE__), '../../cdb/')
|
16
|
-
version = 0
|
17
16
|
|
18
17
|
before(:all) do
|
19
|
-
$log.writer.debug
|
18
|
+
$log.writer.debug 'starting a CDB webserver on port 4567'
|
20
19
|
$pid = spawn("rackup #{path_to_cdb}/config.ru -p 4567")
|
21
20
|
$log.writer.debug "CDB running as pid #{$pid}"
|
22
21
|
sleep(2) # waiting for CDB to come properly
|
23
22
|
end
|
24
23
|
|
25
|
-
it
|
24
|
+
it 'should deliver a parameter from the cdb by path' do
|
26
25
|
worker = Provider::CDB.new
|
27
26
|
worker.protocol = 'http'
|
28
27
|
worker.host = 'localhost:4567'
|
@@ -30,26 +29,25 @@ describe "the cdb backend" do
|
|
30
29
|
worker.env = 'INT'
|
31
30
|
|
32
31
|
result = worker.get_parameter('module/app/this_is', 0)
|
33
|
-
result.should include(
|
32
|
+
result.should include('INT_module_app')
|
34
33
|
end
|
35
34
|
|
36
|
-
it
|
35
|
+
it 'should set a parameter in the cdb' do
|
37
36
|
worker = Provider::CDB.new
|
38
37
|
worker.protocol = 'http'
|
39
38
|
worker.host = 'localhost:4567'
|
40
39
|
worker.context = ''
|
41
40
|
worker.env = 'INT'
|
42
41
|
|
43
|
-
worker.set_parameter('module/app', 'this_is',
|
42
|
+
worker.set_parameter('module/app', 'this_is', 'INT_module_app')
|
44
43
|
result = worker.get_parameter('module/app/this_is', 0)
|
45
44
|
|
46
|
-
result.should include(
|
45
|
+
result.should include('INT_module_app')
|
47
46
|
end
|
48
47
|
|
49
48
|
after(:all) do
|
50
|
-
$log.writer.debug
|
49
|
+
$log.writer.debug 'killing CDB webserver'
|
51
50
|
`kill #{$pid}`
|
52
51
|
end
|
53
52
|
|
54
53
|
end
|
55
|
-
|
@@ -1,27 +1,27 @@
|
|
1
|
-
set :application_name,
|
2
|
-
set :module_name,
|
1
|
+
set :application_name, 'testapp'
|
2
|
+
set :module_name, 'testmodule'
|
3
3
|
|
4
|
-
set :cleanup_workspace_before,
|
4
|
+
set :cleanup_workspace_before, %w(source tmp)
|
5
5
|
|
6
|
-
set :log_level,
|
7
|
-
set :log_file,
|
8
|
-
set :log_file_level,
|
6
|
+
set :log_level, 'INFO'
|
7
|
+
set :log_file, 'deploy.log'
|
8
|
+
set :log_file_level, 'DEBUG'
|
9
9
|
|
10
10
|
Deployment.deliver do
|
11
11
|
|
12
12
|
config = get_all_config_parameters
|
13
|
-
$log.writer.info
|
13
|
+
$log.writer.info 'Got config parameters from cdb'
|
14
14
|
|
15
15
|
$log.writer.info "date_unique: #{date_unique}"
|
16
16
|
|
17
17
|
config['test_app_hosts'].each do |test_app_host|
|
18
18
|
$log.writer.info "doing something on #{test_app_host}"
|
19
|
-
rsync(
|
20
|
-
remote_execute("export JAVA_HOME=/opt/java7; cd /srv/testapp/project_#{config['env'].downcase}/current/; . ./setantenv.sh; ant;", :
|
19
|
+
rsync('target/', '/srv/testapp/')
|
20
|
+
remote_execute("export JAVA_HOME=/opt/java7; cd /srv/testapp/project_#{config['env'].downcase}/current/; . ./setantenv.sh; ant;", remote_host: test_app_host)
|
21
21
|
end
|
22
22
|
|
23
23
|
report_by_mail
|
24
24
|
$log.writer.info "Sent mail to deployment team #{config['deploy_email_to']}"
|
25
25
|
|
26
|
-
$log.writer.info
|
26
|
+
$log.writer.info 'Deployment done!'
|
27
27
|
end
|
data/spec/deployhelper_spec.rb
CHANGED
@@ -8,50 +8,49 @@ require_relative '../lib/depengine/helper/hudson'
|
|
8
8
|
require_relative '../lib/depengine/log/log'
|
9
9
|
|
10
10
|
$log = Log::DeploymentLogger.new
|
11
|
-
|
11
|
+
# $log.writer.level = Log4r::ERROR
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe 'helper functions' do
|
14
14
|
include Helper
|
15
15
|
include FakeFS::SpecHelpers
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'should deliver all relevant envirnoment variables as a hash' do
|
18
18
|
result = get_environemnt_variables
|
19
|
-
result.should include(
|
19
|
+
result.should include('HOME')
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
version =
|
22
|
+
it 'should return a plain version number as a hash' do
|
23
|
+
version = '1.2.3'
|
24
24
|
result = parse_version(version)
|
25
|
-
result['app'].should include(
|
25
|
+
result['app'].should include('1.2.3')
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'should parse a json version string and return as hash' do
|
29
29
|
version = "{\"app\": \"1.2.3\", \"cdb\": 23, \"depsw\": 44}"
|
30
30
|
result = parse_version(version)
|
31
|
-
result['app'].should include(
|
32
|
-
result['cdb'].should
|
31
|
+
result['app'].should include('1.2.3')
|
32
|
+
result['cdb'].should be 23
|
33
33
|
result['depsw'].should be 44
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should remove all files from workspace' do
|
37
37
|
FileUtils.mkdir_p 'workspace'
|
38
|
-
FileUtils.touch
|
38
|
+
FileUtils.touch 'workspace/dummy.file'
|
39
39
|
cleanup_workspace!('workspace')
|
40
40
|
|
41
|
-
File.directory?(
|
42
|
-
File.file?(
|
41
|
+
File.directory?('workspace').should be true
|
42
|
+
File.file?('workspace/dummy.file').should be false
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'should create all inital directories in the workspace' do
|
46
46
|
FileUtils.mkdir_p 'workspace'
|
47
47
|
init_workspace('workspace')
|
48
48
|
|
49
|
-
File.directory?(
|
50
|
-
File.directory?(
|
51
|
-
File.directory?(
|
52
|
-
File.directory?(
|
53
|
-
File.directory?(
|
49
|
+
File.directory?('workspace').should be true
|
50
|
+
File.directory?('workspace/source').should be true
|
51
|
+
File.directory?('workspace/target').should be true
|
52
|
+
File.directory?('workspace/config').should be true
|
53
|
+
File.directory?('workspace/keep').should be true
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
57
|
-
|
data/spec/fileops_spec.rb
CHANGED
@@ -7,39 +7,38 @@ require_relative '../lib/depengine/log/log'
|
|
7
7
|
$log = Log::DeploymentLogger.new
|
8
8
|
$log.writer.level = Log4r::ERROR
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'file operations' do
|
11
11
|
include FakeFS::SpecHelpers
|
12
12
|
include Processor
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'should copy a file' do
|
15
15
|
FileUtils.mkdir_p 'source'
|
16
16
|
FileUtils.mkdir_p 'target'
|
17
17
|
FileUtils.touch 'source/dummy.file'
|
18
18
|
|
19
19
|
copy('source/dummy.file', 'target/dummy.file')
|
20
|
-
File.file?(
|
20
|
+
File.file?('target/dummy.file').should be_true
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'should create a directory' do
|
24
24
|
mkdir('target')
|
25
|
-
File.directory?(
|
25
|
+
File.directory?('target').should be_true
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
29
|
-
#not testable with FakeFS
|
28
|
+
it 'should modifie file parameter' do
|
29
|
+
# not testable with FakeFS
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'should delete a file' do
|
33
33
|
FileUtils.touch 'dummy.file'
|
34
34
|
remove('dummy.file')
|
35
|
-
File.file?(
|
35
|
+
File.file?('dummy.file').should be_false
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it 'should delete a directory' do
|
39
39
|
FileUtils.mkdir_p 'dummy'
|
40
40
|
remove('dummy')
|
41
41
|
|
42
|
-
File.directory?(
|
42
|
+
File.directory?('dummy').should be_false
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
data/spec/git_spec.rb
CHANGED
@@ -3,12 +3,16 @@ require_relative '../lib/depengine/processor/local_execute'
|
|
3
3
|
|
4
4
|
describe '#history' do
|
5
5
|
|
6
|
-
let(:git)
|
6
|
+
let(:git) do
|
7
|
+
g = Provider::Git.new
|
8
|
+
g.repository_local_dir = '.'
|
9
|
+
g
|
10
|
+
end
|
7
11
|
|
8
12
|
context 'no parameters given' do
|
9
13
|
it 'falls back to all history' do
|
10
14
|
expect(Processor).to receive(:local_execute).once.with(['git log --oneline ']).and_return('ok')
|
11
|
-
git.history
|
15
|
+
git.history
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
@@ -24,8 +28,8 @@ describe '#history' do
|
|
24
28
|
it 'uses both to get commits betweem them' do
|
25
29
|
r1, r2 = '4223abc', 'caffe42'
|
26
30
|
expect(Processor).to receive(:local_execute).once.with(['git log --oneline 4223abc..caffe42']).and_return('ok')
|
27
|
-
git.history(r1,r2)
|
31
|
+
git.history(r1, r2)
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
|
-
end
|
35
|
+
end
|