Skip to content
Open
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
17 changes: 11 additions & 6 deletions app/models/shipit/deploy_spec/bundler_discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ def discover_machine_env
end

def bundle_install
bundle = %(bundle install #{frozen_flag} --jobs 4 --path #{bundle_path} --retry 2)
freeze_config = if frozen?
%(bundle config set frozen true)
else
%(bundle config set frozen false)
end
bundle = %(bundle install --jobs 4 --path #{bundle_path} --retry 2)
bundle += " --without=#{bundler_without.join(':')}" unless bundler_without.empty?
[remove_ruby_version_from_gemfile, bundle]
[remove_ruby_version_from_gemfile, freeze_config, bundle]
end

def remove_ruby_version_from_gemfile
Expand All @@ -41,11 +46,11 @@ def remove_ruby_version_from_gemfile
end
end

def frozen_flag
return unless gemfile_lock_exists?
return if config('dependencies', 'bundler', 'frozen') == false
def frozen?
return false unless gemfile_lock_exists?
return false if config('dependencies', 'bundler', 'frozen') == false

'--frozen'
true
end

def bundler_without
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module Shipit
]
},
"override": [
"bundle check --path=/tmp/bundler || bundle install --frozen --path=/tmp/bundler --retry=2 --without=default:production:development:test:staging:benchmark:debug"
"bundle check --path=/tmp/bundler || bundle install --path=/tmp/bundler --retry=2 --without=default:production:development:test:staging:benchmark:debug"
]
},
"fetch": [
Expand Down
14 changes: 6 additions & 8 deletions test/models/deploy_spec_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class DeploySpecTest < ActiveSupport::TestCase
@spec.stubs(:gemfile_lock_exists?).returns(true)
command = %(
bundle install
--frozen
--jobs 4
--path #{DeploySpec.bundle_path}
--retry 2
Expand All @@ -81,7 +80,6 @@ class DeploySpecTest < ActiveSupport::TestCase
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'without' => %w[some custom groups] } })
command = %(
bundle install
--frozen
--jobs 4
--path #{DeploySpec.bundle_path}
--retry 2
Expand All @@ -90,22 +88,22 @@ class DeploySpecTest < ActiveSupport::TestCase
assert_equal command, @spec.bundle_install.last
end

test '#bundle_install has --frozen option if Gemfile.lock is present' do
test '#bundle_install has frozen option if Gemfile.lock is present' do
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'without' => %w[some custom groups] } })
@spec.stubs(:gemfile_lock_exists?).returns(true)
assert @spec.bundle_install.last.include?('--frozen')
assert @spec.bundle_install.any?.include?('bundle config set frozen true')
end

test '#bundle_install does not have --frozen option if Gemfile.lock is not present' do
test '#bundle_install does not set frozen option if Gemfile.lock is not present' do
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'without' => %w[some custom groups] } })
@spec.stubs(:gemfile_lock_exists?).returns(false)
refute @spec.bundle_install.last.include?('--frozen')
assert @spec.bundle_install.any?.include?('bundle config set frozen false')
end

test '#bundle_install does not have --frozen if overridden in shipit.yml' do
test '#bundle_install does not have frozen if overridden in shipit.yml' do
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'frozen' => false } })
@spec.stubs(:gemfile_lock_exists?).returns(true)
refute @spec.bundle_install.last.include?('--frozen')
assert @spec.bundle_install.any?.include?('bundle config set frozen false')
end

test "#provisioning_handler returns `provision.handler` if present" do
Expand Down
Loading