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
|
begin
require 'rubygems'
require 'rspec/core/rake_task'
rescue LoadError
end
Dir['tasks/**/*.rake'].each { |t| load t }
if Rake.application.top_level_tasks.grep(/^(pl:|package:)/).any?
begin
require 'packaging'
Pkg::Util::RakeUtils.load_packaging_tasks
rescue LoadError => e
puts "Error loading packaging rake tasks: #{e}"
end
end
namespace :package do
task :bootstrap do
puts 'Bootstrap is no longer needed, using packaging-as-a-gem'
end
task :implode do
puts 'Implode is no longer needed, using packaging-as-a-gem'
end
end
task :spec do
sh %{rspec #{ENV['TEST'] || ENV['TESTS'] || 'spec'}}
end
task :test => :spec
desc "verify that commit messages match CONTRIBUTING.md requirements"
task(:commits) do
# This git command looks at the summary from every commit from this branch not in master.
# Ideally this would compare against the branch that a PR is submitted against, but I don't
# know how to get that information. Absent that, comparing with master should work in most cases.
commit_range = 'HEAD^..HEAD'
puts "Checking commits #{commit_range}"
%x{git log --no-merges --pretty=%s #{commit_range}}.each_line do |commit_summary|
# This regex tests for the currently supported commit summary tokens: maint, doc, packaging, or hi-<number>.
# The exception tries to explain it in more full.
if /^\((maint|doc|packaging|hi-\d+)\)|revert/i.match(commit_summary).nil?
raise "\n\n\n\tThis commit summary didn't match CONTRIBUTING.md guidelines:\n" \
"\n\t\t#{commit_summary}\n" \
"\tThe commit summary (i.e. the first line of the commit message) should start with one of:\n" \
"\t\t(hi-<digits>) # this is most common and should be a ticket at tickets.puppetlabs.com\n" \
"\t\t(doc)\n" \
"\t\t(maint)\n" \
"\t\t(packaging)\n" \
"\n\tThis test for the commit summary is case-insensitive.\n\n\n"
end
end
end
task :default do
sh 'rake -T'
end
|