onceover 3.20.0 → 3.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -232,46 +232,74 @@ class Onceover
232
232
 
233
233
  output_array = []
234
234
  threads = []
235
+ error_array = []
235
236
  puppetfile.modules.each do |mod|
236
237
  threads << Thread.new do
237
- row = []
238
- logger.debug "Loading data for #{mod.full_name}"
239
- row << mod.full_name
240
- if mod.is_a?(R10K::Module::Forge)
241
- row << mod.expected_version
242
- row << mod.v3_module.current_release.version
243
-
244
- current = Versionomy.parse(mod.expected_version)
245
- latest = Versionomy.parse(mod.v3_module.current_release.version)
246
- row << if current.major < latest.major
247
- "Major".red
248
- elsif current.minor < latest.minor
249
- "Minor".yellow
250
- elsif current.tiny < latest.tiny
251
- "Tiny".green
252
- else
253
- "No".green
254
- end
255
-
256
- row << mod.v3_module.endorsement
257
- superseded_by = mod.v3_module.superseded_by
258
- row << (superseded_by.nil? ? '' : superseded_by[:slug])
259
- else
260
- row << "N/A"
261
- row << "N/A"
262
- row << "N/A"
263
- row << "N/A"
264
- row << "N/A"
238
+ begin
239
+ row = []
240
+ logger.debug "Loading data for #{mod.full_name}"
241
+ row << mod.full_name
242
+ if mod.is_a?(R10K::Module::Forge)
243
+ row << mod.expected_version
244
+ row << mod.v3_module.current_release.version
245
+
246
+ # Configure a custom version format to support modern Puppet Forge versions.
247
+ # (major.minor.tiny-patchlevel-patchlevel_minor)
248
+ # e.g. 8.5.0-0-2
249
+ puppetforge_format = Versionomy.default_format.modified_copy do
250
+ field(:patchlevel_minor) do
251
+ recognize_number(:default_value_optional => true,
252
+ :delimiter_regexp => '-',
253
+ :default_delimiter => '-')
254
+ end
255
+ end
256
+
257
+ current = puppetforge_format.parse(mod.expected_version)
258
+ latest = puppetforge_format.parse(mod.v3_module.current_release.version)
259
+ row << if current.major < latest.major
260
+ "Major".red
261
+ elsif current.minor < latest.minor
262
+ "Minor".yellow
263
+ elsif current.tiny < latest.tiny
264
+ "Tiny".green
265
+ elsif current.patchlevel < latest.patchlevel
266
+ "PatchLevel".green
267
+ elsif current.patchlevel_minor < latest.patchlevel_minor
268
+ "PatchLevel_minor".green
269
+ else
270
+ "No".green
271
+ end
272
+
273
+ row << mod.v3_module.endorsement
274
+ superseded_by = mod.v3_module.superseded_by
275
+ row << (superseded_by.nil? ? '' : superseded_by[:slug])
276
+ else
277
+ row << "N/A"
278
+ row << "N/A"
279
+ row << "N/A"
280
+ row << "N/A"
281
+ row << "N/A"
282
+ end
283
+ output_array << row
284
+ rescue RuntimeError => e
285
+ error = []
286
+ error << mod.full_name
287
+ error << mod.expected_version
288
+ error << mod.v3_module.current_release.version
289
+ error << e.message
290
+ error_array << error
291
+ logger.debug "Error loading module #{mod.full_name} - #{e.inspect}"
292
+ end
265
293
  end
266
- output_array << row
267
294
  end
268
- end
269
295
 
270
296
  threads.map(&:join)
271
297
 
272
298
  output_array.sort_by! { |line| line[0] }
299
+ error_array.sort_by! { |line| line[0] } unless error_array.empty?
273
300
 
274
301
  puts Terminal::Table.new(headings: ["Full Name", "Current Version", "Latest Version", "Out of Date?", "Endorsement", "Superseded by"], rows: output_array)
302
+ puts Terminal::Table.new(headings: ["Issue assessing module", "Current", "Latest", "Error"], rows: error_array) unless error_array.empty?
275
303
  end
276
304
 
277
305
  def update_puppetfile
@@ -575,7 +603,7 @@ class Onceover
575
603
  else
