Skip to content

Commit

Permalink
Merge pull request #575 from rodjek/pdk-1100
Browse files Browse the repository at this point in the history
(PDK-1100) Exclude known artifacts from build instead of cleaning
  • Loading branch information
bmjen authored Oct 3, 2018
2 parents 1c30b4f + 824abb5 commit 810d1d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
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')

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) }

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

0 comments on commit 810d1d3

Please sign in to comment.