-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
75 lines (64 loc) · 2.36 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
69
70
71
72
73
74
75
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'
rootdir = File.dirname(__FILE__)
ENV['SSL_CERT_FILE'] = "#{rootdir}/cacert.pem" unless ENV['SSL_CERT_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 |task, args|
begin
sh "kitchen test windows-2012r2 --destroy=#{destroy_strategy} --concurrency --log-level=info"
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
Dir.glob('**/*.pp').each do |puppet_file|
Bundler.with_clean_env do
# Use bundler.with_clean_env as the way bundler set ruby environment variables
# is killing puppet on windows.
# Note that we may instead want to add puppet to our Gemfiles but we are currently seeing
# gem dependency conflicts between test-kitchen and puppet...
# Since we already have puppet installed on our build/test agents, let's use it.
sh "puppet parser validate #{puppet_file}"
end
end
end
require 'puppet-lint/tasks/puppet-lint'
Rake::Task[:lint].clear
desc 'puppet-lint all the manifests'
PuppetLint::RakeTask.new :lint do |config|
# # Pattern of files to ignore
# config.ignore_paths = ['modules/apt', 'modules/stdlib']
# List of checks to disable
config.disable_checks = ['80chars', 'trailing_whitespace', '2sp_soft_tabs', 'hard_tabs']
# # Enable automatic fixing of problems, defaults to false
# config.fix = 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