forked from voxpupuli/rspec-puppet-facts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
80 lines (68 loc) · 2.28 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
74
75
76
77
78
79
80
require 'bundler/gem_tasks'
PUPPET_VERSIONS_PATH = File.join(__dir__, 'ext', 'puppet_agent_components.json')
begin
require 'rspec/core/rake_task'
require 'yard'
RSpec::Core::RakeTask.new(:spec)
YARD::Rake::YardocTask.new
rescue LoadError
# yard is optional
end
desc 'Produce Commit history since last tag'
task :dump_commit do
last_tag = `git describe --tags $(git rev-list --tags --max-count=1)`.chomp
puts "############ Commits since #{last_tag} ######"
puts `git log --pretty=format:"- %s" #{last_tag}..HEAD`
end
namespace :puppet_versions do
task :update do
require 'net/http'
require 'net/https'
require 'uri'
uri = URI.parse('https://forgeapi.puppet.com/private/versions/puppet-agent')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
raise unless response.is_a?(Net::HTTPSuccess)
File.open(PUPPET_VERSIONS_PATH, 'wb:UTF-8') do |fd|
fd.write(response.body)
end
end
task :test do
Rake::Task['puppet_versions:update'].invoke
output = `git status --porcelain #{PUPPET_VERSIONS_PATH}`
unless output.strip.empty?
$stderr.puts "#{PUPPET_VERSIONS_PATH} is out of date."
$stderr.puts 'Run the puppet_versions:update task to update it and commit the changes.'
raise
end
end
end
begin
require 'rubygems'
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog}
config.user = 'voxpupuli'
config.project = 'rspec-puppet-facts'
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
config.future_release = gem_version
end
rescue LoadError
# Changelog generator is optional
end
begin
require 'rubocop/rake_task'
rescue LoadError
# RuboCop is an optional group
else
RuboCop::RakeTask.new(:rubocop) do |task|
# These make the rubocop experience maybe slightly less terrible
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
# Use Rubocop's Github Actions formatter if possible
if ENV['GITHUB_ACTIONS'] == 'true'
task.formatters << 'github'
end
end
end