Skip to content

Commit

Permalink
Merge pull request #1268 from puppetlabs/maint-reinstate_pdk_2.x_docs
Browse files Browse the repository at this point in the history
(maint) - update pdk.ditamap version
  • Loading branch information
GSPatton authored Aug 7, 2023
2 parents 43de45c + ef66deb commit 868cf9d
Show file tree
Hide file tree
Showing 24 changed files with 58 additions and 121 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
fail-fast: false
matrix:
ruby_version:
- '2.5'
- '2.7'
- "2.7"
- "3.2"
name: "spec (ruby ${{ matrix.ruby_version }})"
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
secrets: "inherit"
Expand All @@ -29,8 +29,8 @@ jobs:
- "ubuntu-latest"
- "windows-2019"
ruby_version:
- "2.5"
- "2.7"
- "3.2"
name: "acceptance (ruby ${{ matrix.ruby_version }} | ${{ matrix.os }})"
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main"
secrets: "inherit"
Expand Down
2 changes: 1 addition & 1 deletion docs/pdk.ditamap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<prodinfo>
<prodname>pdk</prodname>
<vrmlist>
<vrm version="latest"/>
<vrm version="3.x"/>
</vrmlist>
</prodinfo>
</topicmeta>
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/util/changelog_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def self.generate_changelog

output = changelog_content

raise PDK::CLI::ExitWithError, format('The generated changelog contains uncategorized Pull Requests. Please label them and try again. See %{changelog_file} for more details', changelog_file: changelog_file) if output.include?('UNCATEGORIZED PRS; GO LABEL THEM') # rubocop:disable Metrics/LineLength
raise PDK::CLI::ExitWithError, format('The generated changelog contains uncategorized Pull Requests. Please label them and try again. See %{changelog_file} for more details', changelog_file: changelog_file) if output.include?('UNCATEGORIZED PRS; GO LABEL THEM') # rubocop:disable Layout/LineLength

output
end
Expand Down
6 changes: 2 additions & 4 deletions spec/support/packaged_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
let(:package_cachedir) { '/package/share/cache' }

before do
allow(PDK::Util).to receive(:package_install?).and_return(true)
allow(PDK::Util).to receive_messages(package_install?: true, package_cachedir: package_cachedir)
allow(PDK::Util::Filesystem).to receive(:file?).with(/PDK_VERSION/).and_return(true)
allow(PDK::Util::Filesystem).to receive(:exist?).with(/bundle(\.bat)?$/).and_return(true)
allow(PDK::Util).to receive(:package_cachedir).and_return(package_cachedir)
allow(PDK::Util::RubyVersion).to receive(:versions).and_return('2.4.4' => '2.4.0')
allow(PDK::Util::RubyVersion).to receive(:default_ruby_version).and_return('2.4.4')
allow(PDK::Util::RubyVersion).to receive_messages(versions: { '2.4.4' => '2.4.0' }, default_ruby_version: '2.4.4')
end
end

Expand Down
9 changes: 3 additions & 6 deletions spec/unit/pdk/cli/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@

context 'and the module contains incomplete metadata' do
before do
allow(mock_metadata_obj).to receive(:forge_ready?).and_return(false)
allow(mock_metadata_obj).to receive(:missing_fields).and_return(['operatingsystem_support', 'source'])
allow(mock_metadata_obj).to receive_messages(forge_ready?: false, missing_fields: ['operatingsystem_support', 'source'])
allow(PDK::Module::Build).to receive(:new).with(any_args).and_return(mock_builder)
end

Expand Down Expand Up @@ -146,8 +145,7 @@

context 'package already exists in the target dir' do
before do
allow(mock_builder).to receive(:package_already_exists?).and_return(true)
allow(mock_builder).to receive(:module_pdk_compatible?).and_return(true)
allow(mock_builder).to receive_messages(package_already_exists?: true, module_pdk_compatible?: true)
end

