Révision 78f22811
modulesync 4.0.0
Rakefile | ||
---|---|---|
1 |
# frozen_string_literal: true |
|
2 |
|
|
3 |
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? |
|
4 |
require 'puppetlabs_spec_helper/rake_tasks' |
|
5 |
require 'puppet-syntax/tasks/puppet-syntax' |
|
6 |
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? |
|
7 |
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? |
|
8 |
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? |
|
9 |
|
|
10 |
def changelog_user |
|
11 |
return unless Rake.application.top_level_tasks.include? "changelog" |
|
12 |
returnVal = nil || JSON.load(File.read('metadata.json'))['author'] |
|
13 |
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? |
|
14 |
puts "GitHubChangelogGenerator user:#{returnVal}" |
|
15 |
returnVal |
|
1 |
# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper), |
|
2 |
# otherwise attempt to load it directly. |
|
3 |
begin |
|
4 |
require 'voxpupuli/test/rake' |
|
5 |
rescue LoadError |
|
6 |
require 'puppetlabs_spec_helper/rake_tasks' |
|
16 | 7 |
end |
17 | 8 |
|
18 |
def changelog_project |
|
19 |
return unless Rake.application.top_level_tasks.include? "changelog" |
|
20 |
|
|
21 |
returnVal = nil |
|
22 |
returnVal ||= begin |
|
23 |
metadata_source = JSON.load(File.read('metadata.json'))['source'] |
|
24 |
metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) |
|
9 |
# load optional tasks for releases |
|
10 |
# only available if gem group releases is installed |
|
11 |
begin |
|
12 |
require 'voxpupuli/release/rake_tasks' |
|
13 |
rescue LoadError |
|
14 |
end |
|
25 | 15 |
|
26 |
metadata_source_match && metadata_source_match[1] |
|
16 |
desc "Run main 'test' task and report merged results to coveralls" |
|
17 |
task test_with_coveralls: [:test] do |
|
18 |
if Dir.exist?(File.expand_path('../lib', __FILE__)) |
|
19 |
require 'coveralls/rake/task' |
|
20 |
Coveralls::RakeTask.new |
|
21 |
Rake::Task['coveralls:push'].invoke |
|
22 |
else |
|
23 |
puts 'Skipping reporting to coveralls. Module has no lib dir' |
|
27 | 24 |
end |
28 |
|
|
29 |
raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? |
|
30 |
|
|
31 |
puts "GitHubChangelogGenerator project:#{returnVal}" |
|
32 |
returnVal |
|
33 | 25 |
end |
34 | 26 |
|
35 |
def changelog_future_release |
|
36 |
return unless Rake.application.top_level_tasks.include? "changelog" |
|
37 |
returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] |
|
38 |
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? |
|
39 |
puts "GitHubChangelogGenerator future_release:#{returnVal}" |
|
40 |
returnVal |
|
27 |
desc 'Generate REFERENCE.md' |
|
28 |
task :reference, [:debug, :backtrace] do |t, args| |
|
29 |
patterns = '' |
|
30 |
Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) |
|
41 | 31 |
end |
42 | 32 |
|
43 |
PuppetLint.configuration.send('disable_relative')
|
|
44 |
|
|
45 |
if Bundler.rubygems.find_name('github_changelog_generator').any?
|
|
33 |
begin
|
|
34 |
require 'github_changelog_generator/task' |
|
35 |
require 'puppet_blacksmith'
|
|
46 | 36 |
GitHubChangelogGenerator::RakeTask.new :changelog do |config| |
47 |
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? |
|
48 |
config.user = "#{changelog_user}" |
|
49 |
config.project = "#{changelog_project}" |
|
50 |
config.future_release = "#{changelog_future_release}" |
|
51 |
config.exclude_labels = ['maintenance'] |
|
52 |
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." |
|
53 |
config.add_pr_wo_labels = true |
|
54 |
config.issues = false |
|
55 |
config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" |
|
56 |
config.configure_sections = { |
|
57 |
"Changed" => { |
|
58 |
"prefix" => "### Changed", |
|
59 |
"labels" => ["backwards-incompatible"], |
|
60 |
}, |
|
61 |
"Added" => { |
|
62 |
"prefix" => "### Added", |
|
63 |
"labels" => ["enhancement", "feature"], |
|
64 |
}, |
|
65 |
"Fixed" => { |
|
66 |
"prefix" => "### Fixed", |
|
67 |
"labels" => ["bug", "documentation", "bugfix"], |
|
68 |
}, |
|
69 |
} |
|
37 |
version = (Blacksmith::Modulefile.new).version |
|
38 |
config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/ |
|
39 |
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." |
|
40 |
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} |
|
41 |
config.user = 'voxpupuli' |
|
42 |
metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') |
|
43 |
metadata = JSON.load(File.read(metadata_json)) |
|
44 |
config.project = metadata['name'] |
|
70 | 45 |
end |
71 |
else |
|
72 |
desc 'Generate a Changelog from GitHub' |
|
73 |
task :changelog do |
|
74 |
raise <<EOM |
|
75 |
The changelog tasks depends on recent features of the github_changelog_generator gem. |
|
76 |
Please manually add it to your .sync.yml for now, and run `pdk update`: |
|
77 |
--- |
|
78 |
Gemfile: |
|
79 |
optional: |
|
80 |
':development': |
|
81 |
- gem: 'github_changelog_generator' |
|
82 |
version: '~> 1.15' |
|
83 |
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" |
|
84 |
EOM |
|
46 |
|
|
47 |
# Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 |
|
48 |
require 'rbconfig' |
|
49 |
if RbConfig::CONFIG['host_os'] =~ /linux/ |
|
50 |
task :changelog do |
|
51 |
puts 'Fixing line endings...' |
|
52 |
changelog_file = File.join(__dir__, 'CHANGELOG.md') |
|
53 |
changelog_txt = File.read(changelog_file) |
|
54 |
new_contents = changelog_txt.gsub(%r{\r\n}, "\n") |
|
55 |
File.open(changelog_file, "w") {|file| file.puts new_contents } |
|
56 |
end |
|
85 | 57 |
end |
86 |
end |
|
87 | 58 |
|
59 |
rescue LoadError |
|
60 |
end |
|
61 |
# vim: syntax=ruby |
Formats disponibles : Unified diff