simp-rake-helpers 3.7.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -0
  3. data/CHANGELOG.md +10 -0
  4. data/lib/simp/rake/helpers/version.rb +1 -1
  5. data/lib/simp/rake/pupmod/helpers.rb +64 -48
  6. data/lib/simp/rake/rubygem.rb +1 -0
  7. data/spec/lib/simp/rake/pupmod/fixtures/othermod/Gemfile +18 -0
  8. data/spec/lib/simp/rake/pupmod/fixtures/othermod/README.md +83 -0
  9. data/spec/lib/simp/rake/pupmod/fixtures/othermod/Rakefile +32 -0
  10. data/spec/lib/simp/rake/pupmod/fixtures/othermod/examples/init.pp +12 -0
  11. data/spec/lib/simp/rake/pupmod/fixtures/othermod/manifests/init.pp +48 -0
  12. data/spec/lib/simp/rake/pupmod/fixtures/othermod/metadata.json +15 -0
  13. data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/classes/init_spec.rb +6 -0
  14. data/spec/lib/simp/rake/pupmod/fixtures/othermod/spec/spec_helper.rb +1 -0
  15. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/CHANGELOG +11 -0
  16. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/CONTRIBUTORS +1 -0
  17. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/Gemfile +40 -0
  18. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/LICENSE +25 -0
  19. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/README.md +139 -0
  20. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/Rakefile +3 -0
  21. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/build/rpm_metadata/requires +7 -0
  22. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/data/common.yaml +2 -0
  23. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/hiera.yaml +10 -0
  24. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/config.pp +7 -0
  25. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/config/auditing.pp +15 -0
  26. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/config/firewall.pp +14 -0
  27. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/config/logging.pp +16 -0
  28. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/config/pki.pp +16 -0
  29. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/config/selinux.pp +15 -0
  30. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/config/tcpwrappers.pp +16 -0
  31. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/init.pp +110 -0
  32. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/install.pp +11 -0
  33. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/manifests/service.pp +15 -0
  34. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/metadata.json +50 -0
  35. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/nodesets/centos-combined-x64.yml +22 -0
  36. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/nodesets/default.yml +1 -0
  37. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/suites/default/class_spec.rb +32 -0
  38. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/acceptance/suites/default/nodesets +1 -0
  39. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/classes/init_spec.rb +87 -0
  40. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper.rb +92 -0
  41. data/spec/lib/simp/rake/pupmod/fixtures/simpmod/spec/spec_helper_acceptance.rb +45 -0
  42. data/spec/lib/simp/rake/pupmod/helpers_spec.rb +56 -4
  43. metadata +49 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c1179db907c046e2587aba51d6d8bafb4387ccd
4
- data.tar.gz: a8b41cc9cb002d18a0bec544ea7389328198588d
3
+ metadata.gz: 7e36e07cbe0fae048754924ae3a40caba0af5adc
4
+ data.tar.gz: ca2aa327bc13f6e3daacba40fb337f122cc869c6
5
5
  SHA512:
6
- metadata.gz: 85ebb2471f4f3648d3ab3235ad2c268daa8bc09466b76c28c649b7bcb6915be019f495d7e1dd42a25a5d7e48a8613e1da6821db0d18621a0f8efcf5b68db6b03
7
- data.tar.gz: b35605270a2148c09f2ca1803c55703bacf4ff56223a343ecce39b3f1732e79463e30f20614db161e4fba522240e33795ff471bb118efa3b530ac1475a8d84fa
6
+ metadata.gz: e7a65f9772cc1647c25a0c1e5385cef0175110f23baf24d0f3e8b6a0120953d9a7bc0c7565979dd8c7e9d08a13ecfe129964f1a7d46365c7f1fd154b213326b9
7
+ data.tar.gz: efddde79768468a7d9ed3a72b12aef3887abfc90b08f6b8e261a35196f1de061f450b4fc83b64288229051f8f2109153a28444685a73ca8d8d3c0c7ac75c644d
data/.travis.yml CHANGED
@@ -1,21 +1,26 @@
1
1
  language: ruby
2
2
  sudo: required
3
+ dist: trusty
3
4
  before_install:
4
5
  - sudo apt-get update -qq
