forked from puppetlabs/puppetlabs-puppet_agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
73 lines (67 loc) · 3.06 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
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_puppet_url_without_modules')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.send('disable_only_variable_string')
desc 'Generate pooler nodesets'
task :gen_nodeset do
require 'beaker-hostgenerator'
require 'securerandom'
require 'fileutils'
agent_target = ENV['TEST_TARGET']
if ! agent_target
STDERR.puts 'TEST_TARGET environment variable is not set'
STDERR.puts 'setting to default value of "redhat-64default."'
agent_target = 'redhat-64default.'
end
master_target = ENV['MASTER_TEST_TARGET']
if ! master_target
STDERR.puts 'MASTER_TEST_TARGET environment variable is not set'
STDERR.puts 'setting to default value of "redhat7-64mdcl"'
master_target = 'redhat7-64mdcl'
end
targets = "#{master_target}-#{agent_target}"
cli = BeakerHostGenerator::CLI.new([targets])
nodeset_dir = "tmp/nodesets"
nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml"
FileUtils.mkdir_p(nodeset_dir)
File.open(nodeset, 'w') do |fh|
fh.print(cli.execute)
end
puts nodeset
end
desc "verify that commit messages match CONTRIBUTING.md requirements"
task(:commits) do
# This rake task looks at the summary from every commit from this branch not
# in the branch targeted for a PR. This is accomplished by using the
# TRAVIS_COMMIT_RANGE environment variable, which is present in travis CI and
# populated with the range of commits the PR contains. If not available, this
# falls back to `master..HEAD` as a next best bet as `master` is unlikely to
# ever be absent.
commit_range = ENV['TRAVIS_COMMIT_RANGE'].nil? ? 'master..HEAD' : ENV['TRAVIS_COMMIT_RANGE'].sub(/\.\.\./, '..')
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.
# The exception tries to explain it in more full.
if /^\((maint|packaging|doc|docs|modules-\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(MODULES-<digits>) # this is most common and should be a ticket at tickets.puppet.com\n" \
"\t\t(docs)\n" \
"\t\t(docs)(DOCUMENT-<digits>)\n" \
"\t\t(packaging)\n"
"\t\t(maint)\n" \
"\n\tThis test for the commit summary is case-insensitive.\n\n\n"
else
puts "#{commit_summary}"
end
puts "...passed"
end
end