More testing

This commit is contained in:
Gene Liverman 2017-05-07 16:57:16 -07:00
parent d008f064cc
commit 1241ef7c85
9 changed files with 65 additions and 23 deletions

5
.rubocop.yml Normal file
View file

@ -0,0 +1,5 @@
AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
TargetRubyVersion: 2.0

View file

@ -1,11 +1,13 @@
# vim:ft=ruby # vim:ft=ruby
source 'https://rubygems.org' source 'https://rubygems.org'
# rubocop:disable ConditionalAssignment
if ENV.key?('PUPPET_VERSION') if ENV.key?('PUPPET_VERSION')
puppetversion = "#{ENV['PUPPET_VERSION']}" puppetversion = ENV['PUPPET_VERSION'].to_s
else else
puppetversion = ['~> 4.0'] puppetversion = ['~> 4.0']
end end
# rubocop:enable ConditionalAssignment
group :production do group :production do
gem 'os', '~> 1.0' gem 'os', '~> 1.0'
@ -20,6 +22,7 @@ group :development, :unit_tests do
gem 'metadata-json-lint', '~> 1.0' gem 'metadata-json-lint', '~> 1.0'
gem 'puppetlabs_spec_helper', '~> 1.1' gem 'puppetlabs_spec_helper', '~> 1.1'
gem 'rspec-puppet', '~> 2.5' gem 'rspec-puppet', '~> 2.5'
gem 'rubocop', '~> 0.48'
gem 'yamllint', '~> 0.0.9' gem 'yamllint', '~> 0.0.9'
# puppet-lint and plugins # puppet-lint and plugins

View file

