Skip to content

Commit

Permalink
Merge pull request #933 from scotje/maint_fix_bundler_install_check
Browse files Browse the repository at this point in the history
(MAINT) Fix up acceptance tests and configuration for recent releases of dependencies
  • Loading branch information
scotje committed Jan 11, 2021
2 parents 75758fd + 7700ace commit 2e70d6b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 23 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Expand Up @@ -20,19 +20,18 @@ before_install:
cache: bundler
jobs:
include:
- rvm: 2.4.3
- rvm: 2.5
env: CHECK=rubocop
# Make sure that the we still work with an older Bundler version
- rvm: 2.4.3
env: CHECK=acceptance:smoke BUNDLER_VERSION=2.0.2
- rvm: 2.4.3
- rvm: 2.5
env: CHECK=acceptance:smoke
- rvm: 2.5
env: CHECK=acceptance:local_parallel
- rvm: 2.4.3
- rvm: 2.5
env: CHECK=spec:coverage
- rvm: 2.4.3
- rvm: 2.5
env: CHECK=license_finder
bundler_args: "--with development" # license_finder requires all gems installed. Also can't use an empty string so just include any bundler group
- rvm: 2.5
- rvm: 2.4
env: CHECK=spec
- rvm: 2.3
env: CHECK=spec
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Expand Up @@ -9,11 +9,11 @@ environment:
# USE_MSYS: true
# SUITES: "spec"
# BUNDLE_JOBS: 4
- RUBY_VERSION: 24-x64
- RUBY_VERSION: 25-x64
USE_MSYS: true
SUITES: "acceptance:smoke"
BUNDLE_JOBS: 4
- RUBY_VERSION: 24-x64
- RUBY_VERSION: 25-x64
USE_MSYS: true
SUITES: "acceptance:local_parallel"
BUNDLE_JOBS: 4
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/module/metadata.rb
Expand Up @@ -77,7 +77,7 @@ class Metadata
OPERATING_SYSTEMS[os_name]
}.flatten,
'requirements' => [
{ 'name' => 'puppet', 'version_requirement' => '>= 4.10.0 < 7.0.0' },
{ 'name' => 'puppet', 'version_requirement' => '>= 4.10.0 < 8.0.0' },
],
}.freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/util/bundler.rb
Expand Up @@ -44,7 +44,7 @@ def self.ensure_bundle!(gem_overrides = nil)
# If there are missing dependencies after updating the lockfile, let `bundle install`
# go out and get them. If the specified puppet gem version points to a remote location
# or local filepath, then run bundle install as well.
if !bundle.installed? || (gem_overrides[:puppet] && gem_overrides[:puppet].start_with?('file://', 'git://', 'https://'))
if !bundle.installed?(gem_overrides) || (gem_overrides[:puppet] && gem_overrides[:puppet].start_with?('file://', 'git://', 'https://'))
bundle.install!(gem_overrides)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/pdk/util/puppet_version.rb
Expand Up @@ -17,7 +17,7 @@ def instance

PE_VERSIONS_URL = 'https://forgeapi.puppet.com/private/versions/pe'.freeze
DEFAULT_PUPPET_DEV_URL = 'https://github.com/puppetlabs/puppet'.freeze
DEFAULT_PUPPET_DEV_BRANCH = 'master'.freeze
DEFAULT_PUPPET_DEV_BRANCH = 'main'.freeze

def puppet_dev_env
require 'pdk/util/ruby_version'
Expand Down Expand Up @@ -80,7 +80,7 @@ def fetch_puppet_dev(options = {})
end

# Reset local repo to latest
reset_result = PDK::Util::Git.git('-C', puppet_dev_path, 'reset', '--hard', 'origin/master')
reset_result = PDK::Util::Git.git('-C', puppet_dev_path, 'reset', '--hard', "origin/#{DEFAULT_PUPPET_DEV_BRANCH}")

@puppet_dev_fetched = true
return if reset_result[:exit_code].zero?
Expand Down
1 change: 0 additions & 1 deletion package-testing/Rakefile
Expand Up @@ -69,7 +69,6 @@ namespace :acceptance do

puts "Generating beaker hosts using TEST_TARGET value #{test_target}"


cli = BeakerHostGenerator::CLI.new(["#{test_target}{type=foss}", '--disable-default-role', '--hypervisor', 'abs'])

