2012-02-09 20:26:00 +01:00
|
|
|
require 'rubygems'
|
2011-12-19 16:25:35 +01:00
|
|
|
require 'rake'
|
2012-02-09 20:26:00 +01:00
|
|
|
require 'rspec/core/rake_task'
|
2011-12-19 16:25:35 +01:00
|
|
|
require 'fileutils'
|
|
|
|
|
2012-02-09 20:26:00 +01:00
|
|
|
task :default do
|
|
|
|
system("rake -T")
|
2011-12-19 16:25:35 +01:00
|
|
|
end
|
|
|
|
|
2012-02-09 20:26:00 +01:00
|
|
|
desc "Run all rspec-puppet tests"
|
|
|
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
|
|
t.rspec_opts = ['--color']
|
|
|
|
# ignores fixtures directory.
|
|
|
|
t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
|
|
|
|
end
|
2011-12-19 16:25:35 +01:00
|
|
|
|
|
|
|
def update_module_version
|
|
|
|
gitdesc = %x{git describe}.chomp
|
|
|
|
semver = gitdesc.gsub(/v?(\d+\.\d+\.\d+)-?(.*)/) do
|
|
|
|
newver = "#{$1}"
|
|
|
|
newver << "git-#{$2}" unless $2.empty?
|
|
|
|
newver
|
|
|
|
end
|
|
|
|
modulefile = File.read("Modulefile")
|
|
|
|
modulefile.gsub!(/^\s*version\s+'.*?'/, "version '#{semver}'")
|
|
|
|
File.open("Modulefile", 'w') do |f|
|
|
|
|
f.write(modulefile)
|
|
|
|
end
|
|
|
|
semver
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Build Puppet Module Package"
|
|
|
|
task :build do
|
|
|
|
system("gimli README*.markdown")
|
|
|
|
FileUtils.cp "Modulefile", "Modulefile.bak"
|
|
|
|
update_module_version
|
|
|
|
system("puppet-module build")
|
|
|
|
FileUtils.mv "Modulefile.bak", "Modulefile"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Clean the package directory"
|
|
|
|
task :clean do
|
|
|
|
FileUtils.rm_rf("pkg/")
|
|
|
|
end
|
|
|
|
|
2012-02-09 20:26:00 +01:00
|
|
|
desc "Check puppet manifests with puppet-lint"
|
|
|
|
task :lint do
|
|
|
|
# This requires pull request: https://github.com/rodjek/puppet-lint/pull/81
|
|
|
|
system("puppet-lint manifests")
|
|
|
|
system("puppet-lint tests")
|
2011-12-19 16:25:35 +01:00
|
|
|
end
|