diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-05-23 02:10:29 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-05-23 02:10:29 +0800 |
commit | 1a4130d3a6cfb4956f8bb1186cc499ea549d8e18 (patch) | |
tree | 076adcb3e6f3800a1a7bbc6809839d5cb3b3f372 /scripts/prepare_build.sh | |
parent | 3c8a6fba67998eb17240b15db85f8d1c8aff338e (diff) | |
parent | 18a6d9c5326bc2b90a1f0cc8664d638a39885924 (diff) | |
download | gitlab-ce-1a4130d3a6cfb4956f8bb1186cc499ea549d8e18.tar.gz |
Merge remote-tracking branch 'upstream/master' into 27377-preload-pipeline-entity27377-preload-pipeline-entity
* upstream/master: (2534 commits)
Update VERSION to 9.3.0-pre
Update CHANGELOG.md for 9.2.0
removes unnecessary redundacy in usage ping doc
Respect the typo as rubocop said
Add a test to ensure this works on MySQL
Change pipelines schedules help page path
change domain to hostname in usage ping doc
Fixes broken MySQL migration for retried
Show password field mask while editing service settings
Add notes for supported schedulers and cloud providers
Move environment monitoring to environments doc
Add docs for change of Cache/Artifact restore order"
Avoid resource intensive login checks if password is not provided
Change translation for 'coding' by 'desarrollo' for Spanish
Add to docs: issues multiple assignees
rename "Add emoji" and "Award emoji" to "Add reaction" where appropriate
Add project and group notification settings info
32570 Fix border-bottom for project activity tab
Add users endpoint to frontend API class
Rename users on mysql
...
Diffstat (limited to 'scripts/prepare_build.sh')
-rw-r--r--[-rwxr-xr-x] | scripts/prepare_build.sh | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index 6e3f76b8399..03de59f27ad 100755..100644 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -1,35 +1,46 @@ -#!/bin/sh +. scripts/utils.sh -retry() { - if eval "$@"; then - return 0 - fi +export SETUP_DB=${SETUP_DB:-true} +export USE_BUNDLE_INSTALL=${USE_BUNDLE_INSTALL:-true} +export BUNDLE_INSTALL_FLAGS="--without production --jobs $(nproc) --path vendor --retry 3 --quiet" + +if [ "$USE_BUNDLE_INSTALL" != "false" ]; then + bundle install --clean $BUNDLE_INSTALL_FLAGS && bundle check +fi + +# Only install knapsack after bundle install! Otherwise oddly some native +# gems could not be found under some circumstance. No idea why, hours wasted. +retry gem install knapsack fog-aws mime-types + +cp config/resque.yml.example config/resque.yml +sed -i 's/localhost/redis/g' config/resque.yml + +cp config/gitlab.yml.example config/gitlab.yml + +# Determine the database by looking at the job name. +# For example, we'll get pg if the job is `rspec-pg 19 20` +export GITLAB_DATABASE=$(echo $CI_JOB_NAME | cut -f1 -d' ' | cut -f2 -d-) - for i in 2 1; do - sleep 3s - echo "Retrying $i..." - if eval "$@"; then - return 0 - fi - done - return 1 -} - -if [ -f /.dockerenv ] || [ -f ./dockerinit ]; then - cp config/database.yml.mysql config/database.yml +# This would make the default database postgresql, and we could also use +# pg to mean postgresql. +if [ "$GITLAB_DATABASE" != 'mysql' ]; then + export GITLAB_DATABASE='postgresql' +fi + +cp config/database.yml.$GITLAB_DATABASE config/database.yml + +if [ "$GITLAB_DATABASE" = 'postgresql' ]; then + sed -i 's/# host:.*/host: postgres/g' config/database.yml +else # Assume it's mysql sed -i 's/username:.*/username: root/g' config/database.yml sed -i 's/password:.*/password:/g' config/database.yml - sed -i 's/# socket:.*/host: mysql/g' config/database.yml - - cp config/resque.yml.example config/resque.yml - sed -i 's/localhost/redis/g' config/resque.yml - - export FLAGS="--path vendor --retry 3 --quiet" -else - rnd=$(awk 'BEGIN { srand() ; printf("%d\n",rand()*5) }') - export PATH="$HOME/bin:/usr/local/bin:/usr/bin:/bin" - cp config/database.yml.mysql config/database.yml - sed "s/username\:.*$/username\: runner/" -i config/database.yml - sed "s/password\:.*$/password\: 'password'/" -i config/database.yml - sed "s/gitlabhq_test/gitlabhq_test_$rnd/" -i config/database.yml + sed -i 's/# host:.*/host: mysql/g' config/database.yml +fi + +if [ "$SETUP_DB" != "false" ]; then + bundle exec rake db:drop db:create db:schema:load db:migrate + + if [ "$GITLAB_DATABASE" = "mysql" ]; then + bundle exec rake add_limits_mysql + fi fi |