Skip to content

Commit dbd7297

Browse files
authored
Migrate to PDK (DataDog#597)
Puppet Development Kit (PDK) is the recommended way to build and release Puppet modules. PDK adds a base set of files to the projects (think skel in the Unix world), which I've tried to respect and merge with the stuff we already had. Gem dependencies are now grouped under the meta-packages `puppet-module-*`, although unfortunately this is not available for Ruby 2.2 and earlier, where we still have to list dependencies manually. Also, these meta-packages don't work with unsupported combinations like Ruby 2.6 with Puppet < 6, so I had to remove those from the test matrix. I haven't enabled the rubocop check since it has lots of offenses, but will do so on a separate PR. Releases of the module can now be done using `pdk build`.
1 parent 3515097 commit dbd7297

11 files changed

Lines changed: 514 additions & 171 deletions

File tree

.circleci/config.yml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,34 +164,48 @@ jobs:
164164
RUBY_VERSION: '2.4.3'
165165
PUPPET_VERSION: '6.5.0'
166166

167-
specs-ruby26-puppet46:
167+
specs-ruby25-puppet46:
168168
<<: *specs
169169
environment:
170170
STRICT_VARIABLES: 'yes'
171-
RUBY_VERSION: '2.6.3'
171+
RUBY_VERSION: '2.5.3'
172172
PUPPET_VERSION: '4.6.2'
173173

174-
specs-ruby26-puppet410:
174+
specs-ruby25-puppet410:
175175
<<: *specs
176176
environment:
177177
STRICT_VARIABLES: 'yes'
178-
RUBY_VERSION: '2.6.3'
178+
RUBY_VERSION: '2.5.3'
179179
PUPPET_VERSION: '4.10.9'
180180

181-
specs-ruby26-puppet50:
181+
specs-ruby25-puppet50:
182182
<<: *specs
183183
environment:
184184
STRICT_VARIABLES: 'yes'
185-
RUBY_VERSION: '2.6.3'
185+
RUBY_VERSION: '2.5.3'
186186
PUPPET_VERSION: '5.0.1'
187187

188-
specs-ruby26-puppet53:
188+
specs-ruby25-puppet53:
189189
<<: *specs
190190
environment:
191191
STRICT_VARIABLES: 'yes'
192-
RUBY_VERSION: '2.6.3'
192+
RUBY_VERSION: '2.5.3'
193193
PUPPET_VERSION: '5.3.3'
194194

195+
specs-ruby25-puppet60:
196+
<<: *specs
197+
environment:
198+
STRICT_VARIABLES: 'yes'
199+
RUBY_VERSION: '2.5.3'
200+
PUPPET_VERSION: '6.0.0'
201+
202+
specs-ruby25-puppet65:
203+
<<: *specs
204+
environment:
205+
STRICT_VARIABLES: 'yes'
206+
RUBY_VERSION: '2.5.3'
207+
PUPPET_VERSION: '6.5.0'
208+
195209
specs-ruby26-puppet60:
196210
<<: *specs
197211
environment:
@@ -233,7 +247,7 @@ jobs:
233247
machine: true
234248
environment:
235249
STRICT_VARIABLES: 'yes'
236-
RUBY_VERSION: '2.6.3'
250+
RUBY_VERSION: '2.5.3'
237251
steps:
238252
- checkout
239253
- run:
@@ -273,11 +287,13 @@ workflows:
273287
- specs-ruby24-puppet53
274288
- specs-ruby24-puppet60
275289
- specs-ruby24-puppet65
276-
- specs-ruby26-puppet46
277-
- specs-ruby26-puppet410
278-
- specs-ruby26-puppet50
279-
- specs-ruby26-puppet53
290+
- specs-ruby25-puppet46
291+
- specs-ruby25-puppet410
292+
- specs-ruby25-puppet50
293+
- specs-ruby25-puppet53
294+
- specs-ruby25-puppet60
295+
- specs-ruby25-puppet65
296+
- specs-ruby25-puppet65-windows
280297
- specs-ruby26-puppet60
281298
- specs-ruby26-puppet65
282-
- specs-ruby25-puppet65-windows
283299
- verify-gemfile-lock-dependencies

.gitattributes

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

.gitignore

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
pkg/*
1+
.git/
2+
.*.sw[op]
3+
.metadata
4+
.yardoc
5+
.yardwarns
6+
*.iml
7+
/.bundle/
8+
/.idea/
9+
/.vagrant/
10+
/coverage/
11+
/bin/
12+
/doc/
13+
/Gemfile.local
14+
/junit/
15+
/log/
16+
/pkg/
17+
/tmp/
18+
/vendor/
19+
/convert_report.txt
20+
/update_report.txt
221
spec/fixtures
322
.rspec_system
4-
.bundle
5-
vendor
623

724
.rbenv-gemsets
825
.ruby-version
926

1027
tests/centos/.vagrant
1128
tests/ubuntu/.vagrant
1229

13-
# mac stuff
1430
.DS_Store
31+
.project
32+
.envrc
33+
/inventory.yaml

.pdkignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.git/
2+
.*.sw[op]
3+
.metadata
4+
.yardoc
5+
.yardwarns
6+
*.iml
7+
/.bundle/
8+
/.idea/
9+
/.vagrant/
10+
/coverage/
11+
/bin/
12+
/doc/
13+
/Gemfile.local
14+
/Gemfile.lock
15+
/junit/
16+
/log/
17+
/pkg/
18+
/spec/fixtures/manifests/
19+
/spec/fixtures/modules/
20+
/tmp/
21+
/vendor/
22+
/convert_report.txt
23+
/update_report.txt
24+
.DS_Store
25+
.project
26+
.envrc
27+
/inventory.yaml
28+
/appveyor.yml
29+
/.fixtures.yml
30+
/Gemfile
31+
/.gitattributes
32+
/.gitignore
33+
/.gitlab-ci.yml
34+
/.pdkignore
35+
/Rakefile
36+
/rakelib/
37+
/.rspec
38+
/.rubocop.yml
39+
/.travis.yml
40+
/.yardopts
41+
/spec/
42+
/.vscode/
43+
/tests/

.puppet-lint.rc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--relative
2+
--no-140chars-check
3+
--fail-on-warnings

.rubocop.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
require:
3+
- rubocop-rspec
4+
- rubocop-i18n
5+
AllCops:
6+
DisplayCopNames: true
7+
TargetRubyVersion: '2.1'
8+
Include:
9+
- "./**/*.rb"
10+
Exclude:
11+
- bin/*
12+
- ".vendor/**/*"
13+
- "**/Gemfile"
14+
- "**/Rakefile"
15+
- pkg/**/*
16+
- spec/fixtures/**/*
17+
- vendor/**/*
18+
- "**/Puppetfile"
19+
- "**/Vagrantfile"
20+
- "**/Guardfile"
21+
Metrics/LineLength:
22+
Description: People have wide screens, use them.
23+
Max: 200
24+
GetText:
25+
Enabled: false
26+
GetText/DecorateString:
27+
Description: We don't want to decorate test output.
28+
Exclude:
29+
- spec/**/*
30+
Enabled: false
31+
RSpec/BeforeAfterAll:
32+
Description: Beware of using after(:all) as it may cause state to leak between tests.
33+
A necessary evil in acceptance testing.
34+
Exclude:
35+
- spec/acceptance/**/*.rb
36+
RSpec/HookArgument:
37+
Description: Prefer explicit :each argument, matching existing module's style
38+
EnforcedStyle: each
39+
Style/BlockDelimiters:
40+
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
41+
be consistent then.
42+
EnforcedStyle: braces_for_chaining
43+
Style/ClassAndModuleChildren:
44+
Description: Compact style reduces the required amount of indentation.
45+
EnforcedStyle: compact
46+
Style/EmptyElse:
47+
Description: Enforce against empty else clauses, but allow `nil` for clarity.
48+
EnforcedStyle: empty
49+
Style/FormatString:
50+
Description: Following the main puppet project's style, prefer the % format format.
51+
EnforcedStyle: percent
52+
Style/FormatStringToken:
53+
Description: Following the main puppet project's style, prefer the simpler template
54+
tokens over annotated ones.
55+
EnforcedStyle: template
56+
Style/Lambda:
57+
Description: Prefer the keyword for easier discoverability.
58+
EnforcedStyle: literal
59+
Style/RegexpLiteral:
60+
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
61+
EnforcedStyle: percent_r
62+
Style/TernaryParentheses:
63+
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
64+
on complex expressions for better readability, but seriously consider breaking
65+
it up.
66+
EnforcedStyle: require_parentheses_when_complex
67+
Style/TrailingCommaInArguments:
68+
Description: Prefer always trailing comma on multiline argument lists. This makes
69+
diffs, and re-ordering nicer.
70+
EnforcedStyleForMultiline: comma
71+
Style/TrailingCommaInLiteral:
72+
Description: Prefer always trailing comma on multiline literals. This makes diffs,
73+
and re-ordering nicer.
74+
EnforcedStyleForMultiline: comma
75+
Style/SymbolArray:
76+
Description: Using percent style obscures symbolic intent of array's contents.
77+
EnforcedStyle: brackets
78+
RSpec/MessageSpies:
79+
EnforcedStyle: receive
80+
Style/Documentation:
81+
Exclude:
82+
- lib/puppet/parser/functions/**/*
83+
- spec/**/*
84+
Style/WordArray:
85+
EnforcedStyle: brackets
86+
Style/CollectionMethods:
87+
Enabled: true
88+
Style/MethodCalledOnDoEndBlock:
89+
Enabled: true
90+
Style/StringMethods:
91+
Enabled: true
92+
GetText/DecorateFunctionMessage:
93+
Enabled: false
94+
GetText/DecorateStringFormattingUsingInterpolation:
95+
Enabled: false
96+
GetText/DecorateStringFormattingUsingPercent:
97+
Enabled: false
98+
Layout/EndOfLine:
99+
Enabled: false
100+
Layout/IndentHeredoc:
101+
Enabled: false
102+
Metrics/AbcSize:
103+
Enabled: false
104+
Metrics/BlockLength:
105+
Enabled: false
106+
Metrics/ClassLength:
107+
Enabled: false
108+
Metrics/CyclomaticComplexity:
109+
Enabled: false
110+
Metrics/MethodLength:
111+
Enabled: false
112+
Metrics/ModuleLength:
113+
Enabled: false
114+
Metrics/ParameterLists:
115+
Enabled: false
116+
Metrics/PerceivedComplexity:
117+
Enabled: false
118+
RSpec/DescribeClass:
119+
Enabled: false
120+
RSpec/ExampleLength:
121+
Enabled: false
122+
RSpec/MessageExpectation:
123+
Enabled: false
124+
RSpec/MultipleExpectations:
125+
Enabled: false
126+
RSpec/NestedGroups:
127+
Enabled: false
128+
Style/AsciiComments:
129+
Enabled: false
130+
Style/IfUnlessModifier:
131+
Enabled: false
132+
Style/SymbolProc:
133+
Enabled: false

Gemfile

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
source "https://rubygems.org"
22

3-
group :test do
4-
gem "rb-inotify", '< 0.10.0' if RUBY_VERSION < '2.2.0'
5-
gem "public_suffix", "~> 3.0.0"
6-
gem "listen", "~> 3.0.0"
7-
# Puppet 4.10.2 is the minimum version we support on Windows due to https://tickets.puppetlabs.com/browse/PUP-7383
8-
# On Linux we support down to 4.6
9-
gem "puppet", "~> #{ENV.fetch('PUPPET_VERSION', '4.10.2')}"
10-
gem "puppet-lint", "~> 2.3.6"
11-
gem "puppet-syntax", "~> 2.5.0"
12-
gem "puppetlabs_spec_helper", "~> 2.14.1"
13-
gem "jwt", "~> 1.5.6"
14-
gem "rake", "~> 12.3.3" # last version to support ruby < 2.6
15-
gem "rspec-puppet", '2.6.9'
16-
gem "ruby-pwsh", '~> 0.3.0', platforms: [:mswin, :mingw, :x64_mingw]
17-
end
3+
# Puppet 4.10.2 is the minimum version we support on Windows due to https://tickets.puppetlabs.com/browse/PUP-7383
4+
# On Linux we support down to 4.6
5+
gem "puppet", "~> #{ENV.fetch('PUPPET_VERSION', '4.10.2')}"
6+
7+
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
8+
minor_version = ruby_version_segments[0..1].join('.')
189

1910
group :development do
20-
gem "fog-openstack", "0.1.25" if RUBY_VERSION < '2.2.0'
21-
gem "guard-rake"
22-
gem "mocha", "~> 1.9.0"
23-
gem "rspec-core", "~> 3.8.2"
24-
gem "rspec-expectations", "~> 3.8.4"
25-
gem "rspec-mocks", "~> 3.8.1"
26-
gem "puppet-blacksmith", "~> 4.1.2"
27-
gem "xmlrpc" if RUBY_VERSION >= '2.3'
11+
gem "rake", "~> 12.3.3" if RUBY_VERSION < '2.6.0' # last version for ruby < 2.6
12+
gem "xmlrpc" if RUBY_VERSION >= '2.3'
13+
gem "ruby-pwsh", '~> 0.3.0', platforms: [:mswin, :mingw, :x64_mingw]
14+
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
15+
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
16+
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
17+
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
18+
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
19+
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))
20+
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
21+
if RUBY_VERSION >= '2.3'
22+
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
23+
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
24+
gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
25+
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
26+
else
27+
gem "puppetlabs_spec_helper", "~> 2.14.1"
28+
gem "puppet-lint", "~> 2.4.2"
29+
gem "metadata-json-lint", "~> 1.2.2"
30+
gem "puppet-syntax", "~> 2.5.0"
31+
gem "rspec-puppet", '2.6.9'
32+
end
2833
end

0 commit comments

Comments
 (0)