-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRakefile
More file actions
83 lines (73 loc) · 3.62 KB
/
Rakefile
File metadata and controls
83 lines (73 loc) · 3.62 KB
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
76
77
78
79
80
81
82
83
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__)
ENV['SSL_CERT_FILE'] = "#{rootdir}/cacert.pem" unless ENV['SSL_CERT_FILE']
namespace :acceptance do
task :prerequisites do
raise 'Environment variable KITCHEN_YAML should be set to either .kitchen.oldsqlservers.yml, .kitchen.sqlservers.yml or .kitchen.ssms.yml' unless ENV['KITCHEN_YAML']
case ENV['KITCHEN_YAML']
when '.kitchen.oldsqlservers.yml'
raise 'Environment variable SQLSERVER2005_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2005_ISO_URL']
when '.kitchen.sqlservers.yml'
raise 'Environment variable SQLSERVER2008_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2008_ISO_URL']
raise 'Environment variable SQLSERVER2008R2_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2008R2_ISO_URL']
raise 'Environment variable SQLSERVER2012_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2012_ISO_URL']
raise 'Environment variable SQLSERVER2014_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2014_ISO_URL']
raise 'Environment variable SQLSERVER2016_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2016_ISO_URL']
raise 'Environment variable SQLSERVER2017_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2017_ISO_URL']
raise 'Environment variable SQLSERVER2019_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2019_ISO_URL']
raise 'Environment variable SQLSERVER2022_ISO_URL must be set to be able to run our acceptance tests' unless ENV['SQLSERVER2022_ISO_URL']
end
end
desc 'Install puppet modules from Puppetfile'
task :installpuppetmodules do
sh 'bundle exec r10k puppetfile install --verbose'
end
desc 'Execute the acceptance tests'
task kitchen: [:prerequisites, :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
sh "puppet parser validate #{rootdir}"
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