5
6
  - sudo apt-get install -y rpm
6
7
  - rm Gemfile.lock || true
8
+ - rvm @global do gem uninstall bundler -a -x
9
+ - rvm @global do gem install bundler -v '~> 1.14.0'
7
10
  bundler_args: "--without development --path .vendor"
8
11
  notifications:
9
12
  email: false
10
13
  rvm:
11
14
  - 2.1.9
12
15
  - 2.3.3
16
+ - 2.4.1
13
17
  script:
14
18
  - 'bundle exec rake spec'
15
19
  matrix:
16
20
  fast_finish: true
17
21
  allow_failures:
18
22
  - rvm: 2.3.3
23
+ - rvm: 2.4.1
19
24
  before_deploy:
20
25
  - 'bundle exec rake clobber'
21
26
  - "export GEM_VERSION=`ruby -r ./lib/simp/rake/helpers/version.rb -e 'puts Simp::Rake::Helpers::VERSION'`"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 4.0.0 / 2017-07-31
2
+ * Pinned bundler to '~> 1.14.0' to allow building on FIPS-enabled systems
3
+ * Updated to simp-rspec-puppet-facts 2.0.0
4
+
5
+ ### 3.7.1 / 2017-07-20
6
+ * Fixed bug in `:changelog_annotation` task
7
+ * `:test` now uses `:metadata_lint` instead of `:metadata`
8
+ * `:metadata` is now an alias for `:metadata_lint`
9
+ * Added tests and fixtures for changelog logic
10
+
1
11
  ### 3.7.0 / 2017-07-10
2
12
  * Added compare_latest_tag task
3
13
 
@@ -2,5 +2,5 @@ module Simp; end
2
2
  module Simp::Rake; end
3
3
 
4
4
  class Simp::Rake::Helpers
5
- VERSION = '3.7.0'
5
+ VERSION = '4.0.0'
6
6
  end
@@ -19,6 +19,9 @@ module Simp::Rake::Pupmod; end
19
19
 
20
20
  # Rake tasks for SIMP Puppet modules
21
21
  class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
22
+ # See https://fedoraproject.org/wiki/Packaging:Guidelines?rd=Packaging/Guidelines#Changelogs
23
+ CHANGELOG_ENTRY_REGEX = /^\*\s+((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2} \d{4})\s+(.+<.+>)(?:\s+|\s*-\s*)?(\d+\.\d+\.\d+)/
24
+
22
25
  def initialize( base_dir = Dir.pwd )
23
26
  @base_dir = base_dir
24
27
  Dir[ File.join(File.dirname(__FILE__),'*.rb') ].each do |rake_file|
@@ -39,7 +42,6 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
39
42
  rescue LoadError
40
43
  end
41
44
 
42
-
43
45
  # Lint & Syntax exclusions
