From d28887ff2b1679604b358a16b05f16a67eb8ce7a Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 27 Sep 2018 16:14:01 +0200 Subject: [PATCH 1/2] Use a clean env to spawn gitaly-ruby during tests Locally my tests failed, as the enviroment for the spawned Gitaly-Ruby didnt match the environment required. This showed as bundler wasnt available in that enviroment. --- ruby/spec/integration_helper.rb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ruby/spec/integration_helper.rb b/ruby/spec/integration_helper.rb index 57e22b9b63c..37f4c266c6a 100644 --- a/ruby/spec/integration_helper.rb +++ b/ruby/spec/integration_helper.rb @@ -4,6 +4,7 @@ require 'gitaly' require 'spec_helper' SOCKET_PATH = 'gitaly.socket'.freeze +RUBY_PATH = File.expand_path('../', __FILE__) TMP_DIR = File.expand_path('../../tmp', __FILE__) module IntegrationClient @@ -17,6 +18,16 @@ module IntegrationClient end end +def env + env_hash = { + 'BUNDLE_FLAGS' => "--jobs=4 --retry=3", + 'BUNDLE_INSTALL_FLAGS' => nil, + 'RUBYOPT' => nil + } + env_hash['BUNDLE_APP_CONFIG'] = File.join(RUBY_PATH, '.bundle/config') unless ENV['CI'] + env_hash +end + def start_gitaly build_dir = File.expand_path('../../../_build', __FILE__) gitlab_shell_dir = File.join(TMP_DIR, 'gitlab-shell') @@ -26,13 +37,13 @@ def start_gitaly config_toml = <<~CONFIG socket_path = "#{SOCKET_PATH}" bin_dir = "#{build_dir}/bin" - + [gitlab-shell] dir = "#{gitlab_shell_dir}" - + [gitaly-ruby] dir = "#{build_dir}/assembly/ruby" - + [[storage]] name = "#{DEFAULT_STORAGE_NAME}" path = "#{DEFAULT_STORAGE_DIR}" @@ -42,7 +53,9 @@ def start_gitaly test_log = File.join(TMP_DIR, 'gitaly-rspec-test.log') options = { out: test_log, err: test_log, chdir: TMP_DIR } - gitaly_pid = spawn(File.join(build_dir, 'bin/gitaly'), config_path, options) + + gitaly_pid = spawn(env, File.join(build_dir, 'bin/gitaly'), config_path, options) + at_exit { Process.kill('KILL', gitaly_pid) } wait_ready!(File.join('tmp', SOCKET_PATH)) end -- GitLab From 1c3ea8d42a086eeb702c4028859deecef66f63d2 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 27 Sep 2018 16:35:52 +0200 Subject: [PATCH 2/2] Store rspec logs on test failures When Ruby tests fail on CI, but not locally, the logs are useful to get clues for debugging. With these additions the logs will be exported for a week after failure. --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef28688f919..941a78ad272 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,6 +67,11 @@ danger-review: paths: - ruby/vendor/bundle policy: pull + artifacts: + paths: + - ruby/tmp/gitaly-rspec-test.log + when: on_failure + expire_in: 1 week .test_template: &test_definition <<: *go_test_definition -- GitLab