context 'user chooses to continue' do
Expand Down Expand Up @@ -181,8 +179,7 @@

context 'and module is not pdk compatible' do
before do
allow(mock_builder).to receive(:package_already_exists?).and_return(false)
allow(mock_builder).to receive(:module_pdk_compatible?).and_return(false)
allow(mock_builder).to receive_messages(package_already_exists?: false, module_pdk_compatible?: false)
end

context 'user chooses to continue' do
Expand Down
6 changes: 2 additions & 4 deletions spec/unit/pdk/cli/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
end

before do
allow(PDK::Util::RubyVersion).to receive(:gem_home).and_return('/opt/puppetlabs/pdk/share/cache/ruby/2.4.0')
allow(PDK::Util::RubyVersion).to receive(:gem_path).and_return('/opt/puppetlabs/pdk/private/ruby/2.4.3/lib')
allow(PDK::Util::RubyVersion).to receive(:bin_path).and_return('/opt/puppetlabs/pdk/private/ruby/2.4.3/bin')
allow(PDK::Util::RubyVersion).to receive(:gem_paths_raw).and_return(['/opt/puppetlabs/pdk/private/ruby/2.4.3/lib'])
allow(PDK::Util::RubyVersion).to receive_messages(gem_home: '/opt/puppetlabs/pdk/share/cache/ruby/2.4.0', gem_path: '/opt/puppetlabs/pdk/private/ruby/2.4.3/lib',
bin_path: '/opt/puppetlabs/pdk/private/ruby/2.4.3/bin', gem_paths_raw: ['/opt/puppetlabs/pdk/private/ruby/2.4.3/lib'])
allow(PDK::Util::Env).to receive(:[]).and_call_original
allow(PDK::Util::Env).to receive(:[]).with('PATH').and_return('/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin')

Expand Down
3 changes: 1 addition & 2 deletions spec/unit/pdk/cli/exec/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@
before do
command.context = :system
expect(process).to receive(:start).with(no_args)
allow(process).to receive(:exit_code).and_return 0
allow(process).to receive(:environment).and_return({})
allow(process).to receive_messages(exit_code: 0, environment: {})
end

it { expect { command.execute! }.not_to raise_error }
Expand Down
3 changes: 1 addition & 2 deletions spec/unit/pdk/cli/exec/interactive_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@

before do
# rubocop:disable RSpec/SubjectStub
allow(command).to receive(:resolved_env_for_command).and_return(environment)
allow(command).to receive_messages(resolved_env_for_command: environment, child_status: child_status)
allow(command).to receive(:system) # Kernel is a mixed-in module
allow(command).to receive(:child_status).and_return(child_status)
# rubocop:enable RSpec/SubjectStub
end

Expand Down
3 changes: 1 addition & 2 deletions spec/unit/pdk/cli/release_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@

context 'With a module that is not forge ready' do
before do
allow(mock_metadata_obj).to receive(:forge_ready?).and_return(false)
allow(mock_metadata_obj).to receive(:missing_fields).and_return(['mock_field'])
allow(mock_metadata_obj).to receive_messages(forge_ready?: false, missing_fields: ['mock_field'])
end

it 'raises a warning' do
Expand Down
7 changes: 2 additions & 5 deletions spec/unit/pdk/cli/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@

before do
allow(PDK).to receive(:context).and_return(pdk_context)
allow(PDK::Util).to receive(:module_root).and_return(module_root)
allow(PDK::Util).to receive(:module_pdk_compatible?).and_return(true)
allow(PDK::Util).to receive(:module_pdk_version).and_return(module_pdk_version)
allow(PDK::Util).to receive_messages(module_root: module_root, module_pdk_compatible?: true, module_pdk_version: module_pdk_version)
end

context 'and provided no flags' do
Expand Down Expand Up @@ -232,8 +230,7 @@

