Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e80f45e

Browse files
authored
Merge pull request #418 from voxpupuli/modulesync
modulesync 2.12.0
2 parents af1ba04 + 0587cc8 commit e80f45e

File tree

8 files changed

+28
-109
lines changed

8 files changed

+28
-109
lines changed

.github/CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,20 @@ Beaker also supports docker containers. We also use that in our automated CI
256256
pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant:
257257

258258
```sh
259-
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
259+
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
260260
```
261261

262-
You can replace the string `debian9` with any common operating system.
262+
You can replace the string `debian10` with any common operating system.
263263
The following strings are known to work:
264264

265265
* ubuntu1604
266266
* ubuntu1804
267267
* debian8
268268
* debian9
269+
* debian10
269270
* centos6
270271
* centos7
272+
* centos8
271273

272274
The easiest way to debug in a docker container is to open a shell:
273275

.msync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
modulesync_config_version: '2.10.0'
1+
modulesync_config_version: '2.12.0'

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require: rubocop-rspec
22
AllCops:
3-
TargetRubyVersion: 2.1
3+
# Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5
4+
TargetRubyVersion: 1.9
45
Include:
56
- ./**/*.rb
67
Exclude:

Gemfile

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,9 @@ def location_for(place, fake_version = nil)
1111
end
1212

1313
group :test do
14-
gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false
15-
gem 'rspec-puppet-facts', '>= 1.9.5', :require => false
16-
gem 'rspec-puppet-utils', :require => false
17-
gem 'puppet-lint-leading_zero-check', :require => false
18-
gem 'puppet-lint-trailing_comma-check', :require => false
19-
gem 'puppet-lint-version_comparison-check', :require => false
20-
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
21-
gem 'puppet-lint-unquoted_string-check', :require => false
22-
gem 'puppet-lint-variable_contains_upcase', :require => false
23-
gem 'puppet-lint-absolute_classname-check', '>= 2.0.0', :require => false
24-
gem 'puppet-lint-topscope-variable-check', :require => false
25-
gem 'puppet-lint-legacy_facts-check', :require => false
26-
gem 'puppet-lint-anchor-check', :require => false
27-
gem 'metadata-json-lint', :require => false
28-
gem 'redcarpet', :require => false
29-
gem 'rubocop', '~> 0.49.1', :require => false
30-
gem 'rubocop-rspec', '~> 1.15.0', :require => false
31-
gem 'mocha', '~> 1.4.0', :require => false
32-
gem 'coveralls', :require => false
33-
gem 'simplecov-console', :require => false
34-
gem 'parallel_tests', :require => false
14+
gem 'voxpupuli-test', '>= 1.0.0', :require => false
15+
gem 'coveralls', :require => false
16+
gem 'simplecov-console', :require => false
3517
end
3618

3719
group :development do
@@ -62,6 +44,7 @@ group :system_tests do
6244
gem 'rbnacl', '>= 4', :require => false
6345
gem 'rbnacl-libsodium', :require => false
6446
gem 'bcrypt_pbkdf', :require => false
47+
gem 'ed25519', :require => false
6548
end
6649

6750
group :release do

Rakefile

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'puppetlabs_spec_helper/rake_tasks'
1+
require 'voxpupuli/test/rake'
22

33
# load optional tasks for releases
44
# only available if gem group releases is installed
@@ -7,37 +7,6 @@ begin
77
rescue LoadError
88
end
99

10-
PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
11-
12-
desc 'Auto-correct puppet-lint offenses'
13-
task 'lint:auto_correct' do
14-
Rake::Task[:lint_fix].invoke
15-
end
16-
17-
desc 'Run acceptance tests'
18-
RSpec::Core::RakeTask.new(:acceptance) do |t|
19-
t.pattern = 'spec/acceptance'
20-
end
21-
22-
desc 'Run tests'
23-
task test: [:release_checks]
24-
25-
namespace :check do
26-
desc 'Check for trailing whitespace'
27-
task :trailing_whitespace do
28-
Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename|
29-
next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)}
30-
File.foreach(filename).each_with_index do |line, index|
31-
if line =~ %r{\s\n$}
32-
puts "#{filename} has trailing whitespace on line #{index + 1}"
33-
exit 1
34-
end
35-
end
36-
end
37-
end
38-
end
39-
Rake::Task[:release_checks].enhance ['check:trailing_whitespace']
40-
4110
desc "Run main 'test' task and report merged results to coveralls"
4211
task test_with_coveralls: [:test] do
4312
if Dir.exist?(File.expand_path('../lib', __FILE__))

lib/puppet/provider/package/npm.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
def self.npmlist
1616
# Ignore non-zero exit codes as they can be minor, just try and parse JSON
17-
output = execute([command(:npm), 'list', '--json', '--global'], combine: false)
18-
Puppet.debug("Warning: npm list --json exited with code #{$CHILD_STATUS.exitstatus}") unless $CHILD_STATUS.success?
17+
output = execute([command(:npm), 'list', '--json', '--global'], combine: false, failonfail: false)
18+
Puppet.debug("Warning: npm list --json exited with code #{output.exitstatus}") if output.exitstatus != 0
1919
begin
2020
# ignore any npm output lines to be a bit more robust
2121
output = PSON.parse(output.lines.select { |l| l =~ %r{^((?!^npm).*)$} }.join("\n"), max_nesting: 100)

