Skip to content

Commit bc65216

Browse files
author
Ciprian Badescu
committed
(MODULES-11244) save existing tasks as internal tasks
save `commits` and `gen_nodeset` in `rakelib`
1 parent 14cfb2c commit bc65216

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

rakelib/commits.rake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
desc "verify that commit messages match CONTRIBUTING.md requirements"
2+
task(:commits) do
3+
# This rake task looks at the summary from every commit from this branch not
4+
# in the branch targeted for a PR.
5+
commit_range = 'HEAD^..HEAD'
6+
puts "Checking commits #{commit_range}"
7+
%x{git log --no-merges --pretty=%s #{commit_range}}.each_line do |commit_summary|
8+
# This regex tests for the currently supported commit summary tokens.
9+
# The exception tries to explain it in more full.
10+
if /^\((maint|packaging|doc|docs|modules-\d+)\)|revert/i.match(commit_summary).nil?
11+
raise "\n\n\n\tThis commit summary didn't match CONTRIBUTING.md guidelines:\n" \
12+
"\n\t\t#{commit_summary}\n" \
13+
"\tThe commit summary (i.e. the first line of the commit message) should start with one of:\n" \
14+
"\t\t(MODULES-<digits>) # this is most common and should be a ticket at tickets.puppet.com\n" \
15+
"\t\t(docs)\n" \
16+
"\t\t(docs)(DOCUMENT-<digits>)\n" \
17+
"\t\t(packaging)\n"
18+
"\t\t(maint)\n" \
19+
"\n\tThis test for the commit summary is case-insensitive.\n\n\n"
20+
else
21+
puts "#{commit_summary}"
22+
end
23+
puts "...passed"
24+
end
25+
end

rakelib/gen_nodeset.rake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
desc 'Generate pooler nodesets'
2+
task :gen_nodeset do
3+
require 'beaker-hostgenerator'
4+
require 'securerandom'
5+
require 'fileutils'
6+
7+
agent_target = ENV['TEST_TARGET']
8+
if ! agent_target
9+
STDERR.puts 'TEST_TARGET environment variable is not set'
10+
STDERR.puts 'setting to default value of "redhat-64default."'
11+
agent_target = 'redhat-64default.'
12+
end
13+
14+
master_target = ENV['MASTER_TEST_TARGET']
15+
if ! master_target
16+
STDERR.puts 'MASTER_TEST_TARGET environment variable is not set'
17+
STDERR.puts 'setting to default value of "redhat7-64mdcl"'
18+
master_target = 'redhat7-64mdcl'
19+
end
20+
21+
targets = "#{master_target}-#{agent_target}"
22+
cli = BeakerHostGenerator::CLI.new([targets])
23+
nodeset_dir = "tmp/nodesets"
24+
nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml"
25+
FileUtils.mkdir_p(nodeset_dir)
26+
File.open(nodeset, 'w') do |fh|
27+
fh.print(cli.execute)
28+
end
29+
puts nodeset
30+
end

0 commit comments

Comments
 (0)