Commit 8540ffeb authored by Rémy Coutable's avatar Rémy Coutable

ci: Only keep relevant files after installing tests dependencies

The _build dir is 211MB (uncompressed) but the executables are moved to
the top gitaly folder after they're compiled, so there's no need to save
the _build dir in the artifacts of the setup-test-env job.

That should speed up the artifacts upload/download phases for
setup-test-env and all the jobs that depend on it.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 7476967e
......@@ -15,7 +15,6 @@
# SEED_NESTED_GROUPS: "false" # requires network connection
.run-dev-fixtures-script: &run-dev-fixtures-script
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- run_timed_command "RAILS_ENV=test bundle exec rake db:seed_fu"
......
......@@ -103,7 +103,6 @@ update-yarn-cache:
WEBPACK_VENDOR_DLL: "true"
script:
- run_timed_command "gem install knapsack --no-document"
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source ./scripts/rspec_helpers.sh
- rspec_paralellized_job "--tag frontend_fixture"
......
......@@ -10,7 +10,6 @@
# Only install knapsack after bundle install! Otherwise oddly some native
# gems could not be found under some circumstance. No idea why, hours wasted.
- run_timed_command "gem install knapsack --no-document"
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source ./scripts/rspec_helpers.sh
......@@ -150,20 +149,35 @@ setup-test-env:
script:
- run_timed_command "bundle exec ruby -I. -e 'require \"config/environment\"; TestEnv.init'"
- run_timed_command "scripts/gitaly-test-build" # Do not use 'bundle exec' here
- rm tmp/tests/gitaly/.ruby-bundle # This file prevents gems from being installed even if vendor/gitaly-ruby is missing
artifacts:
expire_in: 7d
paths:
- config/secrets.yml
- tmp/tests/gitaly
- tmp/tests/gitlab-elasticsearch-indexer
- tmp/tests/gitlab-shell
- tmp/tests/gitlab-test-fork
- tmp/tests/gitlab-test-fork_bare
- tmp/tests/gitlab-test
- tmp/tests/gitlab-workhorse
- tmp/tests/repositories
- tmp/tests/second_storage
- tmp/tests/gitaly/config.toml
- tmp/tests/gitaly/gitaly
- tmp/tests/gitaly/gitaly2.config.toml
- tmp/tests/gitaly/gitaly-git2go
- tmp/tests/gitaly/gitaly-hooks
- tmp/tests/gitaly/gitaly-lfs-smudge
- tmp/tests/gitaly/gitaly-ssh
- tmp/tests/gitaly/internal/
- tmp/tests/gitaly/internal_sockets/
- tmp/tests/gitaly/Makefile
- tmp/tests/gitaly/praefect
- tmp/tests/gitaly/praefect.config.toml
- tmp/tests/gitaly/ruby/
- tmp/tests/gitlab-elasticsearch-indexer/bin/gitlab-elasticsearch-indexer
- tmp/tests/gitlab-shell/
- tmp/tests/gitlab-test-fork/
- tmp/tests/gitlab-test-fork_bare/
- tmp/tests/gitlab-test/
- tmp/tests/gitlab-workhorse/gitlab-zip-metadata
- tmp/tests/gitlab-workhorse/gitlab-zip-cat
- tmp/tests/gitlab-workhorse/gitlab-workhorse
- tmp/tests/gitlab-workhorse/gitlab-resize-image
- tmp/tests/gitlab-workhorse/config.toml
- tmp/tests/repositories/
- tmp/tests/second_storage/
when: always
update-rails-cache:
......
......@@ -504,6 +504,10 @@ request, be sure to start the `dont-interrupt-me` job before pushing.
- `update-yarn-cache`, defined in [`.gitlab/ci/frontend.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/ci/frontend.gitlab-ci.yml).
1. These jobs run in merge requests whose title include `UPDATE CACHE`.
### Artifacts strategy
We limit the artifacts that are saved and retrieved by jobs to the minimum in order to reduce the upload/download time and costs, as well as the artifacts storage.
### Pre-clone step
The `gitlab-org/gitlab` project on GitLab.com uses a [pre-clone step](https://gitlab.com/gitlab-org/gitlab/-/issues/39134)
......
......@@ -12,7 +12,7 @@ class GitalyTestBuild
include GitalyTest
def run
abort 'gitaly build failed' unless system(env, 'make', chdir: tmp_tests_gitaly_dir)
abort 'gitaly build failed' unless build_gitaly
ensure_gitlab_shell_secret!
check_gitaly_config!
......
......@@ -8,6 +8,7 @@ class GitalyTestSpawn
include GitalyTest
def run
install_gitaly_gems if ENV['CI']
check_gitaly_config!
# # Uncomment line below to see all gitaly logs merged into CI trace
......
......@@ -41,7 +41,7 @@ module GitalyTest
'HOME' => File.expand_path('tmp/tests'),
'GEM_PATH' => Gem.path.join(':'),
'BUNDLE_APP_CONFIG' => File.join(File.dirname(gemfile), '.bundle/config'),
'BUNDLE_FLAGS' => "--jobs=4 --retry=3 --quiet",
'BUNDLE_FLAGS' => "--jobs=4 --retry=3",
'BUNDLE_INSTALL_FLAGS' => nil,
'BUNDLE_GEMFILE' => gemfile,
'RUBYOPT' => nil,
......@@ -78,6 +78,14 @@ module GitalyTest
end
end
def install_gitaly_gems
system(env, "make #{tmp_tests_gitaly_dir}/.ruby-bundle", chdir: tmp_tests_gitaly_dir) # rubocop:disable GitlabSecurity/SystemCommandInjection
end
def build_gitaly
system(env, 'make', chdir: tmp_tests_gitaly_dir) # rubocop:disable GitlabSecurity/SystemCommandInjection
end
def start_gitaly
start(:gitaly)
end
......
......@@ -33,7 +33,7 @@ Capybara.register_server :puma_via_workhorse do |app, port, host, **options|
socket_path = file.path
file.close! # We just want the filename
TestEnv.with_workhorse(TestEnv.workhorse_dir, host, port, socket_path) do
TestEnv.with_workhorse(host, port, socket_path) do
Capybara.servers[:puma].call(app, nil, socket_path, **options)
end
end
......
......@@ -284,7 +284,7 @@ module TestEnv
@workhorse_path ||= File.join('tmp', 'tests', 'gitlab-workhorse')
end
def with_workhorse(workhorse_dir, host, port, upstream, &blk)
def with_workhorse(host, port, upstream, &blk)
host = "[#{host}]" if host.include?(':')
listen_addr = [host, port].join(':')
......
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