diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-04-10 14:09:02 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-04-10 14:15:42 +0300 |
commit | f1e2387e2851009cf2091ab22b3d6a70a27dfa1e (patch) | |
tree | 7eaa26a95ce9c7e1a4b52bcc2da3ad4098e0b93d | |
parent | a9945a6500351331426226efe80631f81cb832aa (diff) |
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
-rw-r--r-- | .gitlab-ci.yml | 46 | ||||
-rwxr-xr-x | scripts/prepare_build.sh | 4 |
2 files changed, 21 insertions, 29 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a900825b3de..ee590e1d604 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index b8d8cc2851a..2b041892eab 100755 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -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 |