576
604
  template = File.read(File.expand_path("./#{template_name}", template_dir))
577
605
  end
578
- ERB.new(template, nil, '-').result(bind)
606
+ ERB.new(template, trim_mode: '-').result(bind)
579
607
  end
580
608
 
581
609
  def self.init_write_file(contents, out_file)
@@ -86,9 +86,12 @@ class Onceover
86
86
  FileUtils.copy repo.puppetfile, "#{temp_controlrepo}/Puppetfile"
87
87
  puppetfile_contents = File.read("#{temp_controlrepo}/Puppetfile")
88
88
 
89
- logger.debug "replacing :control_branch mentions in the Puppetfile with #{git_branch}"
90
- new_puppetfile_contents = puppetfile_contents.gsub(/:control_branch/, "'#{git_branch}'")
91
- File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
89
+ # Avoid touching thing if we don't need to
90
+ if /:control_branch/.match(puppetfile_contents)
91
+ logger.debug "replacing :control_branch mentions in the Puppetfile with #{git_branch}"
92
+ new_puppetfile_contents = puppetfile_contents.gsub(/:control_branch/, "'#{git_branch}'")
93
+ File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
94
+ end
92
95
  end
93
96
 
94
97
  # Remove all files written by the last onceover run, but not the ones
@@ -85,6 +85,7 @@ class Onceover
85
85
  # NOTE: This is the way to provide options to rspec according to:
86
86
  # https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/rake_tasks.rb#L51
87
87
  ENV['CI_SPEC_OPTIONS'] = ENV['CI_SPEC_OPTIONS'].to_s + @config.filter_tags.map { |tag| " --tag #{tag}" }.join unless @config.filter_tags.nil?
88
+ ENV['CI_SPEC_OPTIONS'] = ENV['CI_SPEC_OPTIONS'].to_s + ' --fail-fast' if @config.fail_fast
88
89
 
89
90
  if @config.opts[:parallel]
90
91
  logger.debug "Running #{@command_prefix}rake parallel_spec from #{@repo.tempdir}"
@@ -27,12 +27,13 @@ class Onceover
27
27
  attr_accessor :after_conditions
28
28
  attr_accessor :skip_r10k
29
29
  attr_accessor :force
30
+ attr_accessor :fail_fast
30
31
  attr_accessor :strict_variables
31
32
  attr_accessor :formatters
32
33
 
33
34
  def initialize(file, opts = {})
34
35
  begin
35
- config = YAML.safe_load(File.read(file), [Symbol])
36
+ config = YAML.safe_load(File.read(file), permitted_classes: [Symbol])
36
37
  rescue Errno::ENOENT
37
38
  raise "Could not find #{file}"
38
39
  rescue Psych::SyntaxError
@@ -79,6 +80,7 @@ class Onceover
79
80
  @filter_nodes = opts[:nodes] ? [opts[:nodes].split(',')].flatten.map {|x| Onceover::Node.find(x)} : nil
80
81
  @skip_r10k = opts[:skip_r10k] ? true : false
81
82
  @force = opts[:force] || false
83
+ @fail_fast = opts[:fail_fast] || false
82
84
 
83
85
  # Validate the mock_functions
84
86
  if @mock_functions && @mock_functions.any? { |name, details| details.has_key? 'type' }
@@ -242,7 +244,7 @@ class Onceover
242
244
  source_files.each do |source_file|
