Commit 18a4cf0e authored by Rémy Coutable's avatar Rémy Coutable

Ensure Gitaly is installed properly even when cache is stale

Before, we'd pass `vendor/gitaly-ruby` as artifacts to other jobs in the
pipeline but now that it's saved in cache, it can happen that the cache
doesn't have the exact versions needed by the job since its key is
fixed (i.e. currently "ruby-go-cache-v1").

This commit make sure that Gitaly dependencies are installed (with
`scripts/gitaly-test-build`) in the jobs that call
`scripts/gitaly-test-spawn`. It also makes the cache key dependent on
the `GITALY_SERVER_VERSION` file so that each time this file changes,
the cache key will change as well.

Note that we need to remove the `tmp/tests/gitaly/.ruby-bundle` file in
the `setup-test-env` job since this file prevents gems from being
installed even if `vendor/gitaly-ruby` doesn't have the correct gems.

Also, extend from `.rails-cache` in `frontend-fixtures`.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent f41c5b4f
.run-dev-fixtures: .run-dev-fixtures:
extends: extends:
- .default-retry - .default-retry
- .default-cache - .rails-cache
- .default-before_script - .default-before_script
- .use-pg11 - .use-pg11
stage: test stage: test
...@@ -19,8 +19,9 @@ run-dev-fixtures: ...@@ -19,8 +19,9 @@ run-dev-fixtures:
- .run-dev-fixtures - .run-dev-fixtures
- .dev-fixtures:rules:ee-and-foss - .dev-fixtures:rules:ee-and-foss
script: script:
- scripts/gitaly-test-spawn - run_timed_command "scripts/gitaly-test-build"
- RAILS_ENV=test bundle exec rake db:seed_fu - run_timed_command "scripts/gitaly-test-spawn"
- run_timed_command "RAILS_ENV=test bundle exec rake db:seed_fu"
run-dev-fixtures-ee: run-dev-fixtures-ee:
extends: extends:
...@@ -28,6 +29,7 @@ run-dev-fixtures-ee: ...@@ -28,6 +29,7 @@ run-dev-fixtures-ee:
- .dev-fixtures:rules:ee-only - .dev-fixtures:rules:ee-only
- .use-pg11-ee - .use-pg11-ee
script: script:
- scripts/gitaly-test-spawn - run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- cp ee/db/fixtures/development/* $FIXTURE_PATH - cp ee/db/fixtures/development/* $FIXTURE_PATH
- RAILS_ENV=test bundle exec rake db:seed_fu - run_timed_command "RAILS_ENV=test bundle exec rake db:seed_fu"
...@@ -136,16 +136,15 @@ compile-assets pull-cache as-if-foss: ...@@ -136,16 +136,15 @@ compile-assets pull-cache as-if-foss:
.frontend-fixtures-base: .frontend-fixtures-base:
extends: extends:
- .default-retry - .default-retry
- .default-cache - .rails-cache
- .default-before_script - .default-before_script
- .use-pg11 - .use-pg11
stage: fixtures stage: fixtures
needs: ["setup-test-env", "compile-assets pull-cache"] needs: ["setup-test-env", "compile-assets pull-cache"]
script: script:
- date - run_timed_command "scripts/gitaly-test-build"
- scripts/gitaly-test-spawn - run_timed_command "scripts/gitaly-test-spawn"
- date - run_timed_command "bundle exec rake frontend:fixtures"
- bundle exec rake frontend:fixtures
artifacts: artifacts:
name: frontend-fixtures name: frontend-fixtures
expire_in: 31d expire_in: 31d
......
...@@ -29,6 +29,19 @@ ...@@ -29,6 +29,19 @@
- vendor/gitaly-ruby - vendor/gitaly-ruby
policy: pull policy: pull
.rails-cache:
cache:
key:
files:
- Gemfile.lock
- GITALY_SERVER_VERSION
prefix: "ruby-go-cache-v1"
paths:
- vendor/ruby
- vendor/gitaly-ruby
- .go/pkg/mod
policy: pull
.yarn-cache: .yarn-cache:
cache: cache:
key: key:
......
.rails:needs:setup-and-assets: .rails:needs:setup-and-assets:
needs: ["setup-test-env", "compile-assets pull-cache"] needs: ["setup-test-env", "compile-assets pull-cache"]
.rails-cache:
cache:
key: "ruby-go-cache-v1"
paths:
- vendor/ruby
- vendor/gitaly-ruby
- .go/pkg/mod
policy: pull
.rails-job-base: .rails-job-base:
extends: extends:
- .default-retry - .default-retry
...@@ -18,15 +9,18 @@ ...@@ -18,15 +9,18 @@
####################################################### #######################################################
# EE/FOSS: default refs (MRs, master, schedules) jobs # # EE/FOSS: default refs (MRs, master, schedules) jobs #
.base-setup-test-env: setup-test-env:
extends: extends:
- .rails-job-base - .rails-job-base
- .rails:rules:default-refs-code-backstage-qa
- .use-pg11
stage: prepare stage: prepare
variables: variables:
GITLAB_TEST_EAGER_LOAD: "0" GITLAB_TEST_EAGER_LOAD: "0"
script: script:
- run_timed_command "bundle exec ruby -I. -e 'require \"config/environment\"; TestEnv.init'" - 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 - 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: artifacts:
expire_in: 7d expire_in: 7d
paths: paths:
...@@ -44,12 +38,6 @@ ...@@ -44,12 +38,6 @@
cache: cache:
policy: pull-push policy: pull-push
setup-test-env:
extends:
- .base-setup-test-env
- .rails:rules:default-refs-code-backstage-qa
- .use-pg11
static-analysis: static-analysis:
extends: extends:
- .rails-job-base - .rails-job-base
...@@ -84,6 +72,8 @@ downtime_check: ...@@ -84,6 +72,8 @@ downtime_check:
stage: test stage: test
needs: ["setup-test-env", "retrieve-tests-metadata", "compile-assets pull-cache"] needs: ["setup-test-env", "retrieve-tests-metadata", "compile-assets pull-cache"]
script: script:
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh - source scripts/rspec_helpers.sh
- rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag ~level:migration" - rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag ~level:migration"
artifacts: artifacts:
...@@ -108,6 +98,8 @@ downtime_check: ...@@ -108,6 +98,8 @@ downtime_check:
.rspec-base-migration: .rspec-base-migration:
script: script:
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh - source scripts/rspec_helpers.sh
- rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag level:migration" - rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag level:migration"
...@@ -193,6 +185,7 @@ gitlab:setup: ...@@ -193,6 +185,7 @@ gitlab:setup:
# db/fixtures/development/04_project.rb thanks to SIZE=1 below # db/fixtures/development/04_project.rb thanks to SIZE=1 below
- git clone https://gitlab.com/gitlab-org/gitlab-test.git - git clone https://gitlab.com/gitlab-org/gitlab-test.git
/home/git/repositories/gitlab-org/gitlab-test.git /home/git/repositories/gitlab-org/gitlab-test.git
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn" - run_timed_command "scripts/gitaly-test-spawn"
- force=yes SIZE=1 FIXTURE_PATH="db/fixtures/development" bundle exec rake gitlab:setup - force=yes SIZE=1 FIXTURE_PATH="db/fixtures/development" bundle exec rake gitlab:setup
artifacts: artifacts:
...@@ -300,6 +293,8 @@ rspec-ee system pg11: ...@@ -300,6 +293,8 @@ rspec-ee system pg11:
.rspec-ee-base-geo: .rspec-ee-base-geo:
extends: .rspec-base-ee extends: .rspec-base-ee
script: script:
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh - source scripts/rspec_helpers.sh
- scripts/prepare_postgres_fdw.sh - scripts/prepare_postgres_fdw.sh
- rspec_paralellized_job "--tag ~quarantine --tag geo" - rspec_paralellized_job "--tag ~quarantine --tag geo"
......
...@@ -53,8 +53,6 @@ function rspec_simple_job() { ...@@ -53,8 +53,6 @@ function rspec_simple_job() {
export NO_KNAPSACK="1" export NO_KNAPSACK="1"
scripts/gitaly-test-spawn
bin/rspec --color --format documentation --format RspecJunitFormatter --out junit_rspec.xml ${rspec_opts} bin/rspec --color --format documentation --format RspecJunitFormatter --out junit_rspec.xml ${rspec_opts}
} }
...@@ -104,8 +102,6 @@ function rspec_paralellized_job() { ...@@ -104,8 +102,6 @@ function rspec_paralellized_job() {
fi fi
fi fi
scripts/gitaly-test-spawn
mkdir -p tmp/memory_test mkdir -p tmp/memory_test
export MEMORY_TEST_PATH="tmp/memory_test/${report_name}_memory.csv" export MEMORY_TEST_PATH="tmp/memory_test/${report_name}_memory.csv"
......
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