Use GITLAB_DATABASE: $CI_JOB_NAME[1] so that we

reduce variables definitions. Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10156#note_26811996
This commit is contained in:
Lin Jen-Shin 2017-04-10 19:09:02 +08:00
parent a9945a6500
commit f1e2387e28
2 changed files with 21 additions and 29 deletions

View File

@ -7,6 +7,7 @@ cache:
variables:
MYSQL_ALLOW_EMPTY_PASSWORD: "1"
GITLAB_DATABASE: $CI_JOB_NAME[1]
RAILS_ENV: "test"
NODE_ENV: "test"
SIMPLECOV: "true"
@ -51,15 +52,11 @@ stages:
services:
- postgres:latest
- redis:alpine
variables:
GITLAB_DATABASE: "postgresql"
.use-mysql: &use-mysql
services:
- mysql:latest
- redis:alpine
variables:
GITLAB_DATABASE: "mysql"
.only-master-and-ee-or-mysql: &only-master-and-ee-or-mysql
only:
@ -288,11 +285,11 @@ rake ee_compat_check:
script:
- bundle exec rake db:migrate:reset
pg rake db:migrate:reset:
rake pg db:migrate:reset:
<<: *db-migrate-reset
<<: *use-pg
mysql rake db:migrate:reset:
rake mysql db:migrate:reset:
<<: *db-migrate-reset
<<: *use-mysql
@ -303,19 +300,14 @@ mysql rake db:migrate:reset:
- bundle exec rake db:rollback STEP=120
- bundle exec rake db:migrate
pg rake db:rollback:
rake pg db:rollback:
<<: *db-rollback
<<: *use-pg
mysql rake db:rollback:
rake mysql db:rollback:
<<: *db-rollback
<<: *use-mysql
.db-seed_fu-variables: &db-seed_fu-variables
SIZE: "1"
SETUP_DB: "false"
RAILS_ENV: "development"
.db-seed_fu: &db-seed_fu
stage: test
<<: *dedicated-runner
@ -323,25 +315,24 @@ mysql rake db:rollback:
- git clone https://gitlab.com/gitlab-org/gitlab-test.git
/home/git/repositories/gitlab-org/gitlab-test.git
- bundle exec rake db:setup db:seed_fu
variables:
GITLAB_DATABASE: $CI_JOB_NAME[1]
SIZE: "1"
SETUP_DB: "false"
RAILS_ENV: "development"
artifacts:
when: on_failure
expire_in: 1d
paths:
- log/development.log
pg rake db:seed_fu:
rake pg db:seed_fu:
<<: *db-seed_fu
<<: *use-pg
variables:
<<: *db-seed_fu-variables
GITLAB_DATABASE: "postgresql"
mysql rake db:seed_fu:
rake mysql db:seed_fu:
<<: *db-seed_fu
<<: *use-mysql
variables:
<<: *db-seed_fu-variables
GITLAB_DATABASE: "mysql"
rake gitlab:assets:compile:
stage: test
@ -444,20 +435,17 @@ bundler:audit:
- bundle install --without production --jobs $(nproc) $FLAGS --retry=3
- source scripts/prepare_build.sh
- bundle exec rake db:migrate
variables:
GITLAB_DATABASE: $CI_JOB_NAME[1]
SETUP_DB: "false"
pg migration paths:
migration pg paths:
<<: *migration-paths
<<: *use-pg
variables:
SETUP_DB: "false"
GITLAB_DATABASE: "postgresql"
mysql migration paths:
migration mysql paths:
<<: *migration-paths
<<: *use-mysql
variables:
SETUP_DB: "false"
GITLAB_DATABASE: "mysql"
coverage:
stage: post-test

View File

@ -6,6 +6,10 @@ export SETUP_DB=${SETUP_DB:-true}
export GITLAB_DATABASE=${GITLAB_DATABASE:-postgresql}
export USE_BUNDLE_INSTALL=${USE_BUNDLE_INSTALL:-true}
if [ "$GITLAB_DATABASE" = 'pg' ]; then
export GITLAB_DATABASE='postgresql'
fi
if [ -f /.dockerenv ] || [ -f ./dockerinit ]; then
cp config/database.yml.$GITLAB_DATABASE config/database.yml