puppet_docker_tools 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5065c334b38bfde31cc9e305063afaab1fb057b3
4
- data.tar.gz: 39a900482ea78b84b8affcb445148b5be494f884
3
+ metadata.gz: 0cced50b6cd276b28389615a751ad0946a6e3196
4
+ data.tar.gz: 30084e7aebeee1dd037537bdb6ad521ff33376b3
5
5
  SHA512:
6
- metadata.gz: 217da3ed11d92e6421aa4702f4776a7e807fdae85c6049ab9dd611949c24b988ea060c3ac393edef517eafa61ccc1afc7d245a6f7e3356a8e666fcd6806f23b6
7
- data.tar.gz: 2e23e6ed966dbbc28ac5b40a7187059b85873c2ad26a1903ab378d39bb5da145af50674625a022873551bddd94eabbef60e014691382fcbbbb84dc21640cb225
6
+ metadata.gz: 2612cf5a9ce5c38bd1518c503f72c0943e4517ad6ba789e5573c562123604f9bd0978b4e4c5ceefeaff286ccef2da78868a93e7d3588263495da970d4551eca7
7
+ data.tar.gz: fe1ae2b95ab05230b2aeb780a111c286fde043ebe068af55dd9f4560a59412f44d8d1275fc78f7f72960035e37f6443d5cdb0a91e062586b027c031b1d49427e
data/README.md CHANGED
@@ -44,6 +44,7 @@ Build a docker image based on the dockerfile in DIRECTORY.
44
44
 
45
45
  Run [hadolint](https://github.com/hadolint/hadolint) on the dockerfile in DIRECTORY. The lint task runs on the `hadolint/hadolint` container with the following rule exclusions:
46
46
  * [DL3008](https://github.com/hadolint/hadolint/wiki/DL3008) - Pin versions in apt get install
47
+ * [DL3018](https://github.com/hadolint/hadolint/wiki/DL3018) - Pin versions in apk install
47
48
  * [DL4000](https://github.com/hadolint/hadolint/wiki/DL4000) - MAINTAINER is deprecated
48
49
  * [DL4001](https://github.com/hadolint/hadolint/wiki/DL4001) - Don't use both wget and curl
49
50
 
@@ -3,7 +3,7 @@ require 'docker'
3
3
  require 'rspec/core'
4
4
  require 'time'
5
5
  require 'puppet_docker_tools/utilities'
6
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec", 'spec_helper.rb'))
6
+ require 'puppet_docker_tools/spec_helper'
7
7
 
8
8
  class PuppetDockerTools
9
9
  class Runner
@@ -52,9 +52,17 @@ class PuppetDockerTools
52
52
  #
53
53
  def lint
54
54
  hadolint_container = 'hadolint/hadolint'
55
+ ignore_rules = [
56
+ 'DL3008',
57
+ 'DL3018',
58
+ 'DL4000',
59
+ 'DL4001',
60
+ ]
61
+ ignore_string = ignore_rules.map { |x| "--ignore #{x}" }.join(' ')
62
+
55
63
  # make sure we have the container locally
56
64
  PuppetDockerTools::Utilities.pull("#{hadolint_container}:latest")
57
- container = Docker::Container.create('Cmd' => ['/bin/sh', '-c', "hadolint --ignore DL3008 --ignore DL4000 --ignore DL4001 - "], 'Image' => hadolint_container, 'OpenStdin' => true, 'StdinOnce' => true)
65
+ container = Docker::Container.create('Cmd' => ['/bin/sh', '-c', "hadolint #{ignore_string} - "], 'Image' => hadolint_container, 'OpenStdin' => true, 'StdinOnce' => true)
58
66
  # This container.tap startes the container created above, and passes directory/Dockerfile to the container
59
67
  container.tap(&:start).attach(stdin: "#{directory}/#{dockerfile}")
60
68
  # Wait for the run to finish
@@ -117,7 +125,18 @@ class PuppetDockerTools
117
125
  test_files = tests.map { |test| File.basename(test, '.rb') }
118
126
 
119
127
  puts "Running RSpec tests from #{File.expand_path("#{directory}/spec")} (#{test_files.join ","}), this may take some time"
120
- RSpec::Core::Runner.run(tests, $stderr, $stdout)
128
+ success = true
129
+ tests.each do |test|
130
+ Open3.popen2e("rspec spec #{test}") do |stdin, output_stream, wait_thread|
131
+ while line = output_stream.gets
132
+ puts line
133
+ end
134
+ exit_status = wait_thread.value.exitstatus
135
+ success = success && (exit_status == 0)
136
+ end
137
+ end
138
+
139
+ fail "Running RSpec tests for #{directory} failed!" unless success
121
140
  end
122
141
 
123
142
  # Get the version set in the Dockerfile in the specified directory
@@ -5,4 +5,4 @@ require 'docker'
5
5
  Docker.options[:read_timeout] = 7200
6
6
 
7
7
  # Load any shared examples or context helpers
8
- Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].sort.each { |f| require f }
8
+ Dir[File.join(File.dirname(__FILE__), '..', '..', 'spec', 'support', '**', '*.rb')].sort.each { |f| require f }
@@ -155,9 +155,10 @@ HERE
155
155
 
156
156
  describe '#spec' do
157
157
  it "runs tests under the 'spec' directory" do
158
- tests=["/tmp/test-image/spec/test1_spec.rb", "/tmp/test-dir/spec/test2_spec.rb"]
158
+ tests=["/tmp/test-image/spec/test1_spec.rb", "/tmp/test-image/spec/test2_spec.rb"]
159
159
  expect(Dir).to receive(:glob).with("/tmp/test-image/spec/*_spec.rb").and_return(tests)
160
- expect(RSpec::Core::Runner).to receive(:run).with(tests, $stderr, $stdout).and_return(nil)
160
+ expect(Open3).to receive(:popen2e).with('rspec spec /tmp/test-image/spec/test1_spec.rb')
161
+ expect(Open3).to receive(:popen2e).with('rspec spec /tmp/test-image/spec/test2_spec.rb')
161
162
  runner.spec
162
163
  end
163
164
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_docker_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-18 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -78,10 +78,10 @@ files:
78
78
  - bin/puppet-docker
79
79
  - lib/puppet_docker_tools.rb
80
80
  - lib/puppet_docker_tools/runner.rb
81
+ - lib/puppet_docker_tools/spec_helper.rb
81
82
  - lib/puppet_docker_tools/utilities.rb
82
83
  - spec/lib/puppet_docker_tools/runner_spec.rb
83
84
  - spec/lib/puppet_docker_tools/utilities_spec.rb
84
- - spec/spec_helper.rb
85
85
  - spec/support/context/using_alpine.rb
86
86
  - spec/support/context/using_centos.rb
87
87
  - spec/support/context/with_docker_container.rb