context 'when run from inside an unconverted module' do
before do
allow(PDK::Util).to receive(:module_root).and_return(module_root)
allow(PDK::Util).to receive(:module_pdk_compatible?).and_return(false)
allow(PDK::Util).to receive_messages(module_root: module_root, module_pdk_compatible?: false)
end

context 'and provided no flags' do
Expand Down
9 changes: 3 additions & 6 deletions spec/unit/pdk/cli/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@
end

before do
allow(PDK::Util::PuppetVersion).to receive(:puppet_dev_path).and_return(puppet_version)
allow(PDK::Util::PuppetVersion).to receive(:puppet_dev_env).and_return(version_result)
allow(PDK::Util::PuppetVersion).to receive_messages(puppet_dev_path: puppet_version, puppet_dev_env: version_result)
allow(PDK::Util::PuppetVersion).to receive(:fetch_puppet_dev)
end

Expand All @@ -222,8 +221,7 @@
end

before do
allow(PDK::Util::PuppetVersion).to receive(:puppet_dev_path).and_return(puppet_version)
allow(PDK::Util::PuppetVersion).to receive(:puppet_dev_env).and_return(version_result)
allow(PDK::Util::PuppetVersion).to receive_messages(puppet_dev_path: puppet_version, puppet_dev_env: version_result)
allow(PDK::Util::Env).to receive(:[]).with('PDK_PUPPET_DEV').and_return('true')
allow(PDK::Util::PuppetVersion).to receive(:fetch_puppet_dev)
end
Expand Down Expand Up @@ -283,8 +281,7 @@
let(:puppet_version) { '8.1.0' }

before do
allow(PDK::Util::PuppetVersion).to receive(:from_module_metadata).and_return(nil)
allow(PDK::Util::PuppetVersion).to receive(:latest_available).and_return(version_result)
allow(PDK::Util::PuppetVersion).to receive_messages(from_module_metadata: nil, latest_available: version_result)
end

it_behaves_like 'it returns a puppet environment'
Expand Down
9 changes: 3 additions & 6 deletions spec/unit/pdk/generate/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
allow(renderer).to receive(:render).and_yield(*yielded_file)

allow(test_template_path).to receive(:+).with(anything).and_return(test_template_path)
allow(test_template_path).to receive(:dirname).and_return(test_template_path)
allow(test_template_path).to receive(:relative?).and_return(true)
allow(test_template_path).to receive_messages(dirname: test_template_path, relative?: true)
# TODO: This is overkill. e.g. this breaks using 'require 'pry'; binding.pry'.
allow(Pathname).to receive(:new).with(anything).and_return(test_template_path)
allow(PDK::Util::Filesystem).to receive(:write_file)
Expand Down Expand Up @@ -88,8 +87,7 @@
allow(described_class).to receive(:prepare_module_directory).with(temp_target_dir)
allow(PDK::Util::Filesystem).to receive(:write_file).with(/pdk-test-writable/, anything) { raise Errno::EACCES unless target_parent_writeable }
allow(PDK::Util::Filesystem).to receive(:rm_f).with(/pdk-test-writable/)
allow(PDK::Util).to receive(:module_root).and_return(nil)
allow(PDK::Util).to receive(:package_install?).and_return(false)
allow(PDK::Util).to receive_messages(module_root: nil, package_install?: false)
end

context 'when the parent directory of the target is not writable' do
Expand Down Expand Up @@ -256,8 +254,7 @@
context 'and no template-url answer exists' do
context 'and pdk is installed from packages' do
before do
allow(PDK::Util).to receive(:package_install?).and_return(true)
allow(PDK::Util).to receive(:package_cachedir).and_return('/tmp/package/cache')
allow(PDK::Util).to receive_messages(package_install?: true, package_cachedir: '/tmp/package/cache')
end

it 'uses the vendored template url' do
Expand Down
14 changes: 4 additions & 10 deletions spec/unit/pdk/generate/puppet_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

