Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/cache.rake32
-rw-r--r--lib/tasks/frontend.rake18
-rw-r--r--lib/tasks/gitlab/assets.rake1
-rw-r--r--lib/tasks/gitlab/background_migrations.rake2
-rw-r--r--lib/tasks/gitlab/backup.rake10
-rw-r--r--lib/tasks/gitlab/ci_secure_files/check.rake10
-rw-r--r--lib/tasks/gitlab/ci_secure_files/migrate.rake23
-rw-r--r--lib/tasks/gitlab/db.rake23
-rw-r--r--lib/tasks/gitlab/packages/events.rake5
-rw-r--r--lib/tasks/gitlab/tw/codeowners.rake10
-rw-r--r--lib/tasks/gitlab/usage_data.rake9
-rw-r--r--lib/tasks/tanuki_emoji.rake6
-rw-r--r--lib/tasks/tokens.rake9
13 files changed, 88 insertions, 70 deletions
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake
index 13365b9ec07..8c7e429ef24 100644
--- a/lib/tasks/cache.rake
+++ b/lib/tasks/cache.rake
@@ -7,24 +7,26 @@ namespace :cache do
desc "GitLab | Cache | Clear redis cache"
task redis: :environment do
- Gitlab::Redis::Cache.with do |redis|
- cache_key_pattern = %W[#{Gitlab::Redis::Cache::CACHE_NAMESPACE}*
- projects/*/pipeline_status]
+ [Gitlab::Redis::Cache, Gitlab::Redis::RepositoryCache].each do |redis_instance|
+ redis_instance.with do |redis|
+ cache_key_pattern = %W[#{Gitlab::Redis::Cache::CACHE_NAMESPACE}*
+ projects/*/pipeline_status]
- cache_key_pattern.each do |match|
- cursor = REDIS_SCAN_START_STOP
- loop do
- cursor, keys = redis.scan(
- cursor,
- match: match,
- count: REDIS_CLEAR_BATCH_SIZE
- )
+ cache_key_pattern.each do |match|
+ cursor = REDIS_SCAN_START_STOP
+ loop do
+ cursor, keys = redis.scan(
+ cursor,
+ match: match,
+ count: REDIS_CLEAR_BATCH_SIZE
+ )
- Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
- redis.del(*keys) if keys.any?
- end
+ Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
+ Gitlab::Redis::ClusterUtil.batch_unlink(keys, redis) if keys.any?
+ end
- break if cursor == REDIS_SCAN_START_STOP
+ break if cursor == REDIS_SCAN_START_STOP
+ end
end
end
end
diff --git a/lib/tasks/frontend.rake b/lib/tasks/frontend.rake
index e768c42736d..a6754f13089 100644
--- a/lib/tasks/frontend.rake
+++ b/lib/tasks/frontend.rake
@@ -18,30 +18,12 @@ unless Rails.env.production?
t.rspec_opts = '--format documentation'
end
- desc 'GitLab | Frontend | Generate fixtures for JavaScript integration tests'
- RSpec::Core::RakeTask.new(:mock_server_rspec_fixtures) do |t, args|
- require 'yaml'
-
- base_path = Pathname.new('spec/frontend_integration/fixture_generators.yml')
- ee_path = Pathname.new('ee') + base_path
-
- fixtures = YAML.safe_load(base_path.read)
- fixtures.concat(Array(YAML.safe_load(ee_path.read))) if Gitlab.ee? && ee_path.exist?
-
- t.pattern = fixtures.join(',')
- ENV['NO_KNAPSACK'] = 'true'
- t.rspec_opts = '--format documentation'
- end
-
desc 'GitLab | Frontend | Run JavaScript tests'
task tests: ['yarn:check'] do
sh "yarn test" do |ok, res|
abort('rake frontend:tests failed') unless ok
end
end
-
- desc 'GitLab | Frontend | Shortcut for generating all fixtures used by MirajeJS mock server'
- task mock_server_fixtures: ['frontend:mock_server_rspec_fixtures', 'gitlab:graphql:schema:dump']
end
desc 'GitLab | Frontend | Shortcut for frontend:fixtures and frontend:tests'
diff --git a/lib/tasks/gitlab/assets.rake b/lib/tasks/gitlab/assets.rake
index 2522488f579..b8a6e701876 100644
--- a/lib/tasks/gitlab/assets.rake
+++ b/lib/tasks/gitlab/assets.rake
@@ -15,6 +15,7 @@ module Tasks
yarn.lock
babel.config.js
config/webpack.config.js
+ .nvmrc
].freeze
# Ruby gems might emit assets which have an impact on compilation
# or have a direct impact on asset compilation (e.g. scss) and therefore
diff --git a/lib/tasks/gitlab/background_migrations.rake b/lib/tasks/gitlab/background_migrations.rake
index eca51c345d1..a4e14af22bd 100644
--- a/lib/tasks/gitlab/background_migrations.rake
+++ b/lib/tasks/gitlab/background_migrations.rake
@@ -6,7 +6,7 @@ namespace :gitlab do
namespace :background_migrations do
desc 'Synchronously finish executing a batched background migration'
task :finalize, [:job_class_name, :table_name, :column_name, :job_arguments] => :environment do |_, args|
- if Gitlab::Database.db_config_names.size > 1
+ if Gitlab::Database.db_config_names(with_schema: :gitlab_shared).size > 1
puts "Please specify the database".color(:red)
exit 1
end
diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake
index 22e1d903c8d..4143200ece4 100644
--- a/lib/tasks/gitlab/backup.rake
+++ b/lib/tasks/gitlab/backup.rake
@@ -206,6 +206,16 @@ namespace :gitlab do
Tasks::Gitlab::Backup.restore_task('packages')
end
end
+
+ namespace :ci_secure_files do
+ task create: :gitlab_environment do
+ Tasks::Gitlab::Backup.create_task('ci_secure_files')
+ end
+
+ task restore: :gitlab_environment do
+ Tasks::Gitlab::Backup.restore_task('ci_secure_files')
+ end
+ end
end
# namespace end: backup
end
diff --git a/lib/tasks/gitlab/ci_secure_files/check.rake b/lib/tasks/gitlab/ci_secure_files/check.rake
new file mode 100644
index 00000000000..2c538a9365c
--- /dev/null
+++ b/lib/tasks/gitlab/ci_secure_files/check.rake
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+namespace :gitlab do
+ namespace :ci_secure_files do
+ desc 'GitLab | CI Secure Files | Check integrity of uploaded Secure Files'
+ task check: :environment do
+ Gitlab::Verify::RakeTask.run!(Gitlab::Verify::CiSecureFiles)
+ end
+ end
+end
diff --git a/lib/tasks/gitlab/ci_secure_files/migrate.rake b/lib/tasks/gitlab/ci_secure_files/migrate.rake
new file mode 100644
index 00000000000..8de1b7da6be
--- /dev/null
+++ b/lib/tasks/gitlab/ci_secure_files/migrate.rake
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+desc "GitLab | CI Secure Files | Migrate Secure Files to remote storage"
+namespace :gitlab do
+ namespace :ci_secure_files do
+ task migrate: :environment do
+ require 'logger'
+
+ logger = Logger.new($stdout)
+ logger.info('Starting transfer of Secure Files to object storage')
+
+ begin
+ Gitlab::Ci::SecureFiles::MigrationHelper.migrate_to_remote_storage do |file|
+ message = "Transferred Secure File ID #{file.id} (#{file.name}) to object storage"
+
+ logger.info(message)
+ end
+ rescue StandardError => e
+ logger.error("Failed to migrate: #{e.message}")
+ end
+ end
+ end
+end
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 34ccce3ba2f..026cb39a92f 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -473,7 +473,7 @@ namespace :gitlab do
Gitlab::Database::SchemaValidation::TrackInconsistency.new(
inconsistency,
Project.find_by_full_path(gitlab_url),
- User.support_bot
+ User.automation_bot
).execute
puts inconsistency.inspect
@@ -482,18 +482,12 @@ namespace :gitlab do
end
namespace :dictionary do
- DB_DOCS_PATH = Rails.root.join('db', 'docs')
-
desc 'Generate database docs yaml'
task generate: :environment do
next if Gitlab.jh?
- FileUtils.mkdir_p(DB_DOCS_PATH)
-
- if Gitlab.ee?
- Gitlab::Database::EE_DATABASES_NAME_TO_DIR.each do |_, ee_db_dir|
- FileUtils.mkdir_p(Rails.root.join(ee_db_dir, 'docs'))
- end
+ Gitlab::Database.all_database_connections.values.map(&:db_docs_dir).each do |db_dir|
+ FileUtils.mkdir_p(db_dir)
end
Rails.application.eager_load!
@@ -502,7 +496,6 @@ namespace :gitlab do
milestone = version.release.segments.first(2).join('.')
classes = {}
- ignored_tables = %w[p_ci_builds]
Gitlab::Database.database_base_models.each do |_, model_class|
tables = model_class.connection.tables
@@ -521,11 +514,10 @@ namespace :gitlab do
.reject { |c| c.name =~ /^(?:EE::)?Gitlab::(?:BackgroundMigration|DatabaseImporters)::/ }
.reject { |c| c.name =~ /^HABTM_/ }
.reject { |c| c < Gitlab::Database::Migration[1.0]::MigrationRecord }
- .each { |c| classes[c.table_name] << c.name if classes.has_key?(c.table_name) }
+ .each { |c| classes[c.table_name] << c.name if classes.has_key?(c.table_name) && c.name.present? }
sources.each do |source_name|
next if source_name.start_with?('_test_') # Ignore test tables
- next if ignored_tables.include?(source_name)
database = model_class.connection_db_config.name
file = dictionary_file_path(source_name, views, database)
@@ -574,12 +566,7 @@ namespace :gitlab do
def dictionary_file_path(source_name, views, database)
sub_directory = views.include?(source_name) ? 'views' : ''
- path = if Gitlab.ee? && Gitlab::Database::EE_DATABASES_NAME_TO_DIR.key?(database.to_s)
- Rails.root.join(Gitlab::Database::EE_DATABASES_NAME_TO_DIR[database.to_s], 'docs')
- else
- DB_DOCS_PATH
- end
-
+ path = Gitlab::Database.all_database_connections.fetch(database).db_docs_dir
File.join(path, sub_directory, "#{source_name}.yml")
end
diff --git a/lib/tasks/gitlab/packages/events.rake b/lib/tasks/gitlab/packages/events.rake
index 1234ba039a3..b5dfd163dba 100644
--- a/lib/tasks/gitlab/packages/events.rake
+++ b/lib/tasks/gitlab/packages/events.rake
@@ -45,10 +45,7 @@ namespace :gitlab do
events = event_pairs.each_with_object([]) do |(event_type, event_scope), events|
Packages::Event::ORIGINATOR_TYPES.excluding(:guest).each do |originator_type|
events_definition = Packages::Event.unique_counters_for(event_scope, event_type, originator_type).map do |event_name|
- {
- "name" => event_name,
- "aggregation" => "weekly"
- }
+ { "name" => event_name }
end
events.concat(events_definition)
diff --git a/lib/tasks/gitlab/tw/codeowners.rake b/lib/tasks/gitlab/tw/codeowners.rake
index b4b34581f43..afe2c564247 100644
--- a/lib/tasks/gitlab/tw/codeowners.rake
+++ b/lib/tasks/gitlab/tw/codeowners.rake
@@ -48,18 +48,18 @@ namespace :tw do
CodeOwnerRule.new('Fuzz Testing', '@rdickenson'),
CodeOwnerRule.new('Geo', '@axil'),
CodeOwnerRule.new('Gitaly', '@eread'),
- CodeOwnerRule.new('GitLab Dedicated', '@drcatherinepope'),
+ # CodeOwnerRule.new('GitLab Dedicated', ''),
CodeOwnerRule.new('Global Search', '@ashrafkhamis'),
CodeOwnerRule.new('Import and Integrate', '@eread @ashrafkhamis'),
CodeOwnerRule.new('Infrastructure', '@sselhorn'),
# CodeOwnerRule.new('Knowledge', ''),
# CodeOwnerRule.new('MLOps', '')
- CodeOwnerRule.new('Observability', '@drcatherinepope'),
+ # CodeOwnerRule.new('Observability', ''),
CodeOwnerRule.new('Optimize', '@lciutacu'),
CodeOwnerRule.new('Organization', '@lciutacu'),
- CodeOwnerRule.new('Package Registry', '@marcel.amirault'),
+ CodeOwnerRule.new('Package Registry', '@phillipwells'),
CodeOwnerRule.new('Pipeline Authoring', '@marcel.amirault'),
- CodeOwnerRule.new('Pipeline Execution', '@drcatherinepope'),
+ CodeOwnerRule.new('Pipeline Execution', '@marcel.amirault'),
CodeOwnerRule.new('Pipeline Security', '@marcel.amirault'),
CodeOwnerRule.new('Product Analytics', '@lciutacu'),
CodeOwnerRule.new('Product Planning', '@msedlakjakubowski'),
@@ -71,7 +71,7 @@ namespace :tw do
CodeOwnerRule.new('Runner', '@fneill'),
CodeOwnerRule.new('Runner SaaS', '@fneill'),
CodeOwnerRule.new('Security Policies', '@rdickenson'),
- CodeOwnerRule.new('Source Code', '@aqualls'),
+ CodeOwnerRule.new('Source Code', '@aqualls @msedlakjakubowski'),
CodeOwnerRule.new('Static Analysis', '@rdickenson'),
CodeOwnerRule.new('Style Guide', '@sselhorn'),
CodeOwnerRule.new('Tenant Scale', '@lciutacu'),
diff --git a/lib/tasks/gitlab/usage_data.rake b/lib/tasks/gitlab/usage_data.rake
index fcbec4b0dba..f5bf1a266e5 100644
--- a/lib/tasks/gitlab/usage_data.rake
+++ b/lib/tasks/gitlab/usage_data.rake
@@ -85,12 +85,13 @@ namespace :gitlab do
end
end
+ # rubocop:disable Gitlab/NoCodeCoverageComment
+ # :nocov: remove in https://gitlab.com/gitlab-org/gitlab/-/issues/299453
def ci_template_event(event_name)
- {
- 'name' => event_name,
- 'aggregation' => 'weekly'
- }
+ { 'name' => event_name }
end
+ # :nocov:
+ # rubocop:enable Gitlab/NoCodeCoverageComment
def implicit_auto_devops_event(expanded_template_name)
event_name = Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_template_event_name(expanded_template_name, :auto_devops_source)
diff --git a/lib/tasks/tanuki_emoji.rake b/lib/tasks/tanuki_emoji.rake
index b02d7a532c4..de2ae656952 100644
--- a/lib/tasks/tanuki_emoji.rake
+++ b/lib/tasks/tanuki_emoji.rake
@@ -157,9 +157,9 @@ namespace :tanuki_emoji do
# SpriteFactory's SCSS is a bit too verbose for our purposes here, so
# let's simplify it
- system(%Q(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
- system(%Q(sed -i '' "s/ no-repeat//" #{style_path}))
- system(%Q(sed -i '' "s/ 0px/ 0/g" #{style_path}))
+ system(%(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
+ system(%(sed -i '' "s/ no-repeat//" #{style_path}))
+ system(%(sed -i '' "s/ 0px/ 0/g" #{style_path}))
# Append a generic rule that applies to all Emojis
File.open(style_path, 'a') do |f|
diff --git a/lib/tasks/tokens.rake b/lib/tasks/tokens.rake
index 81e24f4f7b6..c974aebf503 100644
--- a/lib/tasks/tokens.rake
+++ b/lib/tasks/tokens.rake
@@ -31,6 +31,11 @@ class TmpUser < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
self.table_name = 'users'
- add_authentication_token_field :incoming_email_token, token_generator: -> { SecureRandom.hex.to_i(16).to_s(36) }
- add_authentication_token_field :feed_token
+ add_authentication_token_field :incoming_email_token,
+ token_generator: -> { User.generate_incoming_mail_token }
+ add_authentication_token_field :feed_token, format_with_prefix: :prefix_for_feed_token
+
+ def prefix_for_feed_token
+ User::FEED_TOKEN_PREFIX
+ end
end