Commit 745619b6 authored by Rémy Coutable's avatar Rémy Coutable 🏔 Committed by Robert Speicher

Properly enable rspec_profiling for PG jobs only on the CI

Signed-off-by: Rémy Coutable's avatarRémy Coutable <remy@rymai.me>
parent f9e833c4
Pipeline #7972228 passed with stages
in 100 minutes and 7 seconds
...@@ -22,8 +22,8 @@ variables: ...@@ -22,8 +22,8 @@ variables:
before_script: before_script:
- bundle --version - bundle --version
- . scripts/utils.sh - source scripts/utils.sh
- ./scripts/prepare_build.sh - source scripts/prepare_build.sh
stages: stages:
- prepare - prepare
......
...@@ -36,10 +36,10 @@ if Rails.env.test? ...@@ -36,10 +36,10 @@ if Rails.env.test?
RspecProfiling::Collectors::PSQL.prepend(RspecProfilingExt::PSQL) RspecProfiling::Collectors::PSQL.prepend(RspecProfilingExt::PSQL)
config.collector = RspecProfiling::Collectors::PSQL config.collector = RspecProfiling::Collectors::PSQL
end end
end
if ENV.has_key?('CI') && ENV['GITLAB_DATABASE'] == 'postgresql' if ENV.key?('CI')
RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git) RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git)
RspecProfiling::Run.prepend(RspecProfilingExt::Run) RspecProfiling::Run.prepend(RspecProfilingExt::Run)
end
end end
end end
#!/bin/sh
. scripts/utils.sh . scripts/utils.sh
export SETUP_DB=${SETUP_DB:-true} export SETUP_DB=${SETUP_DB:-true}
...@@ -44,7 +42,7 @@ sed -i 's/localhost/redis/g' config/resque.yml ...@@ -44,7 +42,7 @@ sed -i 's/localhost/redis/g' config/resque.yml
cp config/gitlab.yml.example config/gitlab.yml cp config/gitlab.yml.example config/gitlab.yml
if [ "$USE_BUNDLE_INSTALL" != "false" ]; then if [ "$USE_BUNDLE_INSTALL" != "false" ]; then
retry bundle install --clean $BUNDLE_INSTALL_FLAGS bundle install --clean $BUNDLE_INSTALL_FLAGS && bundle check
fi fi
# Only install knapsack after bundle install! Otherwise oddly some native # Only install knapsack after bundle install! Otherwise oddly some native
......
...@@ -13,8 +13,9 @@ rspec_profiling_is_configured = ...@@ -13,8 +13,9 @@ rspec_profiling_is_configured =
ENV['RSPEC_PROFILING_POSTGRES_URL'] || ENV['RSPEC_PROFILING_POSTGRES_URL'] ||
ENV['RSPEC_PROFILING'] ENV['RSPEC_PROFILING']
branch_can_be_profiled = branch_can_be_profiled =
ENV['CI_COMMIT_REF_NAME'] == 'master' || ENV['GITLAB_DATABASE'] == 'postgresql' &&
ENV['CI_COMMIT_REF_NAME'] =~ /rspec-profile/ (ENV['CI_COMMIT_REF_NAME'] == 'master' ||
ENV['CI_COMMIT_REF_NAME'] =~ /rspec-profile/)
if rspec_profiling_is_configured && (!ENV.key?('CI') || branch_can_be_profiled) if rspec_profiling_is_configured && (!ENV.key?('CI') || branch_can_be_profiled)
require 'rspec_profiling/rspec' require 'rspec_profiling/rspec'
......
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