Révision 186a64ca
Add gemfile and rakefile for Puppet lint and spec
Gemfile | ||
---|---|---|
1 |
source ENV['GEM_SOURCE'] || 'https://rubygems.org' |
|
2 |
|
|
3 |
def location_for(place_or_version, fake_version = nil) |
|
4 |
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?} |
|
5 |
file_url_regex = %r{\Afile:\/\/(?<path>.*)} |
|
6 |
|
|
7 |
if place_or_version && (git_url = place_or_version.match(git_url_regex)) |
|
8 |
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact |
|
9 |
elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) |
|
10 |
['>= 0', { path: File.expand_path(file_url[:path]), require: false }] |
|
11 |
else |
|
12 |
[place_or_version, { require: false }] |
|
13 |
end |
|
14 |
end |
|
15 |
|
|
16 |
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments |
|
17 |
minor_version = ruby_version_segments[0..1].join('.') |
|
18 |
|
|
19 |
group :development do |
|
20 |
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') |
|
21 |
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') |
|
22 |
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') |
|
23 |
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') |
|
24 |
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) |
|
25 |
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) |
|
26 |
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] |
|
27 |
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] |
|
28 |
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] |
|
29 |
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] |
|
30 |
end |
|
31 |
|
|
32 |
puppet_version = ENV['PUPPET_GEM_VERSION'] |
|
33 |
facter_version = ENV['FACTER_GEM_VERSION'] |
|
34 |
hiera_version = ENV['HIERA_GEM_VERSION'] |
|
35 |
|
|
36 |
gems = {} |
|
37 |
|
|
38 |
gems['puppet'] = location_for(puppet_version) |
|
39 |
|
|
40 |
# If facter or hiera versions have been specified via the environment |
|
41 |
# variables |
|
42 |
|
|
43 |
gems['facter'] = location_for(facter_version) if facter_version |
|
44 |
gems['hiera'] = location_for(hiera_version) if hiera_version |
|
45 |
|
|
46 |
if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} |
|
47 |
# If we're using a Puppet gem on Windows which handles its own win32-xxx gem |
|
48 |
# dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). |
|
49 |
gems['win32-dir'] = ['<= 0.4.9', require: false] |
|
50 |
gems['win32-eventlog'] = ['<= 0.6.5', require: false] |
|
51 |
gems['win32-process'] = ['<= 0.7.5', require: false] |
|
52 |
gems['win32-security'] = ['<= 0.2.5', require: false] |
|
53 |
gems['win32-service'] = ['0.8.8', require: false] |
|
54 |
end |
|
55 |
|
|
56 |
gems.each do |gem_name, gem_params| |
|
57 |
gem gem_name, *gem_params |
|
58 |
end |
|
59 |
|
|
60 |
# Evaluate Gemfile.local and ~/.gemfile if they exist |
|
61 |
extra_gemfiles = [ |
|
62 |
"#{__FILE__}.local", |
|
63 |
File.join(Dir.home, '.gemfile'), |
|
64 |
] |
|
65 |
|
|
66 |
extra_gemfiles.each do |gemfile| |
|
67 |
if File.file?(gemfile) && File.readable?(gemfile) |
|
68 |
eval(File.read(gemfile), binding) |
|
69 |
end |
|
70 |
end |
|
71 |
# vim: syntax=ruby |
Rakefile | ||
---|---|---|
1 |
require 'puppetlabs_spec_helper/rake_tasks' |
|
2 |
require 'puppet-syntax/tasks/puppet-syntax' |
|
3 |
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? |
|
4 |
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? |
|
5 |
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? |
|
6 |
|
|
7 |
def changelog_user |
|
8 |
return unless Rake.application.top_level_tasks.include? "changelog" |
|
9 |
returnVal = nil || JSON.load(File.read('metadata.json'))['author'] |
|
10 |
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? |
|
11 |
puts "GitHubChangelogGenerator user:#{returnVal}" |
|
12 |
returnVal |
|
13 |
end |
|
14 |
|
|
15 |
def changelog_project |
|
16 |
return unless Rake.application.top_level_tasks.include? "changelog" |
|
17 |
returnVal = nil || JSON.load(File.read('metadata.json'))['name'] |
|
18 |
raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? |
|
19 |
puts "GitHubChangelogGenerator project:#{returnVal}" |
|
20 |
returnVal |
|
21 |
end |
|
22 |
|
|
23 |
def changelog_future_release |
|
24 |
return unless Rake.application.top_level_tasks.include? "changelog" |
|
25 |
returnVal = JSON.load(File.read('metadata.json'))['version'] |
|
26 |
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? |
|
27 |
puts "GitHubChangelogGenerator future_release:#{returnVal}" |
|
28 |
returnVal |
|
29 |
end |
|
30 |
|
|
31 |
PuppetLint.configuration.send('disable_relative') |
|
32 |
|
|
33 |
if Bundler.rubygems.find_name('github_changelog_generator').any? |
|
34 |
GitHubChangelogGenerator::RakeTask.new :changelog do |config| |
|
35 |
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? |
|
36 |
config.user = "#{changelog_user}" |
|
37 |
config.project = "#{changelog_project}" |
|
38 |
config.future_release = "#{changelog_future_release}" |
|
39 |
config.exclude_labels = ['maintenance'] |
|
40 |
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)." |
|
41 |
config.add_pr_wo_labels = true |
|
42 |
config.issues = false |
|
43 |
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" |
|
44 |
config.configure_sections = { |
|
45 |
"Changed" => { |
|
46 |
"prefix" => "### Changed", |
|
47 |
"labels" => ["backwards-incompatible"], |
|
48 |
}, |
|
49 |
"Added" => { |
|
50 |
"prefix" => "### Added", |
|
51 |
"labels" => ["feature", "enhancement"], |
|
52 |
}, |
|
53 |
"Fixed" => { |
|
54 |
"prefix" => "### Fixed", |
|
55 |
"labels" => ["bugfix"], |
|
56 |
}, |
|
57 |
} |
|
58 |
end |
|
59 |
else |
|
60 |
desc 'Generate a Changelog from GitHub' |
|
61 |
task :changelog do |
|
62 |
raise <<EOM |
|
63 |
The changelog tasks depends on unreleased features of the github_changelog_generator gem. |
|
64 |
Please manually add it to your .sync.yml for now, and run `pdk update`: |
|
65 |
--- |
|
66 |
Gemfile: |
|
67 |
optional: |
|
68 |
':development': |
|
69 |
- gem: 'github_changelog_generator' |
|
70 |
git: 'https://github.com/skywinder/github-changelog-generator' |
|
71 |
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' |
|
72 |
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')" |
|
73 |
EOM |
|
74 |
end |
|
75 |
end |
Formats disponibles : Unified diff