diff options
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/assets.rake | 11 | ||||
-rw-r--r-- | lib/tasks/gitlab/db/truncate_legacy_tables.rake | 31 | ||||
-rw-r--r-- | lib/tasks/gitlab/db/validate_config.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/import_export/export.rake | 6 | ||||
-rw-r--r-- | lib/tasks/gitlab/import_export/import.rake | 6 | ||||
-rw-r--r-- | lib/tasks/gitlab/tw/codeowners.rake | 10 | ||||
-rw-r--r-- | lib/tasks/gitlab/uploads/migrate.rake | 22 | ||||
-rw-r--r-- | lib/tasks/gitlab/usage_data.rake | 22 | ||||
-rw-r--r-- | lib/tasks/haml-lint.rake | 7 | ||||
-rw-r--r-- | lib/tasks/rubocop.rake | 13 | ||||
-rw-r--r-- | lib/tasks/tanuki_emoji.rake | 18 |
11 files changed, 98 insertions, 50 deletions
diff --git a/lib/tasks/gitlab/assets.rake b/lib/tasks/gitlab/assets.rake index 0b70dba5c05..76ee5379213 100644 --- a/lib/tasks/gitlab/assets.rake +++ b/lib/tasks/gitlab/assets.rake @@ -40,6 +40,7 @@ module Tasks asset_files end + private_class_method :assets_impacting_webpack_compilation end end @@ -84,9 +85,17 @@ namespace :gitlab do if head_assets_sha256 != master_assets_sha256 || !public_assets_webpack_dir_exists FileUtils.rm_r(Tasks::Gitlab::Assets::PUBLIC_ASSETS_WEBPACK_DIR) if public_assets_webpack_dir_exists - unless system('yarn webpack') + log_path = ENV['WEBPACK_COMPILE_LOG_PATH'] + + cmd = 'yarn webpack' + cmd += " > #{log_path}" if log_path + + unless system(cmd) abort 'Error: Unable to compile webpack production bundle.'.color(:red) end + + puts "Written webpack stdout log to #{log_path}" if log_path + puts "You can inspect the webpack log here: #{ENV['CI_JOB_URL']}/artifacts/file/#{log_path}" if log_path && ENV['CI_JOB_URL'] end end diff --git a/lib/tasks/gitlab/db/truncate_legacy_tables.rake b/lib/tasks/gitlab/db/truncate_legacy_tables.rake new file mode 100644 index 00000000000..9c3d7c3876d --- /dev/null +++ b/lib/tasks/gitlab/db/truncate_legacy_tables.rake @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +namespace :gitlab do + namespace :db do + namespace :truncate_legacy_tables do + desc "GitLab | DB | Truncate CI Tables on Main" + task :main, [:min_batch_size] => [:environment, 'gitlab:db:validate_config'] do |_t, args| + args.with_defaults(min_batch_size: 5) + Gitlab::Database::TablesTruncate.new( + database_name: 'main', + min_batch_size: args.min_batch_size.to_i, + logger: Logger.new($stdout), + dry_run: ENV['DRY_RUN'] == 'true', + until_table: ENV['UNTIL_TABLE'] + ).execute + end + + desc "GitLab | DB | Truncate Main Tables on CI" + task :ci, [:min_batch_size] => [:environment, 'gitlab:db:validate_config'] do |_t, args| + args.with_defaults(min_batch_size: 5) + Gitlab::Database::TablesTruncate.new( + database_name: 'ci', + min_batch_size: args.min_batch_size.to_i, + logger: Logger.new($stdout), + dry_run: ENV['DRY_RUN'] == 'true', + until_table: ENV['UNTIL_TABLE'] + ).execute + end + end + end +end diff --git a/lib/tasks/gitlab/db/validate_config.rake b/lib/tasks/gitlab/db/validate_config.rake index 2a3a54b5351..bf9ebc56486 100644 --- a/lib/tasks/gitlab/db/validate_config.rake +++ b/lib/tasks/gitlab/db/validate_config.rake @@ -144,7 +144,7 @@ namespace :gitlab do rescue ActiveRecord::StatementInvalid => err raise unless err.cause.is_a?(PG::ReadOnlySqlTransaction) - warn "WARNING: Could not write to the database #{db_config.name}: #{err.message}" + warn "WARNING: Could not write to the database #{db_config.name}: cannot execute UPSERT in a read-only transaction" end def get_db_identifier(db_config) diff --git a/lib/tasks/gitlab/import_export/export.rake b/lib/tasks/gitlab/import_export/export.rake index 4bdc62c9319..3cefdcc1aaf 100644 --- a/lib/tasks/gitlab/import_export/export.rake +++ b/lib/tasks/gitlab/import_export/export.rake @@ -27,9 +27,9 @@ namespace :gitlab do task = Gitlab::ImportExport::Project::ExportTask.new( namespace_path: args.namespace_path, - project_path: args.project_path, - username: args.username, - file_path: args.archive_path, + project_path: args.project_path, + username: args.username, + file_path: args.archive_path, logger: logger ) diff --git a/lib/tasks/gitlab/import_export/import.rake b/lib/tasks/gitlab/import_export/import.rake index 2702b530334..fc727eda380 100644 --- a/lib/tasks/gitlab/import_export/import.rake +++ b/lib/tasks/gitlab/import_export/import.rake @@ -31,9 +31,9 @@ namespace :gitlab do task = Gitlab::ImportExport::Project::ImportTask.new( namespace_path: args.namespace_path, - project_path: args.project_path, - username: args.username, - file_path: args.archive_path, + project_path: args.project_path, + username: args.username, + file_path: args.archive_path, logger: logger ) diff --git a/lib/tasks/gitlab/tw/codeowners.rake b/lib/tasks/gitlab/tw/codeowners.rake index f6c518784a9..148801254bf 100644 --- a/lib/tasks/gitlab/tw/codeowners.rake +++ b/lib/tasks/gitlab/tw/codeowners.rake @@ -19,16 +19,15 @@ namespace :tw do end CODE_OWNER_RULES = [ - CodeOwnerRule.new('Activation', '@kpaizee'), - CodeOwnerRule.new("Adoption", '@kpaizee'), - CodeOwnerRule.new('Activation', '@kpaizee'), - CodeOwnerRule.new('Adoption', '@kpaizee'), + CodeOwnerRule.new('Activation', '@phillipwells'), + CodeOwnerRule.new('Acquisition', '@phillipwells'), + CodeOwnerRule.new('Anti-Abuse', '@phillipwells'), CodeOwnerRule.new('Authentication and Authorization', '@eread'), CodeOwnerRule.new('Certify', '@msedlakjakubowski'), CodeOwnerRule.new('Code Review', '@aqualls'), CodeOwnerRule.new('Compliance', '@eread'), CodeOwnerRule.new('Composition Analysis', '@rdickenson'), - CodeOwnerRule.new('Configure', '@sselhorn'), + CodeOwnerRule.new('Configure', '@phillipwells'), CodeOwnerRule.new('Container Security', '@claytoncornell'), CodeOwnerRule.new('Contributor Experience', '@eread'), CodeOwnerRule.new('Conversion', '@kpaizee'), @@ -41,7 +40,6 @@ namespace :tw do CodeOwnerRule.new('Dynamic Analysis', '@rdickenson'), CodeOwnerRule.new('Ecosystem', '@kpaizee'), CodeOwnerRule.new('Editor', '@aqualls'), - CodeOwnerRule.new('Expansion', '@kpaizee'), CodeOwnerRule.new('Foundations', '@rdickenson'), CodeOwnerRule.new('Fuzz Testing', '@rdickenson'), CodeOwnerRule.new('Geo', '@axil'), diff --git a/lib/tasks/gitlab/uploads/migrate.rake b/lib/tasks/gitlab/uploads/migrate.rake index 80290f95e8e..2a91fd1646c 100644 --- a/lib/tasks/gitlab/uploads/migrate.rake +++ b/lib/tasks/gitlab/uploads/migrate.rake @@ -2,15 +2,8 @@ namespace :gitlab do namespace :uploads do - namespace :migrate do - desc "GitLab | Uploads | Migrate all uploaded files to object storage" - task all: :environment do - Gitlab::Uploads::MigrationHelper.categories.each do |args| - Rake::Task["gitlab:uploads:migrate"].invoke(*args) - Rake::Task["gitlab:uploads:migrate"].reenable - end - end - end + desc "GitLab | Uploads | Migrate all uploaded files to object storage" + task 'migrate:all' => :migrate # The following is the actual rake task that migrates uploads of specified # category to object storage @@ -19,15 +12,8 @@ namespace :gitlab do Gitlab::Uploads::MigrationHelper.new(args, Logger.new($stdout)).migrate_to_remote_storage end - namespace :migrate_to_local do - desc "GitLab | Uploads | Migrate all uploaded files to local storage" - task all: :environment do - Gitlab::Uploads::MigrationHelper.categories.each do |args| - Rake::Task["gitlab:uploads:migrate_to_local"].invoke(*args) - Rake::Task["gitlab:uploads:migrate_to_local"].reenable - end - end - end + desc "GitLab | Uploads | Migrate all uploaded files to local storage" + task 'migrate_to_local:all' => :migrate_to_local desc 'GitLab | Uploads | Migrate the uploaded files of specified type to local storage' task :migrate_to_local, [:uploader_class, :model_class, :mounted_as] => :environment do |_t, args| diff --git a/lib/tasks/gitlab/usage_data.rake b/lib/tasks/gitlab/usage_data.rake index 9f064ef4c0c..73a79427da3 100644 --- a/lib/tasks/gitlab/usage_data.rake +++ b/lib/tasks/gitlab/usage_data.rake @@ -17,11 +17,16 @@ namespace :gitlab do puts Gitlab::Json.pretty_generate(Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)) end + desc 'GitLab | UsageData | Generate non SQL data for usage ping in JSON' + task dump_non_sql_in_json: :environment do + puts Gitlab::Json.pretty_generate(Gitlab::Usage::ServicePingReport.for(output: :non_sql_metrics_values)) + end + desc 'GitLab | UsageData | Generate usage ping and send it to Versions Application' task generate_and_send: :environment do - result = ServicePing::SubmitService.new.execute + response = GitlabServicePingWorker.new.perform('triggered_from_cron' => false) - puts Gitlab::Json.pretty_generate(result.attributes) + puts response.body, response.code, response.message, response.headers.inspect end desc 'GitLab | UsageDataMetrics | Generate usage ping from metrics definition YAML files in JSON' @@ -51,6 +56,19 @@ namespace :gitlab do File.write(Gitlab::UsageDataCounters::CiTemplateUniqueCounter::KNOWN_EVENTS_FILE_PATH, banner + YAML.dump(all_includes).gsub(/ *$/m, '')) end + desc 'GitLab | UsageDataMetrics | Generate raw SQL metrics queries for RSpec' + task generate_sql_metrics_queries: :environment do + path = Rails.root.join('tmp', 'test') + + queries = Timecop.freeze(2021, 1, 1) do + Gitlab::Usage::ServicePingReport.for(output: :metrics_queries) + end + + FileUtils.mkdir_p(path) + FileUtils.chdir(path) + File.write('sql_metrics_queries.json', Gitlab::Json.pretty_generate(queries)) + end + def ci_template_includes_hash(source, template_directory = nil) Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_templates("lib/gitlab/ci/templates/#{template_directory}").map do |template| expanded_template_name = Gitlab::UsageDataCounters::CiTemplateUniqueCounter.expand_template_name("#{template_directory}/#{template}") diff --git a/lib/tasks/haml-lint.rake b/lib/tasks/haml-lint.rake deleted file mode 100644 index 29589571344..00000000000 --- a/lib/tasks/haml-lint.rake +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -unless Rails.env.production? - require 'haml_lint/rake_task' - - HamlLint::RakeTask.new -end diff --git a/lib/tasks/rubocop.rake b/lib/tasks/rubocop.rake index e993035aa65..0c257585bd0 100644 --- a/lib/tasks/rubocop.rake +++ b/lib/tasks/rubocop.rake @@ -6,6 +6,19 @@ unless Rails.env.production? RuboCop::RakeTask.new namespace :rubocop do + namespace :check do + desc 'Run RuboCop check gracefully' + task :graceful do |_task, args| + require_relative '../../rubocop/check_graceful_task' + + # Don't reveal TODOs in this run. + ENV.delete('REVEAL_RUBOCOP_TODO') + + result = RuboCop::CheckGracefulTask.new($stdout).run(args.extras) + exit result if result.nonzero? + end + end + namespace :todo do desc 'Generate RuboCop todos' task :generate do |_task, args| diff --git a/lib/tasks/tanuki_emoji.rake b/lib/tasks/tanuki_emoji.rake index 0dc7dd4e701..b02d7a532c4 100644 --- a/lib/tasks/tanuki_emoji.rake +++ b/lib/tasks/tanuki_emoji.rake @@ -148,11 +148,11 @@ namespace :tanuki_emoji do SpriteFactory.run!(tmpdir, { output_style: style_path, output_image: "app/assets/images/emoji.png", - selector: '.emoji-', - style: :scss, - nocomments: true, - pngcrush: true, - layout: :packed + selector: '.emoji-', + style: :scss, + nocomments: true, + pngcrush: true, + layout: :packed }) # SpriteFactory's SCSS is a bit too verbose for our purposes here, so @@ -215,10 +215,10 @@ namespace :tanuki_emoji do # Combine the resized assets into a packed sprite and re-generate the SCSS SpriteFactory.run!(tmpdir, { output_image: "app/assets/images/emoji@2x.png", - style: false, - nocomments: true, - pngcrush: true, - layout: :packed + style: false, + nocomments: true, + pngcrush: true, + layout: :packed }) end |