puppet-check 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -6
- data/README.md +36 -8
- data/lib/puppet-check.rb +3 -1
- data/lib/puppet-check/data_parser.rb +7 -8
- data/lib/puppet-check/tasks.rb +42 -4
- data/spec/fixtures/manifests/good.pp +4 -1
- data/spec/fixtures/spec/facter/facter_spec.rb +7 -0
- data/spec/fixtures/spec/fixtures/do_not_parse_me +1 -0
- data/spec/integration/integration_spec.rb +12 -11
- data/spec/puppet-check/ruby_parser_spec.rb +14 -5
- data/spec/puppet-check/tasks_spec.rb +31 -0
- data/spec/puppet-check_spec.rb +8 -6
- metadata +42 -33
- data/.rubocop.yml +0 -11
- data/.travis.yml +0 -21
- data/Dockerfile +0 -22
- data/Gemfile +0 -5
- data/Rakefile +0 -24
- data/Vagrantfile +0 -77
- data/config.reek +0 -3
- data/images/puppetcheck_new.png +0 -0
- data/images/puppetcheck_old.odp +0 -0
- data/images/puppetcheck_old.png +0 -0
- data/puppet-check.gemspec +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef6e25a3e4df73cbaddd5f509626cc853b4cb9d
|
4
|
+
data.tar.gz: bbfa05df7d4d1d92f27a0b270d102bf2434c0ecb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 791c901be64ebca7dc49db9f5aa99940b1e138be58e5fd5605b881b32c97b36819c5bd7d2f353914bd2756c6a0c75f6cfc455de7429d27b20eca099a1a6498d5
|
7
|
+
data.tar.gz: 1e2f6c6c65ee1af874689f9fe2aab3fb7d4865c4047294de7808ed81d7c6541b16c2b2d9e749dac3bf01f16df2b3059f0875533e65e426e1220cc0250a069803
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
### 1.3.0 (Roadmap)
|
2
2
|
- minimum puppet version bump to 3.5 and future parser enabled by force for version < 4 (search code on 'future')
|
3
|
-
- minimum ruby version bump to 2.0.0 (switch vagrant to centos7, remove 1.9.3 from travis.yml, add 2.3.x to travis.yml, update readme, remove psych::syntaxerror from dataparser.yaml, and remove
|
3
|
+
- minimum ruby version bump to 2.0.0 (switch vagrant to centos7, remove 1.9.3 from travis.yml, add 2.3.x to travis.yml, update readme, remove psych::syntaxerror from dataparser.yaml, and remove 1.9.3 test from rubyparser.template style spec)
|
4
4
|
|
5
5
|
### 1.2.0 (Roadmap)
|
6
|
-
- json and yaml output formats support
|
7
|
-
-
|
8
|
-
|
9
|
-
### 1.1.0 (Roadmap)
|
10
|
-
- rspec and rspec puppet as optional tasks
|
6
|
+
- json and yaml output formats support (error_files becomes hash with file keys and array of issues; refactor output_results)
|
7
|
+
- rspec-puppet external dependencies support
|
11
8
|
- add additional hiera checks, including nested hash parsing
|
9
|
+
- explore puppet-catalog-test integration
|
10
|
+
|
11
|
+
### 1.1.0
|
12
|
+
- Support for RSpec, RSpec-Puppet, and Beaker.
|
13
|
+
- Empty hieradata file bug fix.
|
12
14
|
|
13
15
|
### 1.0.0
|
14
16
|
- Initial release.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
[![Build Status](https://travis-ci.org/mschuchard/puppet-check.svg?branch=master)](https://travis-ci.org/mschuchard/puppet-check)
|
3
3
|
|
4
4
|
## Description
|
5
|
-
Puppet Check is a gem
|
5
|
+
Puppet Check is a gem that provides a comprehensive, streamlined, and efficient analysis of the syntax, style, and validity of your entire Puppet code and data.
|
6
6
|
|
7
7
|
### Former Method for Code and Data Checks
|
8
8
|
![Old](https://raw.githubusercontent.com/mschuchard/puppet-check/master/images/puppetcheck_old.png)
|
@@ -95,14 +95,17 @@ The following files have unrecognized formats and therefore were not processed:
|
|
95
95
|
```
|
96
96
|
|
97
97
|
### Why not Puppetlabs Spec Helper?
|
98
|
-
- Puppetlabs Spec Helper is
|
98
|
+
- Puppetlabs Spec Helper is focused more on advanced and robust spec testing. Puppet Check is focused more on efficient and comprehensive Puppet code and data validation.
|
99
99
|
- Puppetlabs Spec Helper performs fewer types of checks.
|
100
100
|
- Puppetlabs Spec Helper has extra layers of gems in between it and the gems executing the checks.
|
101
101
|
- Puppetlabs Spec Helper does not allow interfacing through it to the gems executing the checks.
|
102
102
|
- Puppetlabs Spec Helper has no CLI.
|
103
|
+
- Puppetlabs Spec Helper intrinsically only executes spec tests against one module at a time.
|
104
|
+
|
105
|
+
It is worth nothing that there is no current development objective for Puppet Check to achieve the same advanced level of robustness for spec testing that Puppetlabs Spec Helper enables. If you are performing standard spec testing on your Puppet code and data, then Puppet Check's spec testing is a fantastic lightweight and faster alternative to Puppetlabs Spec Helper. If you require advanced and intricate capabilities in your spec testing (e.g. direct interfacing to the `Puppet::Parser::Scope` API), you will likely prefer Puppetlabs Spec Helper's spec testing in conjunction with Puppet Check's file validation. Also, Puppet Check currently has no intrinsic support for external dependencies during spec testing, so you will need Puppetlabs Spec Helper or Librarian Puppet for that.
|
103
106
|
|
104
107
|
## Usage
|
105
|
-
Puppet Check requires `ruby >= 1.9.3`, `puppet >= 3.2`, and `puppet-lint >= 1.1.0`. All other dependencies should be fine with various versions. Puppet Check can be used either with a CLI or Rake tasks.
|
108
|
+
Puppet Check requires `ruby >= 1.9.3`, `puppet >= 3.2`, and `puppet-lint >= 1.1.0`. All other dependencies should be fine with various versions. Puppet Check can be used either with a CLI or Rake tasks. Please note both interfaces will ignore any directories named `fixtures` during file checks.
|
106
109
|
|
107
110
|
### CLI
|
108
111
|
```
|
@@ -122,23 +125,48 @@ puppet-check -s --puppet-lint no-hard_tabs-check,no-80chars-check --rubocop Metr
|
|
122
125
|
```
|
123
126
|
|
124
127
|
### Rake
|
125
|
-
Interfacing with Puppet-Check via `rake` requires a `require puppet-check/tasks` in your Rakefile. This generates the following `rake`
|
128
|
+
Interfacing with Puppet-Check via `rake` requires a `require puppet-check/tasks` in your Rakefile. This generates the following `rake` commands:
|
126
129
|
|
127
130
|
```
|
131
|
+
rake puppetcheck # Execute all Puppet-Check checks
|
128
132
|
rake puppetcheck:file # Execute Puppet-Check file checks
|
133
|
+
rake puppetcheck:spec # Execute RSpec and RSpec-Puppet tests
|
134
|
+
rake puppetcheck:beaker # Execute Beaker acceptance tests
|
129
135
|
```
|
130
136
|
|
131
|
-
|
137
|
+
#### puppetcheck:file
|
138
|
+
You can add style checks to and select the future parser for the `rake puppetcheck:file` by adding the following after the require:
|
132
139
|
|
133
140
|
```ruby
|
134
141
|
PuppetCheck.style_check = true
|
135
142
|
PuppetCheck.future_parser = true
|
136
143
|
```
|
137
144
|
|
138
|
-
The style checks from within `rake` are directly interfaced to `puppet-lint`, `rubocop`, and `reek`. This means that all arguments and options should be specified from within your `.puppet-lint.rc`, `.rubocop.yml`, and `*.reek`. The capability to pass arguments and options
|
145
|
+
The style checks from within `rake puppetcheck:file` are directly interfaced to `puppet-lint`, `rubocop`, and `reek`. This means that all arguments and options should be specified from within your `.puppet-lint.rc`, `.rubocop.yml`, and `*.reek`. However, `puppet-lint` can still be interfaced with from within the `Rakefile` with the normal method of `PuppetLint.configuration.send('foo')` after the require. The capability to pass ruby style arguments and options from within the `Rakefile` task block will be considered for future versions.
|
146
|
+
|
147
|
+
#### puppetcheck:spec
|
148
|
+
The spec tests will be executed against everything that matches the pattern `**/{classes, defines, facter, functions, hosts, puppet, unit, types}/**/*_spec.rb`. This means everything in the current path that appears to be a Puppet module spec test will be regarded as such and executed during this rake task.
|
149
|
+
|
150
|
+
Please note it is perfectly acceptable to only execute standard RSpec tests in your modules and not use the extended RSpec Puppet matchers. If RSpec Puppet is not installed, then no RSpec Puppet related actions (including those described below) will be performed.
|
151
|
+
|
152
|
+
Prior to executing the spec tests, Puppet Check will parse everything in the current path and identify all `spec` directories. It will then execute `RSpec::Puppet::Setup` inside each assumed module directory containing these `spec` directories. This ensures any missing configuration items or non-current symlinks are created without altering your current configuration items, directories, or symlinks. The drawback to this is that your modules will be populated with useless `Rakefiles` if they do not already exist.
|
153
|
+
|
154
|
+
#### puppetcheck:beaker
|
155
|
+
The spec tests will be executed against everything that matches the pattern `**/acceptance`. This means everything in the current path that appears to be a Puppet module acceptance test will be regarded as such and executed during this rake task.
|
156
|
+
|
157
|
+
Please note this is merely a frontend to Beaker and that Beaker itself has a self-contained scope compared to all the other tools Puppet Check interfaces with and utilizes. This means if you want to add Beaker-RSpec, Serverspec, etc., or perform advanced configurations, those would be all be performed within Beaker itself. This task merely provides an interface to integrate Beaker in with your other testing infrastructure.
|
158
|
+
|
159
|
+
### Exit Codes
|
160
|
+
- 0: PuppetCheck exited with no internal exceptions or errors in your Puppet code and data.
|
161
|
+
- 1: PuppetCheck exited with an internal exception (takes preference over other non-zero exit codes).
|
162
|
+
- 2: PuppetCheck exited with errors in your Puppet code and data.
|
139
163
|
|
140
|
-
### Optional
|
141
|
-
|
164
|
+
### Optional dependencies
|
165
|
+
- **reek**: will automatically be installed as a dependency and checks enabled during style checks if your Ruby version is `>= 2.1.0`.
|
166
|
+
- **rake**: install this if you want to use Puppet Check with `rake` tasks in addition to the CLI.
|
167
|
+
- **rspec**: install this if you want to use Puppet Check to execute the spec tests for your ruby files during `rake`.
|
168
|
+
- **rspec-puppet**: install this if you want to use Puppet Check to execute the spec tests for your Puppet files during `rake`.
|
169
|
+
- **beaker**: install this if you want to use Puppet Check to execute the acceptance tests during `rake`.
|
142
170
|
|
143
171
|
## Contributing
|
144
172
|
Code should pass all spec tests. New features should involve new spec tests. Adherence to Rubocop and Reek is expected where not overly onerous or where the check is of dubious cost/benefit.
|
data/lib/puppet-check.rb
CHANGED
@@ -35,7 +35,7 @@ class PuppetCheck
|
|
35
35
|
self.class.output_results
|
36
36
|
|
37
37
|
# exit code
|
38
|
-
self.class.error_files.empty? ? 0 :
|
38
|
+
self.class.error_files.empty? ? 0 : 2
|
39
39
|
end
|
40
40
|
|
41
41
|
# parse the paths and return the array of files
|
@@ -50,6 +50,8 @@ class PuppetCheck
|
|
50
50
|
files.push(path)
|
51
51
|
end
|
52
52
|
end
|
53
|
+
# do not process fixtures
|
54
|
+
files.reject! { |file| file =~ /fixtures/ }
|
53
55
|
|
54
56
|
# check that at least one file was found, remove double slashes, and return unique files
|
55
57
|
raise "No files found in supplied paths #{paths.join(', ')}." if files.empty?
|
@@ -13,7 +13,8 @@ class DataParser
|
|
13
13
|
rescue Psych::SyntaxError, StandardError => err
|
14
14
|
PuppetCheck.error_files.push("-- #{file}:\n#{err.to_s.gsub("(#{file}): ", '')}")
|
15
15
|
else
|
16
|
-
|
16
|
+
# perform some rudimentary hiera checks if data exists
|
17
|
+
warnings = parsed.class.to_s == 'NilClass' ? [] : hiera(parsed)
|
17
18
|
next PuppetCheck.warning_files.push("-- #{file}:\n#{warnings.join("\n")}") unless warnings.empty?
|
18
19
|
PuppetCheck.clean_files.push("-- #{file}")
|
19
20
|
end
|
@@ -31,6 +32,8 @@ class DataParser
|
|
31
32
|
rescue JSON::ParserError => err
|
32
33
|
PuppetCheck.error_files.push("-- #{file}:\n#{err.to_s.lines.first.strip}")
|
33
34
|
else
|
35
|
+
warnings = []
|
36
|
+
|
34
37
|
# check metadata.json
|
35
38
|
if file =~ /.*metadata\.json$/
|
36
39
|
# metadata-json-lint has issues and is essentially no longer maintained so here is an improved and leaner version of it
|
@@ -66,19 +69,15 @@ class DataParser
|
|
66
69
|
next PuppetCheck.error_files.push("-- #{file}:\n#{errors.join("\n")}") unless errors.empty?
|
67
70
|
|
68
71
|
# check for warnings
|
69
|
-
warnings = []
|
70
|
-
|
71
72
|
# check for spdx license (rubygems/util/licenses for rubygems >= 2.5 in the far future)
|
72
73
|
if parsed.key?('license') && !SpdxLicenses.exist?(parsed['license']) && parsed['license'] !~ /[pP]roprietary/
|
73
74
|
warnings.push("License identifier '#{parsed['license']}' is not in the SPDX list: http://spdx.org/licenses/")
|
74
75
|
end
|
75
|
-
|
76
|
-
next PuppetCheck.warning_files.push("-- #{file}:\n#{warnings.join("\n")}") unless warnings.empty?
|
77
76
|
else
|
78
|
-
#
|
79
|
-
warnings = hiera(parsed)
|
80
|
-
next PuppetCheck.warning_files.push("-- #{file}:\n#{warnings.join("\n")}") unless warnings.empty?
|
77
|
+
# perform some rudimentary hiera checks if data exists
|
78
|
+
warnings = hiera(parsed) unless parsed.class.to_s == 'NilClass'
|
81
79
|
end
|
80
|
+
next PuppetCheck.warning_files.push("-- #{file}:\n#{warnings.join("\n")}") unless warnings.empty?
|
82
81
|
PuppetCheck.clean_files.push("-- #{file}")
|
83
82
|
end
|
84
83
|
end
|
data/lib/puppet-check/tasks.rb
CHANGED
@@ -1,13 +1,51 @@
|
|
1
|
-
require '
|
1
|
+
require 'rspec/core/rake_task'
|
2
2
|
require 'rake/tasklib'
|
3
|
+
require 'rake/task'
|
3
4
|
require_relative '../puppet-check'
|
4
5
|
|
5
6
|
# the rake interface for PuppetCheck
|
6
7
|
class PuppetCheck::Tasks < ::Rake::TaskLib
|
7
8
|
def initialize
|
8
|
-
desc 'Execute Puppet-Check
|
9
|
-
task
|
10
|
-
|
9
|
+
desc 'Execute all Puppet-Check checks'
|
10
|
+
task :puppetcheck do
|
11
|
+
%w(puppetcheck:file puppetcheck:spec puppetcheck:beaker).each { |task| Rake::Task[task.to_sym].invoke }
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :puppetcheck do
|
15
|
+
desc 'Execute Puppet-Check file checks'
|
16
|
+
task :file do
|
17
|
+
exit_code = PuppetCheck.new.run(Dir.glob('*'))
|
18
|
+
# changes nothing if this task is run separately; aborts 'puppetcheck' task if there are errors here
|
19
|
+
exit exit_code if exit_code != 0
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Execute RSpec and RSpec-Puppet tests'
|
23
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
24
|
+
rspec_puppet_setup
|
25
|
+
# generate tasks for all recognized directories inside of spec directories
|
26
|
+
task.pattern = '**/{classes, defines, facter, functions, hosts, puppet, unit, types}/**/*_spec.rb'
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Execute Beaker acceptance tests'
|
30
|
+
RSpec::Core::RakeTask.new(:beaker) do |task|
|
31
|
+
task.pattern = '**/acceptance'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# prepare the directories for rspec-puppet testing
|
37
|
+
def rspec_puppet_setup
|
38
|
+
# leave method immediately if there is no rspec-puppet installed
|
39
|
+
begin
|
40
|
+
require 'rspec-puppet/setup'
|
41
|
+
rescue LoadError
|
42
|
+
return
|
43
|
+
end
|
44
|
+
|
45
|
+
# executes rspec::puppet::setup in every module directory to ensure module spec directories are configured correctly
|
46
|
+
Dir.glob('**/spec').each do |specdir|
|
47
|
+
Dir.chdir(specdir + '/..')
|
48
|
+
RSpec::Puppet::Setup.run
|
11
49
|
end
|
12
50
|
end
|
13
51
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
i am a file that should not be processed
|
@@ -1,40 +1,41 @@
|
|
1
|
-
require 'rake'
|
1
|
+
require 'rake/task'
|
2
2
|
require_relative '../spec_helper.rb'
|
3
3
|
require_relative '../../lib/puppet-check/cli'
|
4
4
|
require_relative '../../lib/puppet-check/tasks'
|
5
5
|
|
6
6
|
describe 'PuppetCheck' do
|
7
7
|
context 'executed as a system from the CLI with arguments and various files to be processed' do
|
8
|
-
let(:cli) { PuppetCheck::CLI.run(%
|
8
|
+
let(:cli) { PuppetCheck::CLI.run(%w(-s --puppet-lint no-hard_tabs-check,no-80chars-check --rubocop Metrics/LineLength,Style/Encoding .)) }
|
9
9
|
|
10
10
|
it 'outputs diagnostic results correctly after processing all of the files' do
|
11
|
-
|
11
|
+
Dir.chdir(fixtures_dir)
|
12
|
+
|
13
|
+
expect(cli).to eql(2)
|
12
14
|
expect { cli }.not_to raise_exception
|
13
15
|
expect(PuppetCheck.error_files.length).to eql(8)
|
14
16
|
expect(PuppetCheck.warning_files.length).to eql(8)
|
15
|
-
expect(PuppetCheck.clean_files.length).to eql(
|
17
|
+
expect(PuppetCheck.clean_files.length).to eql(10)
|
16
18
|
expect(PuppetCheck.ignored_files.length).to eql(1)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
22
|
context 'executed as a system from the Rakefile with arguments and various files to be processed' do
|
21
|
-
let(:tasks) { Rake::Task['puppetcheck:file'].invoke }
|
23
|
+
let(:tasks) { Rake::Task['puppetcheck:file'.to_sym].invoke }
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
it 'outputs diagnostic results correctly after processing all of the files' do
|
26
|
+
# ensure rake only checks the files inside fixtures
|
27
|
+
Dir.chdir(fixtures_dir)
|
25
28
|
PuppetCheck.error_files = []
|
26
29
|
PuppetCheck.warning_files = []
|
27
30
|
PuppetCheck.clean_files = []
|
28
31
|
PuppetCheck.ignored_files = []
|
29
32
|
PuppetCheck.style_check = true
|
30
|
-
end
|
31
33
|
|
32
|
-
|
33
|
-
expect(tasks).to eql(1)
|
34
|
+
expect(tasks).to eql(2)
|
34
35
|
expect { tasks }.not_to raise_exception
|
35
36
|
expect(PuppetCheck.error_files.length).to eql(8)
|
36
37
|
expect(PuppetCheck.warning_files.length).to eql(8)
|
37
|
-
expect(PuppetCheck.clean_files.length).to eql(
|
38
|
+
expect(PuppetCheck.clean_files.length).to eql(10)
|
38
39
|
expect(PuppetCheck.ignored_files.length).to eql(1)
|
39
40
|
end
|
40
41
|
end
|
@@ -58,11 +58,20 @@ describe RubyParser do
|
|
58
58
|
expect(PuppetCheck.warning_files).to eql([])
|
59
59
|
expect(PuppetCheck.clean_files).to eql([])
|
60
60
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.0.0')
|
62
|
+
it 'puts a bad style ruby template file in the warning files array' do
|
63
|
+
RubyParser.template([fixtures_dir + 'templates/style.erb'])
|
64
|
+
expect(PuppetCheck.error_files).to eql([])
|
65
|
+
expect(PuppetCheck.warning_files[0]).to match(%r{^\-\- #{fixtures_dir}templates/style.erb:\n.*already initialized constant.*\n.*previous definition of})
|
66
|
+
expect(PuppetCheck.clean_files).to eql([])
|
67
|
+
end
|
68
|
+
else
|
69
|
+
it 'puts a bad style ruby template file in the warning files array' do
|
70
|
+
RubyParser.template([fixtures_dir + 'templates/style.erb'])
|
71
|
+
expect(PuppetCheck.error_files).to eql([])
|
72
|
+
expect(PuppetCheck.warning_files[0]).to match(%r{^\-\- #{fixtures_dir}templates/style.erb:})
|
73
|
+
expect(PuppetCheck.clean_files).to eql([])
|
74
|
+
end
|
66
75
|
end
|
67
76
|
it 'puts a ruby template file with ignored errors in the clean files array' do
|
68
77
|
RubyParser.template([fixtures_dir + 'templates/no_method_error.erb'])
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake/task'
|
2
|
+
require_relative '../spec_helper.rb'
|
3
|
+
require_relative '../../lib/puppet-check/tasks'
|
4
|
+
|
5
|
+
describe PuppetCheck::Tasks do
|
6
|
+
context 'puppetcheck:spec' do
|
7
|
+
let(:spec_tasks) { Rake::Task['puppetcheck:spec'.to_sym].invoke }
|
8
|
+
|
9
|
+
it 'executes RSpec and RSpec-Puppet checks in the expected manner' do
|
10
|
+
Dir.chdir(fixtures_dir)
|
11
|
+
|
12
|
+
# rspec task executed
|
13
|
+
expect { spec_tasks }.to output(/ruby.*rspec/).to_stdout
|
14
|
+
# if this is first then the stdout is not captured for testing
|
15
|
+
expect { spec_tasks }.not_to raise_exception
|
16
|
+
# rspec-puppet setup executed
|
17
|
+
expect(File.directory?('spec/fixtures/modules/fixtures')).to be true
|
18
|
+
|
19
|
+
# cleanup rspec-puppet setup
|
20
|
+
%w(Rakefile spec/spec_helper.rb).each { |file| File.delete(file) }
|
21
|
+
%w(manifests modules).each { |dir| FileUtils.rm_r('spec/fixtures/' + dir) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'puppetcheck:beaker' do
|
26
|
+
it 'verifies the Beaker task exists' do
|
27
|
+
Dir.chdir(fixtures_dir)
|
28
|
+
expect { Rake::Task['puppetcheck:spec'.to_sym].invoke }.not_to raise_exception
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/puppet-check_spec.rb
CHANGED
@@ -24,23 +24,25 @@ describe PuppetCheck do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
context '.parse_paths' do
|
27
|
+
before(:each) { Dir.chdir(fixtures_dir) }
|
28
|
+
|
27
29
|
let(:no_files) { puppetcheck.parse_paths(%w(foo bar baz)) }
|
28
|
-
let(:file) { puppetcheck.parse_paths([
|
29
|
-
let(:dir) { puppetcheck.parse_paths([
|
30
|
-
let(:multi_dir) { puppetcheck.parse_paths(
|
31
|
-
let(:repeats) { puppetcheck.parse_paths([
|
30
|
+
let(:file) { puppetcheck.parse_paths(['lib/good.rb']) }
|
31
|
+
let(:dir) { puppetcheck.parse_paths(['.']) }
|
32
|
+
let(:multi_dir) { puppetcheck.parse_paths(%w(hieradata lib manifests)) }
|
33
|
+
let(:repeats) { puppetcheck.parse_paths(['hieradata', 'hieradata', 'lib', 'hieradata/good.json', 'manifests/good.pp', 'manifests/good.pp']) }
|
32
34
|
|
33
35
|
it 'raises an error if no files were found' do
|
34
36
|
expect { no_files }.to raise_error(RuntimeError, 'No files found in supplied paths foo, bar, baz.')
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'correctly parses one file and returns it' do
|
38
|
-
expect(file[0]).to
|
40
|
+
expect(file[0]).to eql('lib/good.rb')
|
39
41
|
end
|
40
42
|
|
41
43
|
it 'correctly parses one directory and returns all of its files' do
|
42
44
|
dir.each { |file| expect(File.file?(file)).to be true }
|
43
|
-
expect(dir.length).to eql(
|
45
|
+
expect(dir.length).to eql(27)
|
44
46
|
end
|
45
47
|
|
46
48
|
it 'correctly parses multiple directories and returns all of their files' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Schuchard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet
|
@@ -30,26 +30,6 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rake
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '9'
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '13'
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '9'
|
50
|
-
- - "<"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '13'
|
53
33
|
- !ruby/object:Gem::Dependency
|
54
34
|
name: rubocop
|
55
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +86,40 @@ dependencies:
|
|
106
86
|
- - "~>"
|
107
87
|
- !ruby/object:Gem::Version
|
108
88
|
version: '3.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '9'
|
96
|
+
- - "<"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '12'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '9'
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '12'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: rspec-puppet
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '2.0'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '2.0'
|
109
123
|
description: Puppet Check is a gem that provides a comprehensive, streamlined, and
|
110
124
|
efficient analysis of the syntax, style, and validity of your entire Puppet code
|
111
125
|
and data.
|
@@ -115,20 +129,10 @@ executables:
|
|
115
129
|
extensions: []
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
118
|
-
- ".rubocop.yml"
|
119
|
-
- ".travis.yml"
|
120
132
|
- CHANGELOG.md
|
121
|
-
- Dockerfile
|
122
|
-
- Gemfile
|
123
133
|
- LICENSE.md
|
124
134
|
- README.md
|
125
|
-
- Rakefile
|
126
|
-
- Vagrantfile
|
127
135
|
- bin/puppet-check
|
128
|
-
- config.reek
|
129
|
-
- images/puppetcheck_new.png
|
130
|
-
- images/puppetcheck_old.odp
|
131
|
-
- images/puppetcheck_old.png
|
132
136
|
- lib/puppet-check.rb
|
133
137
|
- lib/puppet-check/cli.rb
|
134
138
|
- lib/puppet-check/data_parser.rb
|
@@ -136,7 +140,6 @@ files:
|
|
136
140
|
- lib/puppet-check/ruby_parser.rb
|
137
141
|
- lib/puppet-check/tasks.rb
|
138
142
|
- lib/puppet-check/utils.rb
|
139
|
-
- puppet-check.gemspec
|
140
143
|
- spec/fixtures/foobarbaz
|
141
144
|
- spec/fixtures/hieradata/good.json
|
142
145
|
- spec/fixtures/hieradata/good.yaml
|
@@ -157,6 +160,8 @@ files:
|
|
157
160
|
- spec/fixtures/metadata_good/metadata.json
|
158
161
|
- spec/fixtures/metadata_style/metadata.json
|
159
162
|
- spec/fixtures/metadata_syntax/metadata.json
|
163
|
+
- spec/fixtures/spec/facter/facter_spec.rb
|
164
|
+
- spec/fixtures/spec/fixtures/do_not_parse_me
|
160
165
|
- spec/fixtures/templates/good.epp
|
161
166
|
- spec/fixtures/templates/good.erb
|
162
167
|
- spec/fixtures/templates/no_method_error.erb
|
@@ -168,6 +173,7 @@ files:
|
|
168
173
|
- spec/puppet-check/data_parser_spec.rb
|
169
174
|
- spec/puppet-check/puppet_parser_spec.rb
|
170
175
|
- spec/puppet-check/ruby_parser_spec.rb
|
176
|
+
- spec/puppet-check/tasks_spec.rb
|
171
177
|
- spec/puppet-check/utils_spec.rb
|
172
178
|
- spec/puppet-check_spec.rb
|
173
179
|
- spec/spec_helper.rb
|
@@ -217,6 +223,8 @@ test_files:
|
|
217
223
|
- spec/fixtures/metadata_good/metadata.json
|
218
224
|
- spec/fixtures/metadata_style/metadata.json
|
219
225
|
- spec/fixtures/metadata_syntax/metadata.json
|
226
|
+
- spec/fixtures/spec/facter/facter_spec.rb
|
227
|
+
- spec/fixtures/spec/fixtures/do_not_parse_me
|
220
228
|
- spec/fixtures/templates/good.epp
|
221
229
|
- spec/fixtures/templates/good.erb
|
222
230
|
- spec/fixtures/templates/no_method_error.erb
|
@@ -228,6 +236,7 @@ test_files:
|
|
228
236
|
- spec/puppet-check/data_parser_spec.rb
|
229
237
|
- spec/puppet-check/puppet_parser_spec.rb
|
230
238
|
- spec/puppet-check/ruby_parser_spec.rb
|
239
|
+
- spec/puppet-check/tasks_spec.rb
|
231
240
|
- spec/puppet-check/utils_spec.rb
|
232
241
|
- spec/puppet-check_spec.rb
|
233
242
|
- spec/spec_helper.rb
|
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
notifications:
|
3
|
-
email: false
|
4
|
-
|
5
|
-
language: ruby
|
6
|
-
cache: bundler
|
7
|
-
|
8
|
-
matrix:
|
9
|
-
include:
|
10
|
-
- rvm: 1.9.3
|
11
|
-
env: TEST=spec
|
12
|
-
- rvm: 2.0.0
|
13
|
-
env: TEST=spec
|
14
|
-
- rvm: 2.1.9
|
15
|
-
env: TEST=default
|
16
|
-
- rvm: 2.2.5
|
17
|
-
env: TEST=spec
|
18
|
-
|
19
|
-
before_install: gem update bundler
|
20
|
-
install: bundle install --retry=3
|
21
|
-
script: bundle exec rake $TEST
|
data/Dockerfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# PuppetCheck: automated rake testing in reproducible environment
|
2
|
-
|
3
|
-
# Build container to automatically provision environment and execute tests.
|
4
|
-
# sudo docker build -t puppetcheck .
|
5
|
-
|
6
|
-
# Start and enter container for troubleshooting if necessary.
|
7
|
-
# sudo docker run -it -d puppetcheck
|
8
|
-
# sudo docker exec -it `sudo docker ps -qa | awk '{print $1}' | head -n 1` bash
|
9
|
-
|
10
|
-
# Remove running containers before rebuild.
|
11
|
-
# sudo docker ps -qa | xargs sudo docker kill
|
12
|
-
|
13
|
-
# Cleanup all instances when you are finished.
|
14
|
-
# sudo docker ps -qa | xargs sudo docker rm
|
15
|
-
# sudo docker images | grep puppetcheck | awk '{print $3}' | xargs sudo docker rmi
|
16
|
-
|
17
|
-
FROM ubuntu:15.10
|
18
|
-
RUN apt-get update && apt-get install ruby -y
|
19
|
-
RUN gem install --no-rdoc --no-ri puppet rspec rake rubocop reek puppet-lint spdx-licenses
|
20
|
-
COPY / /
|
21
|
-
# Exit 0 to ensure container is built with tag for troubleshooting.
|
22
|
-
RUN rake; exit 0
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rspec/core/rake_task'
|
2
|
-
require 'rubocop/rake_task'
|
3
|
-
require 'reek/rake/task' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
|
4
|
-
|
5
|
-
task default: [:rubocop, :reek, :unit, :integration]
|
6
|
-
|
7
|
-
RuboCop::RakeTask.new(:rubocop) do |task|
|
8
|
-
task.formatters = ['simple']
|
9
|
-
task.fail_on_error = false
|
10
|
-
end
|
11
|
-
|
12
|
-
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
|
13
|
-
Reek::Rake::Task.new do |task|
|
14
|
-
task.fail_on_error = false
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
RSpec::Core::RakeTask.new(:unit) do |task|
|
19
|
-
task.pattern = 'spec/{puppet-check_spec.rb, puppet-check/*_spec.rb}'
|
20
|
-
end
|
21
|
-
|
22
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
23
|
-
task.pattern = 'spec/integration/*_spec.rb'
|
24
|
-
end
|
data/Vagrantfile
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# PuppetCheck: testing gem build, install, and execution
|
2
|
-
|
3
|
-
# -*- mode: ruby -*-
|
4
|
-
# vi: set ft=ruby :
|
5
|
-
|
6
|
-
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
7
|
-
# configures the configuration version (we support older styles for
|
8
|
-
# backwards compatibility). Please don't change it unless you know what
|
9
|
-
# you're doing.
|
10
|
-
Vagrant.configure(2) do |config|
|
11
|
-
# The most common configuration options are documented and commented below.
|
12
|
-
# For a complete reference, please see the online documentation at
|
13
|
-
# https://docs.vagrantup.com.
|
14
|
-
|
15
|
-
# Every Vagrant development environment requires a box. You can search for
|
16
|
-
# boxes at https://atlas.hashicorp.com/search.
|
17
|
-
config.vm.box = 'ubuntu/trusty64'
|
18
|
-
|
19
|
-
# Disable automatic box update checking. If you disable this, then
|
20
|
-
# boxes will only be checked for updates when the user runs
|
21
|
-
# `vagrant box outdated`. This is not recommended.
|
22
|
-
# config.vm.box_check_update = false
|
23
|
-
|
24
|
-
# Create a forwarded port mapping which allows access to a specific port
|
25
|
-
# within the machine from a port on the host machine. In the example below,
|
26
|
-
# accessing "localhost:8080" will access port 80 on the guest machine.
|
27
|
-
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
28
|
-
|
29
|
-
# Create a private network, which allows host-only access to the machine
|
30
|
-
# using a specific IP.
|
31
|
-
# config.vm.network "private_network", ip: "192.168.33.10"
|
32
|
-
|
33
|
-
# Create a public network, which generally matched to bridged network.
|
34
|
-
# Bridged networks make the machine appear as another physical device on
|
35
|
-
# your network.
|
36
|
-
# config.vm.network "public_network"
|
37
|
-
|
38
|
-
# Share an additional folder to the guest VM. The first argument is
|
39
|
-
# the path on the host to the actual folder. The second argument is
|
40
|
-
# the path on the guest to mount the folder. And the optional third
|
41
|
-
# argument is a set of non-required options.
|
42
|
-
# config.vm.synced_folder "../data", "/vagrant_data"
|
43
|
-
|
44
|
-
# Provider-specific configuration so you can fine-tune various
|
45
|
-
# backing providers for Vagrant. These expose provider-specific options.
|
46
|
-
# Example for VirtualBox:
|
47
|
-
#
|
48
|
-
# config.vm.provider "virtualbox" do |vb|
|
49
|
-
# # Display the VirtualBox GUI when booting the machine
|
50
|
-
# vb.gui = true
|
51
|
-
#
|
52
|
-
# # Customize the amount of memory on the VM:
|
53
|
-
# vb.memory = "1024"
|
54
|
-
# end
|
55
|
-
#
|
56
|
-
# View the documentation for the provider you are using for more
|
57
|
-
# information on available options.
|
58
|
-
|
59
|
-
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
60
|
-
# such as FTP and Heroku are also available. See the documentation at
|
61
|
-
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
62
|
-
# config.push.define "atlas" do |push|
|
63
|
-
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
64
|
-
# end
|
65
|
-
|
66
|
-
# Enable provisioning with a shell script. Additional provisioners such as
|
67
|
-
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
68
|
-
# documentation for more information about their specific syntax and use.
|
69
|
-
config.vm.provision 'shell', inline: <<-SHELL
|
70
|
-
cd /vagrant
|
71
|
-
sudo apt-get install git -y
|
72
|
-
sudo gem build puppet-check.gemspec
|
73
|
-
sudo gem install --no-rdoc --no-ri puppet-check*.gem
|
74
|
-
sudo /usr/local/bin/puppet-check -s spec/fixtures
|
75
|
-
sudo rm -f puppet-check*.gem
|
76
|
-
SHELL
|
77
|
-
end
|
data/config.reek
DELETED
data/images/puppetcheck_new.png
DELETED
Binary file
|
data/images/puppetcheck_old.odp
DELETED
Binary file
|
data/images/puppetcheck_old.png
DELETED
Binary file
|
data/puppet-check.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |spec|
|
2
|
-
spec.name = 'puppet-check'
|
3
|
-
spec.version = '1.0.0'
|
4
|
-
spec.authors = ['Matt Schuchard']
|
5
|
-
spec.description = 'Puppet Check is a gem that provides a comprehensive, streamlined, and efficient analysis of the syntax, style, and validity of your entire Puppet code and data.'
|
6
|
-
spec.summary = 'A streamlined comprehensive set of checks for your entire Puppet code and data'
|
7
|
-
spec.homepage = 'https://www.github.com/mschuchard/puppet-check'
|
8
|
-
spec.license = 'MIT'
|
9
|
-
|
10
|
-
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
11
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |file| File.basename(file) }
|
12
|
-
spec.test_files = spec.files.grep(%r{^spec/})
|
13
|
-
spec.require_paths = Dir['lib']
|
14
|
-
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 1.9.3')
|
16
|
-
spec.add_dependency 'puppet', '>= 3.2', '< 5'
|
17
|
-
# spec.add_dependency 'rspec', '~> 3.0'
|
18
|
-
spec.add_dependency 'rake', '>= 9', '< 13'
|
19
|
-
spec.add_dependency 'rubocop', '~> 0'
|
20
|
-
spec.add_dependency 'puppet-lint', '~> 1.1'
|
21
|
-
# spec.add_dependency 'rspec-puppet', '~> 2.0'
|
22
|
-
# spec.add_dependency 'beaker.' '~> 2.0'
|
23
|
-
spec.add_dependency 'spdx-licenses', '~> 1.0'
|
24
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
-
end
|