spec/spec_helper.rb

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
# This file is managed via modulesync
22
# https://github.com/voxpupuli/modulesync
33
# https://github.com/voxpupuli/modulesync_config
4+
45
RSpec.configure do |c|
56
c.mock_with :mocha
67
end
78

8-
require 'puppetlabs_spec_helper/module_spec_helper'
9-
require 'rspec-puppet-facts'
10-
require 'bundler'
11-
include RspecPuppetFacts
9+
# puppetlabs_spec_helper will set up coverage if the env variable is set.
10+
# We want to do this if lib exists and it hasn't been explicitly set.
11+
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
1212

13-
if ENV['DEBUG']
14-
Puppet::Util::Log.level = :debug
15-
Puppet::Util::Log.newdestination(:console)
16-
end
13+
require 'voxpupuli/test/spec_helper'
1714

1815
if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
1916
facts = YAML.load(File.read(File.join(__dir__, 'default_module_facts.yml')))
@@ -23,39 +20,3 @@
2320
end
2421
end
2522
end
26-
27-
if Dir.exist?(File.expand_path('../../lib', __FILE__))
28-
require 'coveralls'
29-
require 'simplecov'
30-
require 'simplecov-console'
31-
SimpleCov.formatters = [
32-
SimpleCov::Formatter::HTMLFormatter,
33-
SimpleCov::Formatter::Console
34-
]
35-
SimpleCov.start do
36-
track_files 'lib/**/*.rb'
37-
add_filter '/spec'
38-
add_filter '/vendor'
39-
add_filter '/.vendor'
40-
add_filter Bundler.configured_bundle_path.path
41-
end
42-
end
43-
44-
RSpec.configure do |c|
45-
# getting the correct facter version is tricky. We use facterdb as a source to mock facts
46-
# see https://github.com/camptocamp/facterdb
47-
# people might provide a specific facter version. In that case we use it.
48-
# Otherwise we need to match the correct facter version to the used puppet version.
49-
# as of 2019-10-31, puppet 5 ships facter 3.11 and puppet 6 ships facter 3.14
50-
# https://puppet.com/docs/puppet/5.5/about_agent.html
51-
c.default_facter_version = if ENV['FACTERDB_FACTS_VERSION']
52-
ENV['FACTERDB_FACTS_VERSION']
53-
else
54-
Gem::Dependency.new('', ENV['PUPPET_VERSION']).match?('', '5') ? '3.11.0' : '3.14.0'
55-
end
56-
57-
# Coverage generation
58-
c.after(:suite) do
59-
RSpec::Puppet::Coverage.report!
60-
end
61-
end

spec/unit/puppet/provider/package/npm_spec.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,27 @@ def self.it_should_respond_to(*actions)
6262
end
6363

6464
it 'returns a list of npm packages installed globally' do
65-
provider.class.expects(:execute).with(['/usr/local/bin/npm', 'list', '--json', '--global'], anything).returns(my_fixture_read('npm_global'))
65+
provider.class.expects(:execute).
66+
with(['/usr/local/bin/npm', 'list', '--json', '--global'], anything).
67+
returns(Puppet::Util::Execution::ProcessOutput.new(my_fixture_read('npm_global'), 0))
6668
expect(provider.class.instances.map(&:properties).sort_by { |res| res[:name] }).to eq([
6769
{ ensure: '2.5.9', provider: 'npm', name: 'express' },
6870
{ ensure: '1.1.15', provider: 'npm', name: 'npm' }
6971
])
7072
end
7173

7274
it 'logs and continue if the list command has a non-zero exit code' do
73-
provider.class.expects(:execute).with(['/usr/local/bin/npm', 'list', '--json', '--global'], anything).returns(my_fixture_read('npm_global'))
74-
Process::Status.any_instance.expects(:success?).returns(false) # rubocop:disable RSpec/AnyInstance
75-
Process::Status.any_instance.expects(:exitstatus).returns(123) # rubocop:disable RSpec/AnyInstance
75+
provider.class.expects(:execute).
76+
with(['/usr/local/bin/npm', 'list', '--json', '--global'], anything).
77+
returns(Puppet::Util::Execution::ProcessOutput.new(my_fixture_read('npm_global'), 123))
7678
Puppet.expects(:debug).with(regexp_matches(%r{123}))
7779
expect(provider.class.instances.map(&:properties)).not_to eq([])
7880
end
7981

8082
it "logs and return no packages if JSON isn't output" do
81-
provider.class.expects(:execute).with(['/usr/local/bin/npm', 'list', '--json', '--global'], anything).returns('failure!')
82-
Process::Status.any_instance.expects(:success?).returns(true) # rubocop:disable RSpec/AnyInstance
83+
provider.class.expects(:execute).
84+
with(['/usr/local/bin/npm', 'list', '--json', '--global'], anything).
85+
returns(Puppet::Util::Execution::ProcessOutput.new('failure!', 0))
8386
Puppet.expects(:debug).with(regexp_matches(%r{npm list.*failure!}))
8487
expect(provider.class.instances).to eq([])
8588
end

0 commit comments

Comments
 (0)