before do
stub_const('PDK::Generate::PuppetObject::OBJECT_TYPE', object_type)
allow(PDK::Util).to receive(:package_install?).and_return(false)
allow(PDK::Util).to receive(:module_root).and_return(module_dir)
allow(PDK::Util).to receive_messages(package_install?: false, module_root: module_dir)
end

describe '#spec_only?' do
Expand Down Expand Up @@ -133,9 +132,7 @@

before do
# Mock required PuppetObject methods
allow(templated_object).to receive(:friendly_name).and_return('spec_object')
allow(templated_object).to receive(:template_files).and_return('source' => 'target')
allow(templated_object).to receive(:templates).and_return(templates)
allow(templated_object).to receive_messages(friendly_name: 'spec_object', template_files: { 'source' => 'target' }, templates: templates)

allow(PDK::Template).to receive(:with) # An unknown uri will not yield
allow(PDK::Template).to receive(:with).with(uri_of('expected1'), pdk_context).and_yield(expected1_template_dir)
Expand Down Expand Up @@ -213,12 +210,9 @@

before do
# Mock required PuppetObject methods
allow(templated_object).to receive(:template_files).and_return(template_files)
allow(templated_object).to receive(:template_data).and_return({})
allow(templated_object).to receive(:friendly_name).and_return('spec_object')
allow(templated_object).to receive(:non_template_files).and_return(non_template_files)
allow(templated_object).to receive_messages(template_files: template_files, template_data: {}, friendly_name: 'spec_object', non_template_files: non_template_files,
update_manager_instance: update_manager)
# Mock external objects
allow(templated_object).to receive(:update_manager_instance).and_return(update_manager)
allow(templated_object).to receive(:with_templates).and_yield(template_dir)
# Mock rendering of the template file
allow(template_dir).to receive(:render_single_item).and_return('mock response')
Expand Down
6 changes: 2 additions & 4 deletions spec/unit/pdk/module/convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,7 @@ def module_path(relative_path)

before do
allow(PDK::Util::PuppetStrings).to receive(:all_objects).and_return(objects)
allow(PDK::Util).to receive(:module_root).and_return(module_root)
allow(PDK::Util).to receive(:module_metadata).and_return(metadata)
allow(PDK::Util).to receive_messages(module_root: module_root, module_metadata: metadata)
end

let(:metadata) { { 'name' => 'myuser-mymodule' } }
Expand Down Expand Up @@ -674,8 +673,7 @@ def module_path(relative_path)

before do
allow(PDK::Util::PuppetStrings).to receive(:all_objects).and_return(objects)
allow(PDK::Util).to receive(:module_root).and_return(module_root)
allow(PDK::Util).to receive(:module_metadata).and_return(metadata)
allow(PDK::Util).to receive_messages(module_root: module_root, module_metadata: metadata)
allow(PDK).to receive(:context).and_return(pdk_context)
end

Expand Down
28 changes: 8 additions & 20 deletions spec/unit/pdk/module/release_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

before do
# Mimic PDK being run in the root of a module in current working directory
allow(PDK::Util).to receive(:find_upwards).and_return(nil)
allow(PDK::Util).to receive(:in_module_root?).and_return(true)
allow(PDK::Util).to receive_messages(find_upwards: nil, in_module_root?: true)
allow(Dir).to receive(:pwd).and_return(module_root)
allow(PDK::Util::ChangelogGenerator).to receive(:changelog_content).and_return('This is a changelog')

Expand Down Expand Up @@ -170,9 +169,7 @@

context 'when skipping the build' do
before do
allow(instance).to receive(:skip_build?).and_return(true)
allow(instance).to receive(:forge_upload_url).and_return('https://localhost')
allow(instance).to receive(:forge_token).and_return('abc123')
allow(instance).to receive_messages(skip_build?: true, forge_upload_url: 'https://localhost', forge_token: 'abc123')
end

it 'uses the default package filename when a file is not specified to publish' do
Expand All @@ -190,9 +187,7 @@

