Commit cc17af1f authored by Thong Kuah's avatar Thong Kuah

Fix gitaly setup running always for specs setup

Since we switched to shas in GITALY_SERVER_VERSION, it no longer matches
the VERSION in gitaly. As we cannot update VERSION as that is in another
project, we match GITALY_SERVER_VERSION against checked out git sha
instead, in order to determine if we need to run gitaly setup again
parent 39b70204
......@@ -6,6 +6,8 @@ module TestEnv
ComponentFailedToInstallError = Class.new(StandardError)
SHA_REGEX = /\A[0-9a-f]{5,40}\z/i.freeze
# When developing the seed repository, comment out the branch you will modify.
BRANCH_SHA = {
'signed-commits' => '6101e87',
......@@ -508,6 +510,8 @@ module TestEnv
# Allow local overrides of the component for tests during development
return false if Rails.env.test? && File.symlink?(component_folder)
return false if component_matches_git_sha?(component_folder, expected_version)
version = File.read(File.join(component_folder, 'VERSION')).strip
# Notice that this will always yield true when using branch versions
......@@ -517,6 +521,16 @@ module TestEnv
rescue Errno::ENOENT
true
end
def component_matches_git_sha?(component_folder, expected_version)
# Not a git SHA, so return early
return false unless expected_version =~ SHA_REGEX
sha, exit_status = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} rev-parse HEAD), component_folder)
return false if exit_status != 0
expected_version == sha.chomp
end
end
require_relative('../../../ee/spec/support/helpers/ee/test_env') if Gitlab.ee?
......
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