@ -2,6 +2,7 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
CFPropertyList (2.2.8) CFPropertyList (2.2.8)
ast (2.3.0)
colored (1.2) colored (1.2)
cri (2.6.1) cri (2.6.1)
colored (~> 1.2) colored (~> 1.2)
@ -37,6 +38,9 @@ GEM
multi_json (1.12.1) multi_json (1.12.1)
multipart-post (2.0.0) multipart-post (2.0.0)
os (1.0.0) os (1.0.0)
parser (2.4.0.0)
ast (~> 2.2)
powerpack (0.1.1)
puppet (4.5.3) puppet (4.5.3)
facter (> 2.0, < 4) facter (> 2.0, < 4)
hiera (>= 2.0, < 4) hiera (>= 2.0, < 4)
@ -90,6 +94,8 @@ GEM
multi_json (~> 1.10) multi_json (~> 1.10)
puppet_forge (~> 2.2) puppet_forge (~> 2.2)
semantic_puppet (~> 0.1.0) semantic_puppet (~> 0.1.0)
rainbow (2.2.2)
rake
rake (12.0.0) rake (12.0.0)
rspec (3.6.0) rspec (3.6.0)
rspec-core (~> 3.6.0) rspec-core (~> 3.6.0)
@ -106,12 +112,20 @@ GEM
rspec-puppet (2.5.0) rspec-puppet (2.5.0)
rspec rspec
rspec-support (3.6.0) rspec-support (3.6.0)
rubocop (0.48.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
rugged (0.25.1.1) rugged (0.25.1.1)
semantic_puppet (0.1.4) semantic_puppet (0.1.4)
gettext-setup (>= 0.3) gettext-setup (>= 0.3)
spdx-licenses (1.1.0) spdx-licenses (1.1.0)
text (1.3.1) text (1.3.1)
trollop (2.1.2) trollop (2.1.2)
unicode-display_width (1.2.1)
yamllint (0.0.9) yamllint (0.0.9)
trollop (~> 2) trollop (~> 2)
@ -140,6 +154,7 @@ DEPENDENCIES
puppetlabs_spec_helper (~> 1.1) puppetlabs_spec_helper (~> 1.1)
r10k (~> 2.3) r10k (~> 2.3)
rspec-puppet (~> 2.5) rspec-puppet (~> 2.5)
rubocop (~> 0.48)
rugged (~> 0.24) rugged (~> 0.24)
yamllint (~> 0.0.9) yamllint (~> 0.0.9)

View file

@ -1,3 +1,4 @@
require 'rubocop/rake_task'
require 'rubygems' require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks' require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint' require 'puppet-lint/tasks/puppet-lint'
@ -9,28 +10,56 @@ exclude_paths = [
'spec/**/*' 'spec/**/*'
] ]
RuboCop::RakeTask.new
RuboCop::RakeTask.new(:rubocop) do |task|
# task.patterns = ['lib/**/*.rb']
# only show the files with failures
# task.formatters = ['files']
# don't abort rake on failure
# task.fail_on_error = false
end
PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.ignore_paths = exclude_paths PuppetLint.configuration.ignore_paths = exclude_paths
PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{check}:%{KIND}:%{message}' PuppetLint.configuration.log_format =
'%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
PuppetSyntax.exclude_paths = exclude_paths PuppetSyntax.exclude_paths = exclude_paths
desc 'Validate manifests, templates, and ruby files' desc 'Validate manifests, templates, and ruby files'
task :validate do task :validate do
Dir['puppet/manifests/**/*.pp', 'puppet/site/*/manifests/**/*.pp'].each do |manifest| Dir['puppet/manifests/**/*.pp',
'puppet/site/*/manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}" sh "puppet parser validate --noop #{manifest}"
end end
Dir['bin/**/*.rb', 'spec/**/*.rb'].each do |ruby_file| Dir['bin/**/*.rb',
# sh "ruby -c #{ruby_file}" unless ruby_file.match? %r{spec\/fixtures} 'spec/**/*.rb'].each do |ruby_file|
# rubocop:disable RegexpLiteral
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
# rubocop:enable RegexpLiteral
end end
Dir['puppet/site/*/templates/**/*.erb'].each do |template| Dir['puppet/site/*/templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c" sh "erb -P -x -T '-' #{template} | ruby -c"
end end
end end
YamlLint::RakeTask.new do |yamllint|
yamllint.paths = %w[
.*.yaml
.*.yml
*.yaml
*.yml
copy/**/*.yml
link/**/*.yml
puppet/hieradata/**/*.yml
puppet/hieradata/**/*.yaml
]
end
task :tests do task :tests do
Rake::Task[:lint].invoke Rake::Task[:lint].invoke
Rake::Task[:yamllint].invoke
Rake::Task[:validate].invoke Rake::Task[:validate].invoke
Rake::Task[:rubocop].invoke
Rake::Task[:spec].invoke Rake::Task[:spec].invoke
end end

4
Vagrantfile vendored
View file

@ -1,3 +1,3 @@
Vagrant.configure("2") do |config| Vagrant.configure('2') do |config|
config.vm.box = "genebean/centos-7-nocm" config.vm.box = 'genebean/centos-7-nocm'
end end

View file

@ -12,7 +12,8 @@ if OS.mac?
elsif Integer(stdout.strip.split('.')[0]) < 10 elsif Integer(stdout.strip.split('.')[0]) < 10
puts "Wow... you're sure running an old os (#{stdout.strip} to be exact)" puts "Wow... you're sure running an old os (#{stdout.strip} to be exact)"
else else
abort("It seems you are on a Mac but I don't know what to do on v#{stdout.strip}") abort("It seems you are on a Mac but I don't know what to do on \
v#{stdout.strip}")
end end
elsif OS.liux? elsif OS.liux?
puts 'It seems you are on Linux' puts 'It seems you are on Linux'

View file

@ -1,4 +1,4 @@
forge "http://forge.puppetlabs.com" # rubocop:disable FileName
forge 'http://forge.puppetlabs.com'
mod 'puppetlabs-vcsrepo', '1.5.0' mod 'puppetlabs-vcsrepo', '1.5.0'

View file

@ -1,10 +0,0 @@
#!/usr/bin/env ruby
require 'json'
environmentpath = ARGV[0]
environment = ARGV[1]
r10k_deploy_file_path = File.join(environmentpath, environment, '.r10k-deploy.json')
# output the sha1 from the control-repo
puts JSON.parse(File.read(r10k_deploy_file_path))['signature']

View file

@ -1,11 +1,10 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
require 'rugged' require 'rugged'
rescue LoadError => e rescue LoadError
t = Time.new t = Time.new
puts t.to_i puts t.to_i
else else
environmentpath = ARGV[0] environmentpath = ARGV[0]
environment = ARGV[1] environment = ARGV[1]
@ -16,7 +15,7 @@ else
head_sha = head.target_id head_sha = head.target_id
# the commit message associated the newest commit # the commit message associated the newest commit
commit = repo.lookup(head_sha) # commit = repo.lookup(head_sha)
# add something to find the remote url # add something to find the remote url