243
245
  target_file = File.join(repo.tempdir, 'spec', source_file.sub(/^#{repo.spec_dir}/, ''))
244
246
  if File.directory?(source_file)
245
- FileUtils.cp_r source_file, target_file unless File.exists? target_file
247
+ FileUtils.cp_r source_file, target_file unless File.exist? target_file
246
248
  else
247
249
  FileUtils.mkdir_p File.dirname target_file
248
250
  FileUtils.cp source_file, target_file
data/onceover.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "onceover"
7
- s.version = "3.20.0"
7
+ s.version = "3.21.0"
8
8
  s.authors = ["Dylan Ratcliffe"]
9
9
  s.email = ["dylan.ratcliffe@puppet.com"]
10
10
  s.homepage = "https://github.com/dylanratcliffe/onceover"
@@ -38,6 +38,8 @@ Gem::Specification.new do |s|
38
38
 
39
39
  s.add_development_dependency 'cucumber', '~> 4.1'
40
40
  s.add_development_dependency 'pry', '~> 0.13.1'
41
- s.add_development_dependency 'rubocop', '~> 1.6', '>= 1.6.1'
41
+ # We need to depend on rubocop <= 1.12 in order to support Ruby 2.4 (Puppet
42
+ # 5). Once we drop support for Puppet 5 we can re-open this
43
+ s.add_development_dependency 'rubocop', '>= 1.6.1', '<= 1.12'
42
44
  s.add_development_dependency 'rubygems-tasks', '~> 0.2.5'
43
45
  end
@@ -1,17 +1,17 @@
1
- forge "http://forge.puppetlabs.com"
2
- #
3
- # I want to download some modules to check if r10k feature in Onceover works correctly.
4
- #
5
-
6
- # Versions should be updated to be the latest at the time you start
7
- mod "puppetlabs/stdlib", '4.11.0'
8
-
9
- # Modules from Git
10
- # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
- mod 'apache',
12
- :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
- :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
-
15
- #mod 'apache',
16
- # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
17
- # :branch => 'docs_experiment'
1
+ forge "http://forge.puppetlabs.com"
2
+ #
3
+ # I want to download some modules to check if r10k feature in Onceover works correctly.
4
+ #
5
+
6
+ # Versions should be updated to be the latest at the time you start
7
+ mod "puppetlabs/stdlib", '4.11.0'
8
+
9
+ # Modules from Git
10
+ # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
+ mod 'apache',
12
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
+ :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
+
15
+ #mod 'apache',
16
+ # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
17
+ # :branch => 'docs_experiment'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onceover
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.20.0
4
+ version: 3.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-08 00:00:00.000000000 Z
11
+ date: 2023-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backticks
@@ -280,22 +280,22 @@ dependencies:
280
280
  name: rubocop
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
- - - "~>"
284
- - !ruby/object:Gem::Version
285
- version: '1.6'
286
283
  - - ">="
287
284
  - !ruby/object:Gem::Version
288
285
  version: 1.6.1
286
+ - - "<="
287
+ - !ruby/object:Gem::Version
288
+ version: '1.12'
289
289
  type: :development
290
290
  prerelease: false
291
291
  version_requirements: !ruby/object:Gem::Requirement
292
292
  requirements:
293
- - - "~>"
294
- - !ruby/object:Gem::Version
295
- version: '1.6'
296
293
  - - ">="
297
294
  - !ruby/object:Gem::Version
298
295
  version: 1.6.1
296
+ - - "<="
297
+ - !ruby/object:Gem::Version
298
+ version: '1.12'
299
299
  - !ruby/object:Gem::Dependency
300
300
  name: rubygems-tasks
301
301
  requirement: !ruby/object:Gem::Requirement
@@ -318,11 +318,13 @@ executables:
318
318
  extensions: []
319
319
  extra_rdoc_files: []
320
320
  files:
321
+ - ".devcontainer/devcontainer.json"
321
322
  - ".gitattributes"
322
323
  - ".github/workflows/tests.yaml"
323
324
  - ".gitignore"
324
325
  - ".gitmodules"
325
326
  - ".rubocop.yml"
327
+ - ".vscode/extensions.json"
326
328
  - Gemfile
327
329
  - README.md
328
330
  - Rakefile
@@ -485,7 +487,7 @@ homepage: https://github.com/dylanratcliffe/onceover
485
487
  licenses:
486
488
  - Apache-2.0
487
489
  metadata: {}
488
- post_install_message:
490
+ post_install_message:
489
491
  rdoc_options: []
490
492
  require_paths:
491
493
  - lib
@@ -500,9 +502,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
500
502
  - !ruby/object:Gem::Version
501
503
  version: '0'
502
504
  requirements: []
503
- rubyforge_project:
504
- rubygems_version: 2.7.6.2
505
- signing_key:
505
+ rubygems_version: 3.4.10
506
+ signing_key:
506
507
  specification_version: 4
507
508
  summary: Testing tools for Puppet controlrepos
508
509
  test_files: []