Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1100) Exclude known artifacts from build instead of cleaning #575

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions lib/pdk/module/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
module PDK
module Module
class Build
DEFAULT_IGNORED = [
'/pkg/',
'.*',
'~*',
'/coverage',
'/checksums.json',
'/REVISION',
'/spec/fixtures/modules/',
].freeze

def self.invoke(options = {})
new(options).build
end
Expand Down Expand Up @@ -37,7 +47,6 @@ def package_file
#
# @return [String] The path to the built package file.
def build
cleanup_module
create_build_dir

stage_module_in_build_dir
Expand Down Expand Up @@ -83,17 +92,6 @@ def cleanup_build_dir
FileUtils.rm_rf(build_dir, secure: true)
end

# Clean up any files created during use of the PDK that shouldn't be part
# of the built module (e.g. test fixtures).
#
# @return nil
def cleanup_module
PDK::Util::Bundler.ensure_bundle!
PDK::Util::Bundler.ensure_binstubs!('rake')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to re-appear somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, the purpose of this change is to remove the need for the in-module bundler environment when building release tarballs


PDK::Test::Unit.tear_down
end

# Combine the module name and version into a Forge-compatible dash
# separated string.
#
Expand Down Expand Up @@ -215,6 +213,8 @@ def ignored_files
ignored = ignored.add("\/#{File.basename(target_dir)}\/")
end

DEFAULT_IGNORED.each { |r| ignored.add(r) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will add duplicate entries to the ignore list if there are common ignores between the pmt/pdk/git ignore files and the defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicates shouldn't cause an issue (just as you can have duplicate entries in a .gitignore).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, we don't currently clear dupes from the ignore file either.


ignored
end
end
Expand Down
16 changes: 0 additions & 16 deletions spec/unit/pdk/module/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,4 @@
end
end
end

describe '#cleanup_module' do
subject(:instance) { described_class.new(module_dir: module_dir) }

let(:module_dir) { File.join(root_dir, 'tmp', 'my-module') }

after(:each) do
instance.cleanup_module
end

it 'ensures the rake binstub is present before cleaning up spec fixtures' do
expect(PDK::Util::Bundler).to receive(:ensure_bundle!).ordered
expect(PDK::Util::Bundler).to receive(:ensure_binstubs!).with('rake').ordered
expect(PDK::Test::Unit).to receive(:tear_down).ordered
end
end
end