44
46
  exclude_paths = [
45
47
  "bundle/**/*",
@@ -76,10 +78,62 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
76
78
  end
77
79
 
78
80
  desc 'lint metadata.json'
79
- task :metadata do
80
- sh "metadata-json-lint metadata.json"
81
+ Rake::Task[:metadata].clear
82
+ task :metadata => :metadata_lint
83
+
84
+ # Read the metadata.json as a data structure
85
+ def metadata( file_path = nil )
86
+ require 'json'
87
+ _file = file_path || File.join(@base_dir, 'metadata.json')
88
+ fail "ERROR: file not found: '#{_file}'" unless File.exists? _file
89
+ @metadata ||= JSON.parse( File.read(_file) )
90
+ end
91
+
92
+
93
+ # Generate an appropriate annotated tag entry from the modules' CHANGELOG
94
+ #
95
+ # @note this currently does not support the valid RPM `%changelog` format
96
+ # that places the version number on the next line:
97
+ #
98
+ # * Fri Mar 02 2012 Maintenance
99
+ # 4.0.0-2
100
+ # - Improved test stubs.
101
+ #
102
+ def changelog_annotation( quiet = false, file = nil )
103
+ result = ""
104
+ changelog_file = file || File.join(@base_dir, 'CHANGELOG')
105
+ module_version = metadata['version']
106
+ changelogs = {}
107
+
108
+ _entry = {} # current log entry's metadata (empty unless valid entry)
109
+ File.read(changelog_file).each_line do |line|
110
+ if line =~ /^\*/
111
+ if CHANGELOG_ENTRY_REGEX.match(line).nil?
112
+ warn %Q[WARNING: invalid changelogs entry: "#{line}"] unless quiet
113
+ _entry = {}
114
+ else
115
+ _entry = {
116
+ :date => $1,
117
+ :user => $2,
118
+ :release => $3,
119
+ }
120
+ changelogs[_entry[:release]] ||= []
121
+ changelogs[_entry[:release]] << line
122
+ next
123
+ end
124
+ end
125
+
126
+ # Don't add anything to the annotation unless reach the next valid entry
127
+ changelogs[_entry[:release]] << " #{line}" if _entry.fetch(:release, false)
128
+ end
129
+
130
+ fail "Did not find any changelogs entries for version #{module_version}" if changelogs[module_version].nil?
131
+
132
+ result += "\nRelease of #{module_version}\n\n"
133
+ result += changelogs[module_version].join
81
134
  end
82
135
 
136
+
83
137
  desc <<-EOM
84
138
  Generate an appropriate annotated tag entry from a CHANGELOG.
85
139
 
@@ -105,45 +159,8 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
105
159
  # That will give Travis a way of warning us if the changelog
106
160
  # will prevent the rpm from building.
107
161
  task :changelog_annotation, [:quiet] do |t,args|
108
- require 'json'
109
-
110
162
  quiet = true if args[:quiet].to_s == 'true'
111
-
112
- module_version = JSON.parse(File.read('metadata.json'))['version']
113
-
114
- changelog = Hash.new
115
- delim = nil
116
- ignore_line = false
117
-
118
- File.read('CHANGELOG').each_line do |line|
119
- if line =~ /^\*/
120
- if /^\*\s+((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{2} \d{4})\s+(.+<.+>)(?:\s+|\s*-\s*)?(\d+\.\d+\.\d+)/.match(line).nil?
121
- warn "WARNING: invalid changelog entry: #{line}" unless quiet
122
- # Don't add anything to the annotation until we reach the next
123
- # valid entry
124
- ignore_line = true
125
- else
126
- ignore_line = false
127
- delim = Hash.new
128
- delim[:date] = $1
129
- delim[:user] = $2
130
- delim[:release] = $3
131
-
132
- changelog[delim[:release]] ||= Array.new
133
- changelog[delim[:release]] << line
134
- end
135
-
136
- next
137
- end
138
-
139
- if delim && delim[:release]
140
- changelog[delim[:release]] << ' ' + line unless ignore_line
141
- end
142
- end
143
-
144
- fail "Did not find any changelog entries for version #{module_version}" if changelog[module_version].nil?
145
- puts "\nRelease of #{module_version}\n\n"
146
- puts changelog[module_version]
163
+ puts changelog_annotation( quiet )
147
164
  end
148
165
 
149
166
  desc <<-EOM
@@ -158,7 +175,7 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
158
175
 
159
176
  NOTES:
160
177
  Compares mission-impacting (significant) files with the latest
161
- tag and identifies the relevant files that have changed.
178
+ tag and identifies the relevant files that have changed.
162
179
 
163
180
  Does nothing if the project owner, as specified in the
164
181
  metadata.json file, is not 'simp'.
@@ -187,10 +204,9 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
187
204
  require 'puppet/util/package'
188
205
 
189
206
  tags_source = args[:tags_source].nil? ? 'origin' : args[:tags_source]
190
- ignore_owner = true if args[:ignore_owner].to_s == 'true'
191
- verbose = true if args[:verbose].to_s == 'true'
207
+ ignore_owner = true if args[:ignore_owner].to_s == 'true'
208
+ verbose = true if args[:verbose].to_s == 'true'
192
209
 
193
- metadata = JSON.load(File.read('metadata.json'))
194
210
  module_version = metadata['version']
195
211
  owner = metadata['name'].split('-')[0]
196
212
 
@@ -211,7 +227,7 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
211
227
  files_changed.delete_if do |file|
212
228
  file[0] == '.' or file =~ /^Gemfile/ or file == 'Rakefile' or file =~/^spec\// or file =~/^doc/
213
229
  end
214
-
230
+
215
231
  if files_changed.empty?
216
232
  puts " No new tag required: No significant files have changed since '#{last_tag}' tag"
217
233
  else
@@ -237,7 +253,7 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
237
253
  end
238
254
  end
239
255
  end
240
- else
256
+ else
241
257
  puts " Not evaluating module owned by '#{owner}'"
242
258
  end
243
259
  end
@@ -247,7 +263,7 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
247
263
  :syntax,
248
264
  :lint,
249
265
  :spec_parallel,
250
- :metadata,
266
+ :metadata_lint,
251
267
  ]
252
268
 
253
269
  desc <<-EOM
@@ -62,6 +62,7 @@ module Simp::Rake
62
62
  desc "Run spec tests"
63
63
  RSpec::Core::RakeTask.new(:spec) do |t|
64
64
  t.rspec_opts = ['--color']
65
+ t.exclude_pattern = '**/{acceptance,fixtures,files}/**/*_spec.rb'
65
66
  t.pattern = 'spec/lib/simp/**/*_spec.rb'
66
67
  end
67
68
  end
@@ -0,0 +1,18 @@
1
+ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
+
3
+ puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3']
4
+ gem 'metadata-json-lint'
5
+ gem 'puppet', puppetversion
6
+ gem 'puppetlabs_spec_helper', '>= 1.0.0'
7
+ gem 'puppet-lint', '>= 1.0.0'
8
+ gem 'facter', '>= 1.7.0'
9
+ gem 'rspec-puppet'
10
+
11
+ # rspec must be v2 for ruby 1.8.7
12
+ if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
13
+ gem 'rspec', '~> 2.0'
14
+ gem 'rake', '~> 10.0'
15
+ else
16
+ # rubocop requires ruby >= 1.9
17
+ gem 'rubocop'
18
+ end
@@ -0,0 +1,83 @@
1
+ # othermod
2
+
3
+ #### Table of Contents
4
+
5
+ 1. [Description](#description)
6
+ 1. [Setup - The basics of getting started with othermod](#setup)
7
+ * [What othermod affects](#what-othermod-affects)
8
+ * [Setup requirements](#setup-requirements)
9
+ * [Beginning with othermod](#beginning-with-othermod)
10
+ 1. [Usage - Configuration options and additional functionality](#usage)
11
+ 1. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
12
+ 1. [Limitations - OS compatibility, etc.](#limitations)
13
+ 1. [Development - Guide for contributing to the module](#development)
14
+
15
+ ## Description
16
+
17
+ Start with a one- or two-sentence summary of what the module does and/or what
18
+ problem it solves. This is your 30-second elevator pitch for your module.
19
+ Consider including OS/Puppet version it works with.
20
+
21
+ You can give more descriptive information in a second paragraph. This paragraph
22
+ should answer the questions: "What does this module *do*?" and "Why would I use
23
+ it?" If your module has a range of functionality (installation, configuration,
24
+ management, etc.), this is the time to mention it.
25
+
26
+ ## Setup
27
+
28
+ ### What othermod affects **OPTIONAL**
29
+
30
+ If it's obvious what your module touches, you can skip this section. For
31
+ example, folks can probably figure out that your mysql_instance module affects
32
+ their MySQL instances.
33
+
34
+ If there's more that they should know about, though, this is the place to mention:
35
+
36
+ * A list of files, packages, services, or operations that the module will alter,
37
+ impact, or execute.
38
+ * Dependencies that your module automatically installs.
39
+ * Warnings or other important notices.
40
+
41
+ ### Setup Requirements **OPTIONAL**
42
+
43
+ If your module requires anything extra before setting up (pluginsync enabled,
44
+ etc.), mention it here.
45
+
46
+ If your most recent release breaks compatibility or requires particular steps
47
+ for upgrading, you might want to include an additional "Upgrading" section
48
+ here.
49
+
50
+ ### Beginning with othermod
51
+
52
+ The very basic steps needed for a user to get the module up and running. This
53
+ can include setup steps, if necessary, or it can be an example of the most
54
+ basic use of the module.
55
+
56
+ ## Usage
57
+
58
+ This section is where you describe how to customize, configure, and do the
59
+ fancy stuff with your module here. It's especially helpful if you include usage
60
+ examples and code samples for doing things with your module.
61
+
62
+ ## Reference
63
+
64
+ Here, include a complete list of your module's classes, types, providers,
65
+ facts, along with the parameters for each. Users refer to this section (thus
66
+ the name "Reference") to find specific details; most users don't read it per
67
+ se.
68
+
69
+ ## Limitations
70
+
71
+ This is where you list OS compatibility, version compatibility, etc. If there
72
+ are Known Issues, you might want to include them under their own heading here.
73
+
74
+ ## Development
75
+
76
+ Since your module is awesome, other users will want to play with it. Let them
77
+ know what the ground rules for contributing are.
78
+
79
+ ## Release Notes/Contributors/Etc. **Optional**
80
+
81
+ If you aren't using changelog, put your release notes here (though you should
82
+ consider using changelog). You can also add any additional sections you feel
83
+ are necessary or important to include here. Please use the `## ` header.
@@ -0,0 +1,32 @@
1
+ require 'puppetlabs_spec_helper/rake_tasks'
2
+ require 'puppet-lint/tasks/puppet-lint'
3
+ require 'metadata-json-lint/rake_task'
4
+
5
+ if RUBY_VERSION >= '1.9'
6
+ require 'rubocop/rake_task'
7
+ RuboCop::RakeTask.new
8
+ end
9
+
10
+ PuppetLint.configuration.send('disable_80chars')
11
+ PuppetLint.configuration.relative = true
12
+ PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']
13
+
14
+ desc 'Validate manifests, templates, and ruby files'
15
+ task :validate do
16
+ Dir['manifests/**/*.pp'].each do |manifest|
17
+ sh "puppet parser validate --noop #{manifest}"
18
+ end
19
+ Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
20
+ sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
21
+ end
22
+ Dir['templates/**/*.erb'].each do |template|
23
+ sh "erb -P -x -T '-' #{template} | ruby -c"
24
+ end
25
+ end
26
+
27
+ desc 'Run metadata_lint, lint, validate, and spec tests.'
28
+ task :test do
29
+ [:metadata_lint, :lint, :validate, :spec].each do |test|
30
+ Rake::Task[test].invoke
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ # The baseline for module testing used by Puppet Inc. is that each manifest
2
+ # should have a corresponding test manifest that declares that class or defined
3
+ # type.
4
+ #
5
+ # Tests are then run by using puppet apply --noop (to check for compilation
6
+ # errors and view a log of events) or by fully applying the test in a virtual
7
+ # environment (to compare the resulting system state to the desired state).
8
+ #
9
+ # Learn more about module testing here:
10
+ # https://docs.puppet.com/guides/tests_smoke.html
11
+ #
12
+ include ::othermod
@@ -0,0 +1,48 @@
1
+ # Class: othermod
2
+ # ===========================
3
+ #
4
+ # Full description of class othermod here.
5
+ #
6
+ # Parameters
7
+ # ----------
8
+ #
9
+ # Document parameters here.
10
+ #
11
+ # * `sample parameter`
12
+ # Explanation of what this parameter affects and what it defaults to.
13
+ # e.g. "Specify one or more upstream ntp servers as an array."
14
+ #
15
+ # Variables
16
+ # ----------
17
+ #
18
+ # Here you should define a list of variables that this module would require.
19
+ #
20
+ # * `sample variable`
21
+ # Explanation of how this variable affects the function of this class and if
22
+ # it has a default. e.g. "The parameter enc_ntp_servers must be set by the
23
+ # External Node Classifier as a comma separated list of hostnames." (Note,
24
+ # global variables should be avoided in favor of class parameters as
25
+ # of Puppet 2.6.)
26
+ #
27
+ # Examples
28
+ # --------
29
+ #
30
+ # @example
31
+ # class { 'othermod':
32
+ # servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
33
+ # }
34
+ #
35
+ # Authors
36
+ # -------
37
+ #
38
+ # Author Name <author@domain.com>
39
+ #
40
+ # Copyright
41
+ # ---------
42
+ #
43
+ # Copyright 2017 Your name here, unless otherwise noted.
44
+ #
45
+ class othermod {
46
+
47
+
48
+ }