Commit fee4f8cc authored by Toon Claes's avatar Toon Claes

test: Configure Gitaly's bundler with env vars

Setting up and spawning Gitaly in tests needs to have some Bundler
settings configured. Until now this was done by writing to the local
config file in the ruby directory inside the gitaly dir used in test.

This method didn't seem to be robust for all our user and
use-cases (i.e. CI), because this configuration _could_ be done from
different places.

To make the situation more predictable, this change injects all Bundler
configuration through environment variables instead.
parent f1083234
...@@ -13,8 +13,6 @@ class GitalyTestBuild ...@@ -13,8 +13,6 @@ class GitalyTestBuild
include GitalySetup include GitalySetup
def run def run
set_bundler_config
# If we have the binaries from the cache, we can skip building them again # If we have the binaries from the cache, we can skip building them again
if File.exist?(tmp_tests_gitaly_bin_dir) if File.exist?(tmp_tests_gitaly_bin_dir)
GitalySetup::LOGGER.debug "Gitaly binary already built. Skip building...\n" GitalySetup::LOGGER.debug "Gitaly binary already built. Skip building...\n"
......
...@@ -9,7 +9,6 @@ class GitalyTestSpawn ...@@ -9,7 +9,6 @@ class GitalyTestSpawn
include GitalySetup include GitalySetup
def run def run
set_bundler_config
install_gitaly_gems if ENV['CI'] install_gitaly_gems if ENV['CI']
check_gitaly_config! check_gitaly_config!
......
...@@ -54,9 +54,11 @@ module GitalySetup ...@@ -54,9 +54,11 @@ module GitalySetup
{ {
'HOME' => expand_path('tmp/tests'), 'HOME' => expand_path('tmp/tests'),
'GEM_PATH' => Gem.path.join(':'), 'GEM_PATH' => Gem.path.join(':'),
'BUNDLE_APP_CONFIG' => File.join(gemfile_dir, '.bundle'),
'BUNDLE_INSTALL_FLAGS' => nil, 'BUNDLE_INSTALL_FLAGS' => nil,
'BUNDLE_PATH' => bundle_path,
'BUNDLE_GEMFILE' => gemfile, 'BUNDLE_GEMFILE' => gemfile,
'BUNDLE_JOBS' => '4',
'BUNDLE_RETRY' => '3',
'RUBYOPT' => nil, 'RUBYOPT' => nil,
# Git hooks can't run during tests as the internal API is not running. # Git hooks can't run during tests as the internal API is not running.
...@@ -65,17 +67,11 @@ module GitalySetup ...@@ -65,17 +67,11 @@ module GitalySetup
} }
end end
# rubocop:disable GitlabSecurity/SystemCommandInjection def bundle_path
def set_bundler_config
system('bundle config set --local jobs 4', chdir: gemfile_dir)
system('bundle config set --local retry 3', chdir: gemfile_dir)
if ENV['CI'] if ENV['CI']
bundle_path = expand_path('vendor/gitaly-ruby') expand_path('vendor/gitaly-ruby')
system('bundle', 'config', 'set', '--local', 'path', bundle_path, chdir: gemfile_dir)
end end
end end
# rubocop:enable GitlabSecurity/SystemCommandInjection
def config_path(service) def config_path(service)
case service case service
......
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