-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
68 lines (60 loc) · 2.05 KB
/
Rakefile
1
2
3
4
5
6
7
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'rake'
require 'rake_performance'
require 'find'
require 'fileutils'
require 'bundler/setup'
# always destroy the kitchen when running within Teamcity
destroy_strategy = ENV['TEAMCITY_VERSION'] ? 'always' : 'passing'
color = ENV['TEAMCITY_VERSION'] ? '--no-color' : '--color'
ENV['PUPPET_COLOR'] = '--color false' if ENV['TEAMCITY_VERSION']
rootdir = File.dirname(__FILE__)
namespace :acceptance do
desc 'Install puppet modules from Puppetfile'
task :installpuppetmodules do
sh 'bundle exec r10k puppetfile install --verbose'
end
desc 'Execute the acceptance tests'
task kitchen: [:installpuppetmodules] do
begin
Dir.mkdir('.kitchen') unless Dir.exist?('.kitchen')
sh "kitchen test --destroy=#{destroy_strategy} --concurrency 2 --log-level=info #{color} 2> .kitchen/kitchen.stderr" do |ok, _|
raise IO.read('.kitchen/kitchen.stderr') unless ok
end
ensure
puts "##teamcity[publishArtifacts '#{Dir.pwd}/.kitchen/logs/*.log => logs.zip']"
end
end
end
namespace :check do
namespace :manifests do
desc 'Validate syntax for all manifests'
task :syntax do
Bundler.with_unbundled_env do
# Use bundler.with_clean_env as the way bundler set ruby environment variables
# is killing puppet on windows.
sh "puppet parser validate #{rootdir}"
end
end
require 'puppet-lint/tasks/puppet-lint'
Rake::Task[:lint].clear
desc 'puppet-lint all the manifests'
PuppetLint::RakeTask.new :lint do |config|
# List of checks to disable
config.disable_checks = %w(80chars trailing_whitespace 2sp_soft_tabs hard_tabs)
config.relative = true
end
end
namespace :ruby do
desc 'Validate syntax for all ruby files'
task :syntax do
Dir.glob('**/*.rb').each do |ruby_file|
sh "ruby -c #{ruby_file}"
end
Dir.glob('**/*.erb').each do |erb_file|
sh "erb -P -x -T '-' #{erb_file} | ruby -c"
end
end
end
end
task checks: ['check:manifests:syntax', 'check:manifests:lint', 'check:ruby:syntax']
task default: :checks