-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
73 lines (61 loc) · 1.96 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
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
specdir = File.join([File.dirname(__FILE__), "spec"])
require "rake"
begin
require "rspec/core/rake_task"
require "mcollective"
rescue LoadError # rubocop:disable Lint/SuppressedException
end
desc "Run rubycop style checks"
task :rubocop do
sh("rubocop")
end
desc "Run agent and application tests"
task :test do
require "#{specdir}/spec_helper.rb"
if ENV["TARGETDIR"]
test_pattern = "#{File.expand_path(ENV['TARGETDIR'])}/spec/**/*_spec.rb"
else
test_pattern = "spec/**/*_spec.rb"
end
sh "bundle exec rspec #{Dir.glob(test_pattern).sort.join(' ')}"
end
task :default => [:rubocop, :test]
desc "Set versions for a release"
task :prep_version do
abort("Please specify VERSION") unless ENV["VERSION"]
Rake::FileList["**/*.ddl"].each do |file|
sh 'sed -i"" -re \'s/([\t ]+:version[\t ]+=>[\t ]+").+/\\1%s",/\' %s' % [ENV["VERSION"], file]
end
Rake::FileList["**/*.json"].each do |file|
sh 'sed -i"" -re \'s/("version": ").+/\\1%s",/\' %s' % [ENV["VERSION"], file]
end
changelog = File.read("CHANGELOG.md")
File.open("CHANGELOG.md", "w") do |f|
done = false
changelog.lines.each do |line|
if line =~ /^## / && !done
done = true
puts "Adding a new entry to CHANGELOG.md:"
puts "-------------------- 8< --------------------"
new_entry = <<~END_CHANGELOG
## #{ENV['VERSION']}
Released #{Time.now.strftime('%Y-%m-%d')}
#{`git log --oneline $(git tag | tail -n 1)..HEAD`.lines.map { |l| l.sub(/^/, ' * ')}.join}
END_CHANGELOG
puts new_entry
puts "-------------------- 8< --------------------"
f.puts new_entry
end
f.puts line
end
end
end
# load optional tasks for releases
# only available if gem group releases is installed
begin
require "voxpupuli/release/rake_tasks"
rescue LoadError
# voxpupuli-release not present
end