File.open('acceptance_hosts.yml', 'w') do |hosts_file|
Expand Down
2 changes: 1 addition & 1 deletion package-testing/config/options.rb
Expand Up @@ -3,5 +3,5 @@
keys: ['~/.ssh/id_rsa-acceptance'],
},
preserve_hosts: 'onfail',
provision: 'true'
provision: 'true',
}
4 changes: 4 additions & 0 deletions spec/acceptance/validate_ruby_spec.rb
Expand Up @@ -11,6 +11,7 @@

before(:all) do
File.open(spec_violation_rb, 'w') do |f|
f.puts "# frozen_string_literal: true\n\n"
f.puts 'f = %(x y z)'
end
end
Expand Down Expand Up @@ -41,6 +42,7 @@
before(:all) do
FileUtils.mkdir_p(File.dirname(another_violation_rb))
File.open(another_violation_rb, 'w') do |f|
f.puts "# frozen_string_literal: true\n\n"
f.puts "puts {:foo => 'bar'}.inspect"
end
end
Expand Down Expand Up @@ -87,6 +89,7 @@
context 'when auto-correcting violations' do
before(:all) do
File.open('test.rb', 'w') do |f|
f.puts "# frozen_string_literal: true\n\n"
f.puts "puts({'a' => 'b'}.inspect)"
end
end
Expand All @@ -111,6 +114,7 @@
FileUtils.mkdir_p(File.join('spec', 'unit'))
(1..5000).each do |num|
File.open(File.join('spec', 'unit', "test#{num}.rb"), 'w') do |f|
f.puts "# frozen_string_literal: true\n\n"
f.puts "puts({ 'a' => 'b' }.inspect)"
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/acceptance/version_changer_spec.rb
Expand Up @@ -21,7 +21,7 @@
end
end

%w[5.5.0 4.10.10].each do |puppet_version|
%w[6.19.1 5.5.22].each do |puppet_version|
describe command("pdk validate --puppet-version #{puppet_version}") do
its(:exit_status) { is_expected.to eq(0) }
end
Expand All @@ -32,7 +32,7 @@
end
end

{ '2017.3.1' => '5.3.2', '2017.2.5' => '4.10.9' }.each do |pe_version, puppet_version|
{ '2018.1.18' => '5.5.22' }.each do |pe_version, puppet_version|
describe command("pdk validate --pe-version #{pe_version}") do
its(:exit_status) { is_expected.to eq(0) }
end
Expand All @@ -56,6 +56,8 @@ class version_select {
FileUtils.mkdir_p(File.join('spec', 'classes'))
File.open(File.join('spec', 'classes', 'version_select_spec.rb'), 'w') do |f|
f.puts <<-TESTFILE
# frozen_string_literal: true
require 'spec_helper'
describe 'version_select' do
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/pdk/util/puppet_version_spec.rb
Expand Up @@ -211,7 +211,7 @@
before(:each) do
allow(PDK::Util).to receive(:cachedir).and_return('/path/to/')
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'fetch', 'origin').and_return(fetch_results)
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'reset', '--hard', 'origin/master').and_return(exit_code: 0)
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'reset', '--hard', 'origin/main').and_return(exit_code: 0)
end

it 'exits cleanly' do
Expand All @@ -231,7 +231,7 @@
before(:each) do
allow(PDK::Util).to receive(:cachedir).and_return('/path/to/')
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'fetch', 'origin').and_return(exit_code: 0)
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'reset', '--hard', 'origin/master').and_return(reset_results)
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'reset', '--hard', 'origin/main').and_return(reset_results)
end

it 'raises an error' do
Expand All @@ -255,7 +255,7 @@
before(:each) do
allow(PDK::Util).to receive(:cachedir).and_return('/path/to/')
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'fetch', 'origin').and_return(exit_code: 0)
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'reset', '--hard', 'origin/master').and_return(reset_results)
allow(PDK::Util::Git).to receive(:git).with('-C', anything, 'reset', '--hard', 'origin/main').and_return(reset_results)
end

it 'exits cleanly' do
Expand Down Expand Up @@ -555,8 +555,8 @@ def result(pe_version)
let(:metadata) { PDK::Module::Metadata.new }

context 'with default metadata' do
it 'searches for a Puppet gem >= 4.10.0 < 7.0.0' do
requirement = Gem::Requirement.create(['>= 4.10.0', '< 7.0.0'])
it 'searches for a Puppet gem >= 4.10.0 < 8.0.0' do
requirement = Gem::Requirement.create(['>= 4.10.0', '< 8.0.0'])
expect(described_class.instance).to receive(:find_gem).with(requirement)

described_class.from_module_metadata(metadata)
Expand Down

0 comments on commit 2e70d6b

Please sign in to comment.