context 'when running the build helper' do
before do
allow(instance).to receive(:skip_build?).and_return(false)
allow(instance).to receive(:forge_upload_url).and_return('https://localhost')
allow(instance).to receive(:forge_token).and_return('abc123')
allow(instance).to receive_messages(skip_build?: false, forge_upload_url: 'https://localhost', forge_token: 'abc123')
end

it 'uses the built tarball to publish' do
Expand Down Expand Up @@ -238,9 +233,7 @@
# under test really needs to be refactored

before do
allow(PDK::CLI::Util).to receive(:validate_puppet_version_opts).and_return(nil)
allow(PDK::CLI::Util).to receive(:module_version_check).and_return(nil)
allow(PDK::CLI::Util).to receive(:puppet_from_opts_or_env).and_return(gemset: {}, ruby_version: '1.2.3')
allow(PDK::CLI::Util).to receive_messages(validate_puppet_version_opts: nil, module_version_check: nil, puppet_from_opts_or_env: { gemset: {}, ruby_version: '1.2.3' })
allow(PDK::Util::PuppetVersion).to receive(:fetch_puppet_dev).and_return(nil)
allow(PDK::Util::RubyVersion).to receive(:use).and_return(nil)
allow(PDK::Util::Bundler).to receive(:ensure_bundle!).and_return(nil)
Expand Down Expand Up @@ -321,8 +314,7 @@
# under test really needs to be refactored

before do
allow(instance).to receive(:forge_token).and_return('abc123')
allow(instance).to receive(:forge_upload_url).and_return('https://badapi.puppetlabs.com/v3/releases')
allow(instance).to receive_messages(forge_token: 'abc123', forge_upload_url: 'https://badapi.puppetlabs.com/v3/releases')
allow(PDK::Util::Filesystem).to receive(:file?).with(tarball_path).and_return(true)
allow(PDK::Util::Filesystem).to receive(:read_file).with(tarball_path, Hash).and_return('tarball_contents')
allow(Net::HTTP).to receive(:start).and_return(http_response)
Expand Down Expand Up @@ -358,21 +350,17 @@
end

it 'raises when missing the forge upload url' do
allow(instance).to receive(:forge_upload_url).and_return(nil)
allow(instance).to receive(:forge_token).and_return('abc123')
allow(instance).to receive_messages(forge_upload_url: nil, forge_token: 'abc123')
expect { instance.validate_publish_options! }.to raise_error(PDK::CLI::ExitWithError)
end

it 'raises when missing the forge token' do
allow(instance).to receive(:forge_upload_url).and_return('https://localhost')
allow(instance).to receive(:forge_token).and_return(nil)
allow(instance).to receive_messages(forge_upload_url: 'https://localhost', forge_token: nil)
expect { instance.validate_publish_options! }.to raise_error(PDK::CLI::ExitWithError)
end

it 'does not raise when publishing is skipped' do
allow(instance).to receive(:skip_publish?).and_return(true)
allow(instance).to receive(:forge_upload_url).and_return(nil)
allow(instance).to receive(:forge_token).and_return(nil)
allow(instance).to receive_messages(skip_publish?: true, forge_upload_url: nil, forge_token: nil)
expect { instance.validate_publish_options! }.not_to raise_error
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/unit/pdk/module/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,8 @@ def module_path(relative_path)

context 'and PDK is running from a package install' do
before do
allow(PDK::Util).to receive(:package_install?).and_return(true)
allow(PDK::Util).to receive_messages(package_install?: true, package_cachedir: File.join('package', 'cachedir'))
allow(PDK::Util::Version).to receive(:git_ref).and_return('1234acb')
allow(PDK::Util).to receive(:package_cachedir).and_return(File.join('package', 'cachedir'))
end

it 'returns the default ref' do
Expand Down
Loading

0 comments on commit 868cf9d

Please sign in to comment.