Mercurial > repos > other > Puppet
annotate modules/translate/Rakefile @ 245:b0f8b88fea5c
Add "translate" module used by MySQL module
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Dec 2019 14:12:10 -0500 |
parents | |
children |
rev | line source |
---|---|
245
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 require 'puppetlabs_spec_helper/rake_tasks' |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 require 'puppet-syntax/tasks/puppet-syntax' |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 def changelog_user |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 return unless Rake.application.top_level_tasks.include? "changelog" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 returnVal = nil || JSON.load(File.read('metadata.json'))['author'] |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 puts "GitHubChangelogGenerator user:#{returnVal}" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 returnVal |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 end |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 def changelog_project |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 return unless Rake.application.top_level_tasks.include? "changelog" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 returnVal = nil |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 returnVal ||= begin |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 metadata_source = JSON.load(File.read('metadata.json'))['source'] |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 metadata_source_match && metadata_source_match[1] |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 end |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 puts "GitHubChangelogGenerator project:#{returnVal}" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 returnVal |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 end |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 def changelog_future_release |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 return unless Rake.application.top_level_tasks.include? "changelog" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 puts "GitHubChangelogGenerator future_release:#{returnVal}" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 returnVal |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 end |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 PuppetLint.configuration.send('disable_relative') |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 if Bundler.rubygems.find_name('github_changelog_generator').any? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 GitHubChangelogGenerator::RakeTask.new :changelog do |config| |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 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? |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 config.user = "#{changelog_user}" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 config.project = "#{changelog_project}" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 config.future_release = "#{changelog_future_release}" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 config.exclude_labels = ['maintenance'] |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 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)." |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 config.add_pr_wo_labels = true |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 config.issues = false |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 config.configure_sections = { |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 "Changed" => { |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 "prefix" => "### Changed", |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 "labels" => ["backwards-incompatible"], |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 }, |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 "Added" => { |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 "prefix" => "### Added", |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 "labels" => ["feature", "enhancement"], |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 }, |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 "Fixed" => { |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 "prefix" => "### Fixed", |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 "labels" => ["bugfix"], |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 }, |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 } |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 end |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 else |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 desc 'Generate a Changelog from GitHub' |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 task :changelog do |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 raise <<EOM |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 The changelog tasks depends on unreleased features of the github_changelog_generator gem. |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 Please manually add it to your .sync.yml for now, and run `pdk update`: |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 --- |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 Gemfile: |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 optional: |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 ':development': |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 - gem: 'github_changelog_generator' |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 git: 'https://github.com/skywinder/github-changelog-generator' |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')" |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 EOM |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 end |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 end |
b0f8b88fea5c
Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 |