Skip to content

Commit 148c0dc

Browse files
committed
Update to latest pdk
1 parent e79970a commit 148c0dc

11 files changed

+171
-36
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222
/convert_report.txt
2323
/update_report.txt
2424
.DS_Store
25+
.project
26+
.envrc
27+
/inventory.yaml

.gitlab-ci.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
stages:
3+
- syntax
4+
- unit
5+
6+
cache:
7+
paths:
8+
- vendor/bundle
9+
10+
before_script:
11+
- bundle -v
12+
- rm Gemfile.lock || true
13+
- gem update --system $RUBYGEMS_VERSION
14+
- gem --version
15+
- bundle -v
16+
- bundle install --without system_tests --path vendor/bundle --jobs $(nproc)
17+
18+
syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.3-Puppet ~> 6:
19+
stage: syntax
20+
image: ruby:2.5.3
21+
script:
22+
- bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
23+
variables:
24+
PUPPET_GEM_VERSION: '~> 6'
25+
26+
parallel_spec-Ruby 2.5.3-Puppet ~> 6:
27+
stage: unit
28+
image: ruby:2.5.3
29+
script:
30+
- bundle exec rake parallel_spec
31+
variables:
32+
PUPPET_GEM_VERSION: '~> 6'
33+
34+
parallel_spec-Ruby 2.4.5-Puppet ~> 5:
35+
stage: unit
36+
image: ruby:2.4.5
37+
script:
38+
- bundle exec rake parallel_spec
39+
variables:
40+
PUPPET_GEM_VERSION: '~> 5'
41+

.pdkignore

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
/convert_report.txt
2323
/update_report.txt
2424
.DS_Store
25+
.project
26+
.envrc
27+
/inventory.yaml
2528
/appveyor.yml
2629
/.fixtures.yml
2730
/Gemfile
@@ -30,8 +33,10 @@
3033
/.gitlab-ci.yml
3134
/.pdkignore
3235
/Rakefile
36+
/rakelib/
3337
/.rspec
3438
/.rubocop.yml
3539
/.travis.yml
3640
/.yardopts
3741
/spec/
42+
/.vscode/

.rubocop.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
require: rubocop-rspec
2+
require:
3+
- rubocop-rspec
4+
- rubocop-i18n
35
AllCops:
46
DisplayCopNames: true
57
TargetRubyVersion: '2.1'
@@ -19,10 +21,12 @@ AllCops:
1921
Metrics/LineLength:
2022
Description: People have wide screens, use them.
2123
Max: 200
24+
GetText:
25+
Enabled: false
2226
GetText/DecorateString:
2327
Description: We don't want to decorate test output.
2428
Exclude:
25-
- spec/*
29+
- spec/**/*
2630
RSpec/BeforeAfterAll:
2731
Description: Beware of using after(:all) as it may cause state to leak between tests.
2832
A necessary evil in acceptance testing.

.travis.yml

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
dist: trusty
2+
dist: xenial
33
language: ruby
44
cache: bundler
55
before_install:
@@ -12,32 +12,34 @@ script:
1212
- 'bundle exec rake $CHECK'
1313
bundler_args: --without system_tests
1414
rvm:
15-
- 2.5.1
16-
env:
17-
global:
18-
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0"
15+
- 2.5.3
16+
stages:
17+
- static
18+
- spec
19+
- acceptance
20+
-
21+
if: tag =~ ^v\d
22+
name: deploy
1923
matrix:
2024
fast_finish: true
2125
include:
2226
-
23-
env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
24-
-
25-
env: CHECK=parallel_spec
27+
env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
28+
stage: static
2629
-
2730
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
28-
rvm: 2.4.4
31+
rvm: 2.4.5
32+
stage: spec
33+
-
34+
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
35+
rvm: 2.5.3
36+
stage: spec
37+
-
38+
env: DEPLOY_TO_FORGE=yes
39+
stage: deploy
2940
branches:
3041
only:
3142
- master
3243
- /^v\d/
3344
notifications:
3445
email: false
35-
deploy:
36-
provider: puppetforge
37-
user: puppet
38-
password:
39-
secure: ""
40-
on:
41-
tags: true
42-
all_branches: true
43-
condition: "$DEPLOY_TO_FORGE = yes"

