Skip to content

Commit 24f66b8

Browse files
authored
Merge pull request #12 from melissa/maint/master/update-pdk-1.8.0-templates
(maint) update PDK to 1.8.0; update all templates
2 parents 3260c40 + 3d22b67 commit 24f66b8

File tree

10 files changed

+123
-42
lines changed

10 files changed

+123
-42
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.erb eol=lf
33
*.pp eol=lf
44
*.sh eol=lf
5+
*.epp eol=lf

.pdkignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,16 @@
2222
/convert_report.txt
2323
/update_report.txt
2424
.DS_Store
25+
/appveyor.yml
26+
/.fixtures.yml
27+
/Gemfile
28+
/.gitattributes
29+
/.gitignore
30+
/.gitlab-ci.yml
31+
/.pdkignore
32+
/Rakefile
33+
/.rspec
34+
/.rubocop.yml
35+
/.travis.yml
36+
/.yardopts
37+
/spec/

.puppet-lint.rc

Whitespace-only changes.

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ AllCops:
1919
Metrics/LineLength:
2020
Description: People have wide screens, use them.
2121
Max: 200
22+
GetText/DecorateString:
23+
Description: We don't want to decorate test output.
24+
Exclude:
25+
- spec/*
2226
RSpec/BeforeAfterAll:
2327
Description: Beware of using after(:all) as it may cause state to leak between tests.
2428
A necessary evil in acceptance testing.

.travis.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
---
2-
sudo: false
32
dist: trusty
43
language: ruby
54
cache: bundler
65
before_install:
6+
- if [ $BUNDLER_VERSION ]; then
7+
gem install -v $BUNDLER_VERSION bundler --no-rdoc --no-ri;
8+
fi
79
- bundle -v
810
- rm -f Gemfile.lock
9-
- gem update --system
11+
- gem update --system $RUBYGEMS_VERSION
1012
- gem --version
1113
- bundle -v
1214
script:
1315
- 'bundle exec rake $CHECK'
1416
bundler_args: --without system_tests
1517
rvm:
16-
- 2.5.3
18+
- 2.5.1
1719
env:
1820
global:
19-
- PUPPET_GEM_VERSION="~> 6.0"
21+
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0"
2022
matrix:
2123
fast_finish: true
2224
include:
@@ -26,9 +28,9 @@ matrix:
2628
env: CHECK=parallel_spec
2729
-
2830
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
29-
rvm: 2.4.5
31+
rvm: 2.4.4
3032
-
31-
env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
33+
env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec RUBYGEMS_VERSION=2.7.8 BUNDLER_VERSION=1.17.3
3234
rvm: 2.1.9
3335
branches:
3436
only:

Gemfile

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
22

33
def location_for(place_or_version, fake_version = nil)
4-
if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)}
5-
[fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
6-
elsif place_or_version =~ %r{\Afile:\/\/(.*)}
7-
['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
8-
else
9-
[place_or_version, { require: false }]
10-
end
11-
end
4+
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
5+
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
126

13-
def gem_type(place_or_version)
14-
if place_or_version =~ %r{\Agit[:@]}
15-
:git
16-
elsif !place_or_version.nil? && place_or_version.start_with?('file:')
17-
:file
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 }]
1811
else
19-
:gem
12+
[place_or_version, { require: false }]
2013
end
2114
end
2215

@@ -28,7 +21,8 @@ group :development do
2821
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
2922
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
3023
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
31-
gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
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))
3226
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
3327
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
3428
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
@@ -47,7 +41,6 @@ group :system_tests do
4741
end
4842

4943
puppet_version = ENV['PUPPET_GEM_VERSION']
50-
puppet_type = gem_type(puppet_version)
5144
facter_version = ENV['FACTER_GEM_VERSION']
5245
hiera_version = ENV['HIERA_GEM_VERSION']
5346

Rakefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,76 @@
11
require 'puppetlabs_spec_helper/rake_tasks'
22
require 'puppet-syntax/tasks/puppet-syntax'
33
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
430

531
PuppetLint.configuration.send('disable_relative')
632

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
76+

metadata.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"version_requirement": ">= 6.0.0 < 7.0.0"
7979
}
8080
],
81-
"pdk-version": "1.6.0",
82-
"template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
83-
"template-ref": "1.6.0-0-gf5564c0"
84-
}
81+
"pdk-version": "1.8.0",
82+
"template-url": "https://github.com/puppetlabs/pdk-templates",
83+
"template-ref": "heads/master-0-gd61c0a4"
84+
}

spec/default_facts.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# Facts specified here will override the values provided by rspec-puppet-facts.
44
---
5-
concat_basedir: "/tmp"
65
ipaddress: "172.16.254.254"
76
is_pe: false
87
macaddress: "AA:AA:AA:AA:AA:AA"

spec/spec_helper.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
21
require 'puppetlabs_spec_helper/module_spec_helper'
32
require 'rspec-puppet-facts'
43

5-
begin
6-
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
7-
rescue LoadError => loaderror
8-
warn "Could not require spec_helper_local: #{loaderror.message}"
9-
end
4+
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
105

116
include RspecPuppetFacts
127

@@ -15,15 +10,19 @@
1510
facterversion: Facter.version,
1611
}
1712

18-
default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml'))
19-
default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
13+
default_fact_files = [
14+
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
15+
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
16+
]
2017

21-
if File.exist?(default_facts_path) && File.readable?(default_facts_path)
22-
default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
23-
end
18+
default_fact_files.each do |f|
19+
next unless File.exist?(f) && File.readable?(f) && File.size?(f)
2420

25-
if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path)
26-
default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path)))
21+
begin
22+
default_facts.merge!(YAML.safe_load(File.read(f)))
23+
rescue => e
24+
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
25+
end
2726
end
2827

2928
RSpec.configure do |c|
@@ -37,8 +36,8 @@
3736

3837
def ensure_module_defined(module_name)
3938
module_name.split('::').reduce(Object) do |last_module, next_module|
40-
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)
41-
last_module.const_get(next_module)
39+
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
40+
last_module.const_get(next_module, false)
4241
end
4342
end
4443

0 commit comments

Comments
 (0)