Commit d33fc982 authored by Robert Speicher's avatar Robert Speicher

Move the nested groups seed behind an environment flag

This seed downloads 2.1 GB worth of repositories. Google can afford the
bandwidth, but if a person using the GDK is on a metered connection,
that's not so great.

Also the GDK test suite runs this seed, so every CI run for that project
had to download those as well. Needlessly wasteful.
parent 9c576cc7
...@@ -223,7 +223,9 @@ class Gitlab::Seeder::CycleAnalytics ...@@ -223,7 +223,9 @@ class Gitlab::Seeder::CycleAnalytics
end end
Gitlab::Seeder.quiet do Gitlab::Seeder.quiet do
if ENV['SEED_CYCLE_ANALYTICS'] flag = 'SEED_CYCLE_ANALYTICS'
if ENV[flag]
Project.all.each do |project| Project.all.each do |project|
seeder = Gitlab::Seeder::CycleAnalytics.new(project) seeder = Gitlab::Seeder::CycleAnalytics.new(project)
seeder.seed! seeder.seed!
...@@ -235,6 +237,6 @@ Gitlab::Seeder.quiet do ...@@ -235,6 +237,6 @@ Gitlab::Seeder.quiet do
seeder = Gitlab::Seeder::CycleAnalytics.new(Project.order(:id).first, perf: true) seeder = Gitlab::Seeder::CycleAnalytics.new(Project.order(:id).first, perf: true)
seeder.seed_metrics! seeder.seed_metrics!
else else
puts "Not running the cycle analytics seed file. Use the `SEED_CYCLE_ANALYTICS` environment variable to enable it." puts "Skipped. Use the `#{flag}` environment variable to enable."
end end
end end
...@@ -27,43 +27,49 @@ end ...@@ -27,43 +27,49 @@ end
Sidekiq::Testing.inline! do Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do Gitlab::Seeder.quiet do
project_urls = [ flag = 'SEED_NESTED_GROUPS'
'https://android.googlesource.com/platform/hardware/broadcom/libbt.git',
'https://android.googlesource.com/platform/hardware/broadcom/wlan.git',
'https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git',
'https://android.googlesource.com/platform/hardware/bsp/broadcom.git',
'https://android.googlesource.com/platform/hardware/bsp/freescale.git',
'https://android.googlesource.com/platform/hardware/bsp/imagination.git',
'https://android.googlesource.com/platform/hardware/bsp/intel.git',
'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git',
'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git'
]
user = User.admins.first if ENV[flag]
project_urls = [
'https://android.googlesource.com/platform/hardware/broadcom/libbt.git',
'https://android.googlesource.com/platform/hardware/broadcom/wlan.git',
'https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git',
'https://android.googlesource.com/platform/hardware/bsp/broadcom.git',
'https://android.googlesource.com/platform/hardware/bsp/freescale.git',
'https://android.googlesource.com/platform/hardware/bsp/imagination.git',
'https://android.googlesource.com/platform/hardware/bsp/intel.git',
'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git',
'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git'
]
project_urls.each_with_index do |url, i| user = User.admins.first
full_path = url.sub('https://android.googlesource.com/', '')
full_path = full_path.sub(/\.git\z/, '')
full_path, _, project_path = full_path.rpartition('/')
group = Group.find_by_full_path(full_path) || create_group_with_parents(user, full_path)
params = { project_urls.each_with_index do |url, i|
import_url: url, full_path = url.sub('https://android.googlesource.com/', '')
namespace_id: group.id, full_path = full_path.sub(/\.git\z/, '')
path: project_path, full_path, _, project_path = full_path.rpartition('/')
name: project_path, group = Group.find_by_full_path(full_path) || create_group_with_parents(user, full_path)
description: FFaker::Lorem.sentence,
visibility_level: Gitlab::VisibilityLevel.values.sample
}
project = Projects::CreateService.new(user, params).execute params = {
project.send(:_run_after_commit_queue) import_url: url,
namespace_id: group.id,
path: project_path,
name: project_path,
description: FFaker::Lorem.sentence,
visibility_level: Gitlab::VisibilityLevel.values.sample
}
if project.valid? project = Projects::CreateService.new(user, params).execute
print '.' project.send(:_run_after_commit_queue)
else
print 'F' if project.valid?
print '.'
else
print 'F'
end
end end
else
puts "Skipped. Use the `#{flag}` environment variable to enable."
end end
end end
end end
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