Skip to content
代码片段 群组 项目
提交 adef05b1 编辑于 作者: Kev Kloss's avatar Kev Kloss
浏览文件

Cache database once per pipeline

上级 18beef57
No related branches found
No related tags found
无相关合并请求
include: include:
- local: .gitlab/ci/rails/shared.gitlab-ci.yml - local: .gitlab/ci/rails/shared.gitlab-ci.yml
db:setup pg14:
stage: prepare
needs: []
extends:
- .use-pg14
- .default-before_script
- .ruby-cache
- .rails:rules:setup-test-env
script:
- source scripts/utils.sh
- run_timed_command "pg_dumpall -h postgres -U postgres > pg_dumpall.sql"
artifacts:
paths:
- pg_dumpall.sql
db:rollback single-db-ci-connection: db:rollback single-db-ci-connection:
extends: extends:
- db:rollback - db:rollback
......
...@@ -210,6 +210,10 @@ include: ...@@ -210,6 +210,10 @@ include:
- !reference [.rspec-base, after_script] - !reference [.rspec-base, after_script]
.rspec-base-pg14: .rspec-base-pg14:
needs:
- !reference [.rspec-base, needs]
- job: "db:setup pg14"
optional: true
extends: extends:
- .rspec-base - .rspec-base
- .use-pg14 - .use-pg14
......
...@@ -198,6 +198,21 @@ function setup_db_praefect() { ...@@ -198,6 +198,21 @@ function setup_db_praefect() {
function setup_db() { function setup_db() {
section_start "setup-db" "Setting up DBs" section_start "setup-db" "Setting up DBs"
if [[ -f pg_dumpall.sql ]] && ! [[ "$DECOMPOSED_DB" =~ "false" ]]; then
echo "Found pg_dumpall.sql, applying!"
psql -h postgres -U postgres -q < pg_dumpall.sql > /dev/null
rm pg_dumpall.sql
section_end "setup-db"
return 0
fi
if [[ -f pg_dumpall.sql ]]; then
echo "Found pg_dumpall.sql but we're not using a standard multi-db (decomposed) setup. Performing a regular db setup instead."
rm pg_dumpall.sql
fi
setup_db_user_only setup_db_user_only
run_timed_command_with_metric "bundle exec rake db:drop db:create db:schema:load db:migrate gitlab:db:lock_writes" "setup_db" run_timed_command_with_metric "bundle exec rake db:drop db:create db:schema:load db:migrate gitlab:db:lock_writes" "setup_db"
setup_db_praefect setup_db_praefect
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册