jackal-kitchen 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jackal-kitchen/tester.rb +41 -28
- data/lib/jackal-kitchen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8db32bb5a094463ef9b831ce269aa49c1ece5251
|
4
|
+
data.tar.gz: 377afbeca4b98319ce323057611f42824da6b5a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f8364e3758a1732dc655c38e103d31964e576828362f0c52abd5a606fe4488a7319e18f3098f934940d1fc20e5ec91dca8007c8d6b0b834ada2594b0b5493d
|
7
|
+
data.tar.gz: eba823497bf372af71dba9fd192c988ce79e3f6d30433584c41eec124e9589ee563f6bd69843422301059cf3eaa71a1d4d9ce23f0b49ed5f0013a7e54980c725
|
@@ -33,14 +33,16 @@ module Jackal
|
|
33
33
|
working_dir = working_path = Dir.mktmpdir
|
34
34
|
begin
|
35
35
|
maybe_clean_bundle do
|
36
|
-
|
36
|
+
run_command("git clone #{repo} cookbook", working_path, payload)
|
37
37
|
working_path = File.join(working_path, 'cookbook')
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
run_command("git checkout #{ref}", working_path, payload)
|
39
|
+
insert_kitchen_lxc(working_path)
|
40
|
+
insert_kitchen_local(working_path)
|
41
|
+
run_command("bundle install --path /tmp/.kitchen-jackal-vendor", working_path, payload)
|
42
|
+
run_command("bundle exec kitchen test", working_path, payload)
|
41
43
|
end
|
42
44
|
rescue => e
|
43
|
-
|
45
|
+
error "Command failed! #{e.class}: #{e}"
|
44
46
|
ensure
|
45
47
|
FileUtils.rm_rf(working_dir)
|
46
48
|
end
|
@@ -48,34 +50,41 @@ module Jackal
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
53
|
+
def insert_kitchen_local(path)
|
54
|
+
File.open(File.join(path, '.kitchen.local.yml'), 'w') do |file|
|
55
|
+
file.puts '---'
|
56
|
+
file.puts 'driver:'
|
57
|
+
file.puts ' name: lxc'
|
58
|
+
file.puts ' use_sudo: false'
|
59
|
+
if(config[:ssh_key])
|
60
|
+
file.puts " ssh_key: #{config[:ssh_key]}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Update gemfile to include kitchen-lxc driver
|
66
|
+
#
|
67
|
+
# @param path [String] working directory
|
68
|
+
def insert_kitchen_lxc(path)
|
69
|
+
gemfile = File.join(path, 'Gemfile')
|
70
|
+
if(File.exists?(gemfile))
|
71
|
+
content = File.readlines(gemfile)
|
72
|
+
else
|
73
|
+
content = ['source "https://rubygems.org"']
|
74
|
+
end
|
75
|
+
content << 'gem "kitchen-lxc"'
|
76
|
+
File.open(gemfile, 'w') do |file|
|
77
|
+
file.puts content.join("\n")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
51
81
|
# Run a command
|
52
82
|
#
|
53
83
|
# @param command [String] command to execute
|
54
84
|
# @param working_path [String] local working path
|
55
85
|
# @param payload [Smash] current payload
|
56
86
|
# @return [TrueClass]
|
57
|
-
def
|
58
|
-
cmd_input = Shellwords.shellsplit(command)
|
59
|
-
process = ChildProcess.build(*cmd_input)
|
60
|
-
stdout = File.open(File.join(working_path, 'stdout'), 'w+')
|
61
|
-
stderr = File.open(File.join(working_path, 'stderr'), 'w+')
|
62
|
-
process.io.stdout = stdout
|
63
|
-
process.io.stderr = stderr
|
64
|
-
process.cwd = working_path
|
65
|
-
process.start
|
66
|
-
status = process.wait
|
67
|
-
if status == 0
|
68
|
-
info "Setup command '#{command}' completed sucessfully"
|
69
|
-
payload.set(:data, :kitchen, :result, command, :success)
|
70
|
-
true
|
71
|
-
else
|
72
|
-
error "Command '#{command}' failed"
|
73
|
-
payload.set(:data, :kitchen, :result, command, :fail)
|
74
|
-
raise "Failed to execute setup command '#{command}'"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def kitchen_command(command, working_path, payload)
|
87
|
+
def run_command(command, working_path, payload)
|
79
88
|
cmd_input = Shellwords.shellsplit(command)
|
80
89
|
process = ChildProcess.build(*cmd_input)
|
81
90
|
stdout = File.open(File.join(working_path, 'stdout'), 'w+')
|
@@ -91,8 +100,12 @@ module Jackal
|
|
91
100
|
true
|
92
101
|
else
|
93
102
|
error "Command '#{command}' failed"
|
103
|
+
stderr.rewind
|
94
104
|
payload.set(:data, :kitchen, :result, command, :fail)
|
95
|
-
|
105
|
+
payload.set(:data, :kitchen, :error, stderr.read)
|
106
|
+
stdout.rewind
|
107
|
+
stderr.rewind
|
108
|
+
raise "Command failure! (#{command}). STDOUT: #{stdout.read} STDERR: #{stderr.read}"
|
96
109
|
end
|
97
110
|
end
|
98
111
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackal-kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Goddard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jackal
|