Commit 36c66c41 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'refactor-duplicated-bundle-install-in-ci-config' into 'master'

ci: Refactor duplicated 'bundle install' in CI config

See merge request gitlab-org/gitlab!61119
parents 21d95abd 90bc1696
......@@ -53,6 +53,8 @@ workflow:
variables:
RAILS_ENV: "test"
NODE_ENV: "test"
BUNDLE_WITHOUT: "production:development"
BUNDLE_INSTALL_FLAGS: "--jobs=$(nproc) --retry=3 --quiet"
# we override the max_old_space_size to prevent OOM errors
NODE_OPTIONS: --max_old_space_size=3584
SIMPLECOV: "true"
......
......@@ -4,11 +4,13 @@
- .qa-cache
stage: test
needs: []
variables:
USE_BUNDLE_INSTALL: "false"
SETUP_DB: "false"
before_script:
- '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/ qa/spec/ee/ qa/qa/specs/features/ee/ qa/qa/ee/ qa/qa/ee.rb'
- !reference [.default-before_script, before_script]
- cd qa/
- bundle install --clean --jobs=$(nproc) --path=vendor --retry=3 --without=development --quiet
- bundle check
- bundle_install_script
qa:internal:
extends:
......
......@@ -8,7 +8,8 @@
.minimal-bundle-install:
script:
- run_timed_command "bundle install --jobs=$(nproc) --path=vendor --retry=3 --quiet --without default development test production puma unicorn kerberos metrics omnibus ed25519"
- export BUNDLE_WITHOUT="${BUNDLE_WITHOUT}:default:test:puma:unicorn:kerberos:metrics:omnibus:ed25519"
- bundle_install_script
.base-script:
script:
......
......@@ -218,8 +218,8 @@ danger-review:
stage: test
needs: []
before_script:
- source ./scripts/utils.sh
- run_timed_command "bundle install --jobs=$(nproc) --path=vendor --retry=3 --quiet --with danger"
- source scripts/utils.sh
- bundle_install_script "--with danger"
- run_timed_command "retry yarn install --frozen-lockfile"
script:
- >
......
......@@ -2,17 +2,9 @@
export SETUP_DB=${SETUP_DB:-true}
export USE_BUNDLE_INSTALL=${USE_BUNDLE_INSTALL:-true}
export BUNDLE_INSTALL_FLAGS=${BUNDLE_INSTALL_FLAGS:-"--without=production development --jobs=$(nproc) --path=vendor --retry=3 --quiet"}
if [ "$USE_BUNDLE_INSTALL" != "false" ]; then
bundle --version
bundle config set clean 'true'
run_timed_command "bundle install ${BUNDLE_INSTALL_FLAGS}"
run_timed_command "bundle check"
# When we test multiple versions of PG in the same pipeline, we have a single `setup-test-env`
# job but the `pg` gem needs to be rebuilt since it includes extensions (https://guides.rubygems.org/gems-with-extensions).
# Uncomment the following line if multiple versions of PG are tested in the same pipeline.
run_timed_command "bundle pristine pg"
bundle_install_script
fi
cp config/gitlab.yml.example config/gitlab.yml
......
......@@ -13,6 +13,32 @@ function retry() {
return 1
}
function bundle_install_script() {
local extra_install_args="${1}"
if [[ "${extra_install_args}" =~ "--without" ]]; then
echoerr "The '--without' flag shouldn't be passed as it would replace the default \${BUNDLE_WITHOUT} (currently set to '${BUNDLE_WITHOUT}')."
echoerr "Set the 'BUNDLE_WITHOUT' variable instead, e.g. '- export BUNDLE_WITHOUT=\"\${BUNDLE_WITHOUT}:any:other:group:not:to:install\"'."
exit 1;
fi;
bundle --version
bundle config set path 'vendor'
bundle config set clean 'true'
echo $BUNDLE_WITHOUT
bundle config
run_timed_command "bundle install ${BUNDLE_INSTALL_FLAGS} ${extra_install_args} && bundle check"
if [[ $(bundle info pg) ]]; then
# When we test multiple versions of PG in the same pipeline, we have a single `setup-test-env`
# job but the `pg` gem needs to be rebuilt since it includes extensions (https://guides.rubygems.org/gems-with-extensions).
# Uncomment the following line if multiple versions of PG are tested in the same pipeline.
run_timed_command "bundle pristine pg"
fi
}
function setup_db_user_only() {
source scripts/create_postgres_user.sh
}
......
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