Commit 7a85e798 authored by Rémy Coutable's avatar Rémy Coutable

ci: Change the way we skip env loading in some rake tasks

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 04d3dac0
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace :gitlab do namespace :gitlab do
namespace :indexer do namespace :indexer do
desc "GitLab | Indexer | Install or upgrade gitlab-elasticsearch-indexer" desc "GitLab | Indexer | Install or upgrade gitlab-elasticsearch-indexer"
task :install, [:dir, :repo] => :with_gitlab_helpers do |t, args| task :install, [:dir, :repo] => :gitlab_environment do |t, args|
unless args.dir.present? unless args.dir.present?
abort %(Please specify the directory where you want to install the indexer abort %(Please specify the directory where you want to install the indexer
Usage: rake "gitlab:indexer:install[/installation/dir,repo]") Usage: rake "gitlab:indexer:install[/installation/dir,repo]")
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace :gitlab do namespace :gitlab do
namespace :gitaly do namespace :gitaly do
desc 'GitLab | Gitaly | Install or upgrade gitaly' desc 'GitLab | Gitaly | Install or upgrade gitaly'
task :install, [:dir, :storage_path, :repo] => :with_gitlab_helpers do |t, args| task :install, [:dir, :storage_path, :repo] => :gitlab_environment do |t, args|
warn_user_is_not_gitlab warn_user_is_not_gitlab
unless args.dir.present? && args.storage_path.present? unless args.dir.present? && args.storage_path.present?
......
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
# Prevent StateMachine warnings from outputting during a cron task # Prevent StateMachine warnings from outputting during a cron task
StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON'] StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON']
task gitlab_environment: :environment do task :gitlab_environment do
extend SystemCheck::Helpers Rake::Task[:environment].invoke unless ENV['SKIP_RAILS_ENV_IN_RAKE']
end
task :with_gitlab_helpers do
extend SystemCheck::Helpers extend SystemCheck::Helpers
end end
...@@ -11,6 +11,8 @@ require 'active_support/dependencies/autoload' ...@@ -11,6 +11,8 @@ require 'active_support/dependencies/autoload'
require 'active_support/core_ext/numeric' require 'active_support/core_ext/numeric'
require 'active_support/string_inquirer' require 'active_support/string_inquirer'
ENV['SKIP_RAILS_ENV_IN_RAKE'] = 'true'
module Rails module Rails
extend self extend self
......
...@@ -521,8 +521,14 @@ module TestEnv ...@@ -521,8 +521,14 @@ module TestEnv
# Cleanup the component entirely to ensure we start fresh # Cleanup the component entirely to ensure we start fresh
FileUtils.rm_rf(install_dir) FileUtils.rm_rf(install_dir)
unless Rake::Task[task].invoke(*task_args) if ENV['SKIP_RAILS_ENV_IN_RAKE']
raise ComponentFailedToInstallError # When we run `scripts/setup-test-env`, we take care of loading the necessary dependencies
# so we can run the rake task programmatically.
Rake::Task[task].invoke(*task_args)
else
# In other cases, we run the task via `rake` so that the environment
# and dependencies are automatically loaded.
raise ComponentFailedToInstallError unless system('rake', "#{task}[#{task_args.join(',')}]")
end end
yield if block_given? yield if block_given?
......
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