Commit 8560c74f authored by Toon Claes's avatar Toon Claes

test: Expand bundle path to absolute path

In previous commit we started setting BUNDLE_PATH as an environment
variable, and this works great. But this value gets overridden in case
it's specified in the local config. You can see so by using the
`bundle config` command:

    $ BUNDLE_PATH=vendor/bundle bundle config path
    Settings for `path` in order of priority. The top value will be used
    Set for your local app (/home/r/gdk/gitlab/.bundle/config): "vendor/bundle"
    Set via BUNDLE_PATH: "vendor/bundle"
    Set for the current user (/home/r/.config/bundle): "vendor/bundle"

This isn't persay an issue, but in most cases this is set as a relative
path. Because different `bundle` commands might get triggered from
different directory levels in the project tree, this might become an
issue.

To overcome this, the active value of BUNDLE_PATH is read, expanded to
an absolute path and passed back to the environment. But because of the
prioritization demonstrated above, we need to set BUNDLE_IGNORE_CONFIG
so any local, user, or system configuration is ignored.
parent 15c406cc
......@@ -9,6 +9,7 @@
require 'securerandom'
require 'socket'
require 'logger'
require 'bundler'
module GitalySetup
LOGGER = begin
......@@ -55,6 +56,7 @@ module GitalySetup
'HOME' => expand_path('tmp/tests'),
'GEM_PATH' => Gem.path.join(':'),
'BUNDLE_INSTALL_FLAGS' => nil,
'BUNDLE_IGNORE_CONFIG' => '1',
'BUNDLE_PATH' => bundle_path,
'BUNDLE_GEMFILE' => gemfile,
'BUNDLE_JOBS' => '4',
......@@ -70,6 +72,12 @@ module GitalySetup
def bundle_path
if ENV['CI']
expand_path('vendor/gitaly-ruby')
else
explicit_path = Bundler.configured_bundle_path.explicit_path
return unless explicit_path
expand_path(explicit_path)
end
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