drydocker 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +2 -0
- data/README.md +5 -2
- data/VERSION +1 -1
- data/bin/drydocker +37 -39
- data/drydocker.gemspec +4 -5
- data/lib/drydocker.rb +15 -12
- data/spec/drydocker_spec.rb +4 -3
- metadata +3 -4
- data/test/helper.rb +0 -34
- data/test/test_loop_test.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f60acdab6aa7f2bde922bd50bfb390dd39f7a3f
|
4
|
+
data.tar.gz: b16eea66d98f207632ff9a89c0aa531612f936ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5950ef61f6030f8fa7262b8ab467018dbad8a2a030e159daa4c291a85f95f61f49452287ac418953f75a7c0191f5004b84057c24a6b7930215d9e4dcba0180bd
|
7
|
+
data.tar.gz: 6f6783c43f809a379d928a5c96f6ef5c446599b2474fb4f6b4d33c03dd564f303031450ea00b775220ee052e1098bd5ad5a7cc2d127e518b1ec9232e2c01254b
|
data/.dockerignore
ADDED
data/README.md
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
[![wercker status](https://app.wercker.com/status/b00d4339862ef12b880f0022b6d20b2a/s "wercker status")](https://app.wercker.com/project/bykey/b00d4339862ef12b880f0022b6d20b2a)
|
4
4
|
|
5
|
-
|
5
|
+
Drydocker provides a simple wrapper to run tests inside a container every
|
6
|
+
time you make a change to your code. It listens to filesystem changes on your
|
7
|
+
host and runs a docker command every time it detects anything. It is a
|
8
|
+
pre-requisite of use that you have a docker image you can run your tests in.
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
@@ -36,7 +39,7 @@ the output of `drydocker -h` for more information on the flags to use.
|
|
36
39
|
## Links
|
37
40
|
|
38
41
|
* Source code: https://github.com/silarsis/drydocker
|
39
|
-
* Build/Test: https://app.wercker.com/
|
42
|
+
* Build/Test: https://app.wercker.com/#applications/54b446f6da3a4af764100e91
|
40
43
|
* Docker container: https://registry.hub.docker.com/u/silarsis/drydocker/
|
41
44
|
* RubyGem: https://rubygems.org/gems/drydocker
|
42
45
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/bin/drydocker
CHANGED
@@ -5,49 +5,47 @@ require 'optparse'
|
|
5
5
|
|
6
6
|
# Command line parser to setup options
|
7
7
|
# :name, :command, :image, :entrypoint, :path
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
options[:verbose] = verbose
|
43
|
-
end
|
8
|
+
def parse(args)
|
9
|
+
options = Drydocker::Config.default_config
|
10
|
+
|
11
|
+
opt_parser = OptionParser.new do |opts|
|
12
|
+
opts.banner = 'Usage: drydocker [options]'
|
13
|
+
opts.separator ''
|
14
|
+
opts.separator 'Specific options:'
|
15
|
+
|
16
|
+
opts.on('-f', '--filename [FILENAME]', 'File of options to load') do |fn|
|
17
|
+
options.load(fn)
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on('-n', '--name [NAME]', 'Container name to run tests in, default "<imagename>-test"') do |name|
|
21
|
+
options[:name] = name
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on('-c', '--command [COMMAND]', "command to run, default '#{options[:command]}'") do |cmd|
|
25
|
+
options[:command] = cmd
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on('-i', '--image [IMAGE]', "image to run for testing, default '#{options[:image]}'") do |img|
|
29
|
+
options[:image] = img
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on('-e', '--entrypoint [ENTRYPOINT]', 'entrypoint in case you need to override that, default nil') do |entry|
|
33
|
+
options[:entrypoint] = entry
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on('-p', '--path [PATH]', "directory to monitor and mount for testing, default '#{options[:path]}'") do |path|
|
37
|
+
options[:path] = path
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on('-v', '--[no-]verbose', 'verbose output') do |verbose|
|
41
|
+
options[:verbose] = verbose
|
44
42
|
end
|
45
|
-
opt_parser.parse!(args)
|
46
|
-
options
|
47
43
|
end
|
44
|
+
opt_parser.parse!(args)
|
45
|
+
options
|
48
46
|
end
|
49
47
|
|
50
|
-
options =
|
48
|
+
options = parse(ARGV)
|
51
49
|
config = Drydocker::Config.new(options)
|
52
50
|
monitor = Drydocker::Monitor.new(config)
|
53
51
|
monitor.clean_containers
|
data/drydocker.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: drydocker 0.1.
|
5
|
+
# stub: drydocker 0.1.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "drydocker"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Kevin Littlejohn"]
|
14
|
-
s.date = "2015-01-
|
14
|
+
s.date = "2015-01-14"
|
15
15
|
s.description = "Run tests on change in a docker container continuously"
|
16
16
|
s.email = "kevin@littlejohn.id.au"
|
17
17
|
s.executables = ["drydocker"]
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
"README.md"
|
21
21
|
]
|
22
22
|
s.files = [
|
23
|
+
".dockerignore",
|
23
24
|
".document",
|
24
25
|
".rubocop.yml",
|
25
26
|
"Dockerfile",
|
@@ -34,8 +35,6 @@ Gem::Specification.new do |s|
|
|
34
35
|
"lib/drydocker.rb",
|
35
36
|
"spec/drydocker_spec.rb",
|
36
37
|
"spec/spec_helper.rb",
|
37
|
-
"test/helper.rb",
|
38
|
-
"test/test_loop_test.rb",
|
39
38
|
"wercker.yml"
|
40
39
|
]
|
41
40
|
s.homepage = "http://github.com/silarsis/drydocker"
|
data/lib/drydocker.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'listen'
|
2
2
|
require 'ptools'
|
3
|
+
require 'logger'
|
4
|
+
require 'shellwords'
|
3
5
|
|
4
6
|
module Drydocker
|
5
7
|
# Configuration file reader
|
6
8
|
class Config
|
7
|
-
attr_reader :name, :command, :image, :entrypoint, :path, :verbose
|
9
|
+
attr_reader :name, :command, :image, :entrypoint, :path, :verbose, :logger
|
8
10
|
|
9
11
|
def self.default_config
|
10
12
|
{
|
@@ -22,9 +24,10 @@ module Drydocker
|
|
22
24
|
@image = config[:image]
|
23
25
|
@name = config[:name] || name_from_image
|
24
26
|
@entrypoint = config[:entrypoint]
|
25
|
-
@command = config[:command]
|
27
|
+
@command = config[:command].shellescape
|
26
28
|
@path = config[:path]
|
27
|
-
@
|
29
|
+
@logger = Logger.new(STDERR)
|
30
|
+
@logger.level = Logger::DEBUG if config[:verbose]
|
28
31
|
end
|
29
32
|
|
30
33
|
private
|
@@ -44,17 +47,17 @@ module Drydocker
|
|
44
47
|
|
45
48
|
def listen
|
46
49
|
listener = Listen.to(config.path) do |modified, added, removed|
|
47
|
-
|
50
|
+
config.logger.info("triggering change: #{modified + added + removed}")
|
48
51
|
run_or_start
|
49
52
|
end
|
50
53
|
listener.start # not blocking
|
51
|
-
|
54
|
+
config.logger.info('now listening')
|
52
55
|
end
|
53
56
|
|
54
57
|
def clean_containers
|
55
58
|
fail 'No docker found' if File.which('docker').nil?
|
56
|
-
return unless
|
57
|
-
|
59
|
+
return unless system(docker_check_cmd)
|
60
|
+
config.logger.debug('cleaning up previous containers')
|
58
61
|
`docker kill #{config.name}`
|
59
62
|
`docker rm #{config.name}`
|
60
63
|
end
|
@@ -64,7 +67,7 @@ module Drydocker
|
|
64
67
|
def docker_run_cmd
|
65
68
|
%W(
|
66
69
|
#{docker_cmd} #{name_opt} #{path_opt} #{entrypoint_opt} #{config.image}
|
67
|
-
#{command}
|
70
|
+
sh -c #{command}
|
68
71
|
).reject { |x| x == '' }.join(' ')
|
69
72
|
end
|
70
73
|
|
@@ -77,7 +80,7 @@ module Drydocker
|
|
77
80
|
end
|
78
81
|
|
79
82
|
def docker_cmd
|
80
|
-
'docker run -it'
|
83
|
+
'docker run -it -w /app'
|
81
84
|
end
|
82
85
|
|
83
86
|
def name_opt
|
@@ -85,7 +88,7 @@ module Drydocker
|
|
85
88
|
end
|
86
89
|
|
87
90
|
def entrypoint_opt
|
88
|
-
config.entrypoint.nil? ? '' : "--entrypoint #{config.entrypoint}"
|
91
|
+
config.entrypoint.nil? ? '' : "--entrypoint #{config.entrypoint.shellescape}"
|
89
92
|
end
|
90
93
|
|
91
94
|
def path_opt
|
@@ -97,12 +100,12 @@ module Drydocker
|
|
97
100
|
end
|
98
101
|
|
99
102
|
def run
|
100
|
-
|
103
|
+
config.logger.debug(docker_run_cmd)
|
101
104
|
system(docker_run_cmd)
|
102
105
|
end
|
103
106
|
|
104
107
|
def start
|
105
|
-
|
108
|
+
config.logger.debug(docker_start_cmd)
|
106
109
|
system(docker_start_cmd)
|
107
110
|
end
|
108
111
|
|
data/spec/drydocker_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'drydocker'
|
3
|
+
require 'shellwords'
|
3
4
|
|
4
5
|
# Tests for the main module
|
5
6
|
module Drydocker
|
@@ -9,7 +10,7 @@ module Drydocker
|
|
9
10
|
specify { expect(config.name).to eq 'silarsis-drydocker-test' }
|
10
11
|
specify { expect(config.entrypoint).to be_nil }
|
11
12
|
specify { expect(config.image).to eq 'silarsis/drydocker' }
|
12
|
-
specify { expect(config.command).to eq 'rspec spec' }
|
13
|
+
specify { expect(config.command).to eq 'rspec spec'.shellescape }
|
13
14
|
end
|
14
15
|
context 'with provide value for' do
|
15
16
|
context 'name' do
|
@@ -40,7 +41,7 @@ module Drydocker
|
|
40
41
|
end
|
41
42
|
|
42
43
|
describe Monitor do
|
43
|
-
let(:config) { Config.new }
|
44
|
+
let(:config) { Config.new(name: 'spec-container') }
|
44
45
|
let(:monitor) { Monitor.new(config) }
|
45
46
|
|
46
47
|
describe '#monitor' do
|
@@ -49,7 +50,7 @@ module Drydocker
|
|
49
50
|
.with("docker ps -a | grep #{config.name} >/dev/null") \
|
50
51
|
.and_return false
|
51
52
|
expect(monitor).to receive(:system) \
|
52
|
-
.with("docker run -it --name #{config.name} -v #{config.path}:/app #{config.image} #{config.command}") \
|
53
|
+
.with("docker run -it -w /app --name #{config.name} -v #{config.path}:/app #{config.image} sh -c #{config.command}") \
|
53
54
|
.and_return true
|
54
55
|
monitor.send(:run_or_start)
|
55
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drydocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Littlejohn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -145,6 +145,7 @@ extra_rdoc_files:
|
|
145
145
|
- LICENSE.txt
|
146
146
|
- README.md
|
147
147
|
files:
|
148
|
+
- ".dockerignore"
|
148
149
|
- ".document"
|
149
150
|
- ".rubocop.yml"
|
150
151
|
- Dockerfile
|
@@ -159,8 +160,6 @@ files:
|
|
159
160
|
- lib/drydocker.rb
|
160
161
|
- spec/drydocker_spec.rb
|
161
162
|
- spec/spec_helper.rb
|
162
|
-
- test/helper.rb
|
163
|
-
- test/test_loop_test.rb
|
164
163
|
- wercker.yml
|
165
164
|
homepage: http://github.com/silarsis/drydocker
|
166
165
|
licenses:
|
data/test/helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
|
-
module SimpleCov::Configuration
|
4
|
-
def clean_filters
|
5
|
-
@filters = []
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
SimpleCov.configure do
|
10
|
-
clean_filters
|
11
|
-
load_adapter 'test_frameworks'
|
12
|
-
end
|
13
|
-
|
14
|
-
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
-
add_filter "/.rvm/"
|
16
|
-
end
|
17
|
-
require 'rubygems'
|
18
|
-
require 'bundler'
|
19
|
-
begin
|
20
|
-
Bundler.setup(:default, :development)
|
21
|
-
rescue Bundler::BundlerError => e
|
22
|
-
$stderr.puts e.message
|
23
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
24
|
-
exit e.status_code
|
25
|
-
end
|
26
|
-
require 'test/unit'
|
27
|
-
require 'shoulda'
|
28
|
-
|
29
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
30
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
31
|
-
require 'drydocker'
|
32
|
-
|
33
|
-
class Test::Unit::TestCase
|
34
|
-
end
|