.vscode/extensions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"jpogran.puppet-vscode",
4+
"rebornix.Ruby"
5+
]
6+
}

Gemfile

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
1717
minor_version = ruby_version_segments[0..1].join('.')
1818

1919
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]
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 "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
27+
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
28+
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
29+
gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
30+
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3031
end
3132

3233
puppet_version = ENV['PUPPET_GEM_VERSION']

Rakefile

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
12
require 'puppetlabs_spec_helper/rake_tasks'
23
require 'puppet-syntax/tasks/puppet-syntax'
34
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
@@ -14,15 +15,24 @@ end
1415

1516
def changelog_project
1617
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?
18+
19+
returnVal = nil
20+
returnVal ||= begin
21+
metadata_source = JSON.load(File.read('metadata.json'))['source']
22+
metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z})
23+
24+
metadata_source_match && metadata_source_match[1]
25+
end
26+
27+
raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil?
28+
1929
puts "GitHubChangelogGenerator project:#{returnVal}"
2030
returnVal
2131
end
2232

2333
def changelog_future_release
2434
return unless Rake.application.top_level_tasks.include? "changelog"
25-
returnVal = JSON.load(File.read('metadata.json'))['version']
35+
returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
2636
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
2737
puts "GitHubChangelogGenerator future_release:#{returnVal}"
2838
returnVal

appveyor.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
version: 1.1.x.{build}
3+
branches:
4+
only:
5+
- master
6+
- release
7+
skip_commits:
8+
message: /^\(?doc\)?.*/
9+
clone_depth: 10
10+
init:
11+
- SET
12+
- 'mkdir C:\ProgramData\PuppetLabs\code && exit 0'
13+
- 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0'
14+
- 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0'
15+
- 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0'
16+
environment:
17+
matrix:
18+
-
19+
RUBY_VERSION: 24-x64
20+
CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
21+
-
22+
PUPPET_GEM_VERSION: ~> 5.0
23+
RUBY_VERSION: 24
24+
CHECK: parallel_spec
25+
-
26+
PUPPET_GEM_VERSION: ~> 5.0
27+
RUBY_VERSION: 24-x64
28+
CHECK: parallel_spec
29+
-
30+
PUPPET_GEM_VERSION: ~> 6.0
31+
RUBY_VERSION: 25
32+
CHECK: parallel_spec
33+
-
34+
PUPPET_GEM_VERSION: ~> 6.0
35+
RUBY_VERSION: 25-x64
36+
CHECK: parallel_spec
37+
matrix:
38+
fast_finish: true
39+
install:
40+
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
41+
- bundle install --jobs 4 --retry 2 --without system_tests
42+
- type Gemfile.lock
43+
build: off
44+
test_script:
45+
- bundle exec puppet -V
46+
- ruby -v
47+
- gem -v
48+
- bundle -v
49+
- bundle exec rake %CHECK%
50+
notifications:
51+
- provider: Email
52+
to:
53+
54+
on_build_success: false
55+
on_build_failure: false
56+
on_build_status_changed: false

metadata.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"npm",
104104
"bower"
105105
],
106-
"pdk-version": "1.9.1",
107-
"template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
108-
"template-ref": "1.9.1-0-g6945d31"
106+
"pdk-version": "1.13.0",
107+
"template-url": "https://github.com/puppetlabs/pdk-templates#1.13.0",
108+
"template-ref": "tags/1.13.0-0-g66e1443"
109109
}

spec/spec_helper.rb

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
end
2626
end
2727

28+
# read default_facts and merge them over what is provided by facterdb
29+
default_facts.each do |fact, value|
30+
add_custom_fact fact, value
31+
end
32+
2833
RSpec.configure do |c|
2934
c.default_facts = default_facts
3035
c.before :each do
@@ -37,6 +42,8 @@
3742
end
3843
end
3944

45+
# Ensures that a module is defined
46+
# @param module_name Name of the module
4047
def ensure_module_defined(module_name)
4148
module_name.split('::').reduce(Object) do |last_module, next_module|
4249
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)

0 commit comments

Comments
 (0)