Commit 77f41fff authored by Albert Salim's avatar Albert Salim Committed by Rémy Coutable

Fix Bundle config for gitaly bundle

`BUNDLE_FLAGS=--no-deployment` was not picked up
during bundle install in `tmp/tests/gitaly/ruby`.

As a result, `tmp/tests/gitaly/ruby` had `BUNDLE_DEPLOYMENT: "true"`.

This leads to default bundle path being `vendor/bundle`, instead of
using `GEM_HOME`
parent 2e647463
......@@ -17,24 +17,29 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
checkout_or_clone_version(version: version, repo: args.repo, target_dir: args.dir, clone_opts: %w[--depth 1])
command = []
_, status = Gitlab::Popen.popen(%w[which gmake])
command << (status == 0 ? 'gmake' : 'make')
if Rails.env.test?
command.push(
'BUNDLE_FLAGS=--no-deployment',
"GEM_HOME=#{Bundler.bundle_path}")
end
storage_paths = { 'default' => args.storage_path }
Gitlab::SetupHelper::Gitaly.create_configuration(args.dir, storage_paths)
# In CI we run scripts/gitaly-test-build
next if ENV['CI'].present?
Dir.chdir(args.dir) do
# In CI we run scripts/gitaly-test-build instead of this command
unless ENV['CI'].present?
Bundler.with_original_env { Gitlab::Popen.popen(command, nil, { "RUBYOPT" => nil, "BUNDLE_GEMFILE" => nil }) }
Bundler.with_original_env do
env = { "RUBYOPT" => nil, "BUNDLE_GEMFILE" => nil }
if Rails.env.test?
env["GEM_HOME"] = Bundler.bundle_path.to_s
env["BUNDLE_DEPLOYMENT"] = 'false'
end
Gitlab::Popen.popen([make_cmd], nil, env)
end
end
end
def make_cmd
_, status = Gitlab::Popen.popen(%w[which gmake])
status == 0 ? 'gmake' : 'make'
end
end
end
......@@ -41,6 +41,7 @@ RSpec.describe 'gitlab:gitaly namespace rake task' do
describe 'checkout or clone' do
before do
stub_env('CI', false)
expect(Dir).to receive(:chdir).with(clone_path)
end
......@@ -86,18 +87,14 @@ RSpec.describe 'gitlab:gitaly namespace rake task' do
end
context 'when Rails.env is test' do
let(:command) do
%W[make
BUNDLE_FLAGS=--no-deployment
GEM_HOME=#{Bundler.bundle_path}]
end
let(:command) { %w[make] }
before do
stub_rails_env('test')
end
it 'calls make in the gitaly directory with --no-deployment flag for bundle' do
expect(Gitlab::Popen).to receive(:popen).with(command, nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }).and_return(true)
it 'calls make in the gitaly directory with BUNDLE_DEPLOYMENT and GEM_HOME variables' do
expect(Gitlab::Popen).to receive(:popen).with(command, nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil, "BUNDLE_DEPLOYMENT" => 'false', "GEM_HOME" => Bundler.bundle_path.to_s }).and_return(true)
subject
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment