summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 14:22:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 14:22:11 +0000
commit0c872e02b2c822e3397515ec324051ff540f0cd5 (patch)
treece2fb6ce7030e4dad0f4118d21ab6453e5938cdd /lib/tasks
parentf7e05a6853b12f02911494c4b3fe53d9540d74fc (diff)
downloadgitlab-ce-0c872e02b2c822e3397515ec324051ff540f0cd5.tar.gz
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/contracts/merge_requests.rake26
-rw-r--r--lib/tasks/contracts/pipeline_schedules.rake9
-rw-r--r--lib/tasks/contracts/pipelines.rake31
-rw-r--r--lib/tasks/dev.rake15
-rw-r--r--lib/tasks/gitlab/assets.rake6
-rw-r--r--lib/tasks/gitlab/cleanup.rake10
-rw-r--r--lib/tasks/gitlab/db.rake3
-rw-r--r--lib/tasks/gitlab/db/lock_writes.rake5
-rw-r--r--lib/tasks/gitlab/feature_categories.rake80
-rw-r--r--lib/tasks/gitlab/info.rake8
-rw-r--r--lib/tasks/gitlab/shell.rake12
-rw-r--r--lib/tasks/gitlab/sidekiq.rake11
-rw-r--r--lib/tasks/gitlab/tw/codeowners.rake21
-rw-r--r--lib/tasks/gitlab/update_templates.rake13
-rw-r--r--lib/tasks/gitlab/usage_data.rake5
15 files changed, 175 insertions, 80 deletions
diff --git a/lib/tasks/contracts/merge_requests.rake b/lib/tasks/contracts/merge_requests.rake
index 2ee7ec07a96..61823f0cf1a 100644
--- a/lib/tasks/contracts/merge_requests.rake
+++ b/lib/tasks/contracts/merge_requests.rake
@@ -4,29 +4,35 @@ return if Rails.env.production?
require 'pact/tasks/verification_task'
-contracts = File.expand_path('../../../spec/contracts/contracts/project/merge_request', __dir__)
provider = File.expand_path('../../../spec/contracts/provider', __dir__)
namespace :contracts do
+ require_relative "../../../spec/contracts/provider/helpers/contract_source_helper"
+
namespace :merge_requests do
- Pact::VerificationTask.new(:diffs_batch) do |pact|
+ Pact::VerificationTask.new(:get_diffs_batch) do |pact|
+ pact_helper_location = "pact_helpers/project/merge_requests/show/get_diffs_batch_helper.rb"
+
pact.uri(
- "#{contracts}/show/mergerequest#show-merge_request_diffs_batch_endpoint.json",
- pact_helper: "#{provider}/pact_helpers/project/merge_request/show/diffs_batch_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
- Pact::VerificationTask.new(:diffs_metadata) do |pact|
+ Pact::VerificationTask.new(:get_diffs_metadata) do |pact|
+ pact_helper_location = "pact_helpers/project/merge_requests/show/get_diffs_metadata_helper.rb"
pact.uri(
- "#{contracts}/show/mergerequest#show-merge_request_diffs_metadata_endpoint.json",
- pact_helper: "#{provider}/pact_helpers/project/merge_request/show/diffs_metadata_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
- Pact::VerificationTask.new(:discussions) do |pact|
+ Pact::VerificationTask.new(:get_discussions) do |pact|
+ pact_helper_location = "pact_helpers/project/merge_requests/show/get_discussions_helper.rb"
+
pact.uri(
- "#{contracts}/show/mergerequest#show-merge_request_discussions_endpoint.json",
- pact_helper: "#{provider}/pact_helpers/project/merge_request/show/discussions_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
diff --git a/lib/tasks/contracts/pipeline_schedules.rake b/lib/tasks/contracts/pipeline_schedules.rake
index 75080d41ebe..b4c87d2e3c9 100644
--- a/lib/tasks/contracts/pipeline_schedules.rake
+++ b/lib/tasks/contracts/pipeline_schedules.rake
@@ -4,15 +4,18 @@ return if Rails.env.production?
require 'pact/tasks/verification_task'
-contracts = File.expand_path('../../../spec/contracts/contracts/project/pipeline_schedule', __dir__)
provider = File.expand_path('../../../spec/contracts/provider', __dir__)
namespace :contracts do
+ require_relative "../../../spec/contracts/provider/helpers/contract_source_helper"
+
namespace :pipeline_schedules do
Pact::VerificationTask.new(:update_pipeline_schedule) do |pact|
+ pact_helper_location = "pact_helpers/project/pipeline_schedules/edit/put_edit_a_pipeline_schedule_helper.rb"
+
pact.uri(
- "#{contracts}/edit/pipelineschedules#edit-put_edit_a_pipeline_schedule.json",
- pact_helper: "#{provider}/pact_helpers/project/pipeline_schedule/update_pipeline_schedule_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
diff --git a/lib/tasks/contracts/pipelines.rake b/lib/tasks/contracts/pipelines.rake
index 5a8d7791233..55a7baa4539 100644
--- a/lib/tasks/contracts/pipelines.rake
+++ b/lib/tasks/contracts/pipelines.rake
@@ -4,40 +4,45 @@ return if Rails.env.production?
require 'pact/tasks/verification_task'
-contracts = File.expand_path('../../../spec/contracts/contracts/project/pipeline', __dir__)
provider = File.expand_path('../../../spec/contracts/provider', __dir__)
namespace :contracts do
+ require_relative "../../../spec/contracts/provider/helpers/contract_source_helper"
+
namespace :pipelines do
Pact::VerificationTask.new(:create_a_new_pipeline) do |pact|
+ pact_helper_location = "pact_helpers/project/pipelines/new/post_create_a_new_pipeline_helper.rb"
+
pact.uri(
- "#{contracts}/new/pipelines#new-post_create_a_new_pipeline.json",
- pact_helper: "#{provider}/pact_helpers/project/pipeline/index/create_a_new_pipeline_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
Pact::VerificationTask.new(:get_list_project_pipelines) do |pact|
+ pact_helper_location = "pact_helpers/project/pipelines/index/get_list_project_pipelines_helper.rb"
+
pact.uri(
- "#{contracts}/index/pipelines#index-get_list_project_pipelines.json",
- pact_helper: "#{provider}/pact_helpers/project/pipeline/index/get_list_project_pipelines_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
Pact::VerificationTask.new(:get_pipeline_header_data) do |pact|
- # pact.uri(
- # "http://localhost:9292/pacts/provider/GET%20pipeline%20header%20data/consumer/Pipelines%23show/latest",
- # pact_helper: "#{provider}/pact_helpers/project/pipeline/show/get_pipeline_header_data_helper.rb"
- # )
+ pact_helper_location = "pact_helpers/project/pipelines/show/get_pipeline_header_data_helper.rb"
+
pact.uri(
- "#{contracts}/show/pipelines#show-get_pipeline_header_data.json",
- pact_helper: "#{provider}/pact_helpers/project/pipeline/show/get_pipeline_header_data_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
Pact::VerificationTask.new(:delete_pipeline) do |pact|
+ pact_helper_location = "pact_helpers/project/pipelines/show/delete_pipeline_helper.rb"
+
pact.uri(
- "#{contracts}/show/pipelines#show-delete_pipeline.json",
- pact_helper: "#{provider}/pact_helpers/project/pipeline/show/delete_pipeline_helper.rb"
+ Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
+ pact_helper: "#{provider}/#{pact_helper_location}"
)
end
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index 129f4c0ff0e..22ca5d9039c 100644
--- a/lib/tasks/dev.rake
+++ b/lib/tasks/dev.rake
@@ -76,13 +76,9 @@ namespace :dev do
namespace :copy_db do
ALLOWED_DATABASES = %w[ci].freeze
- defined_copy_db_tasks = []
-
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
next unless ALLOWED_DATABASES.include?(name)
- defined_copy_db_tasks << name
-
desc "Copies the #{name} database from the main database"
task name => :environment do
Rake::Task["dev:terminate_all_connections"].invoke
@@ -94,16 +90,5 @@ namespace :dev do
warn "Database '#{db_config.database}' already exists"
end
end
-
- ALLOWED_DATABASES.each do |name|
- next if defined_copy_db_tasks.include?(name)
-
- # :nocov: we cannot mock ActiveRecord::Tasks::DatabaseTasks in time
- # Workaround for GDK issue, see
- # https://gitlab.com/gitlab-org/gitlab-development-kit/-/issues/1464
- desc "No-op task"
- task name
- # :nocov:
- end
end
end
diff --git a/lib/tasks/gitlab/assets.rake b/lib/tasks/gitlab/assets.rake
index 12a8cb01e9e..d8c0b1007e6 100644
--- a/lib/tasks/gitlab/assets.rake
+++ b/lib/tasks/gitlab/assets.rake
@@ -137,7 +137,7 @@ namespace :gitlab do
File.open(gzip, 'wb+') do |f|
gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
gz.mtime = mtime
- gz.write IO.binread(file)
+ gz.write File.binread(file)
gz.close
File.utime(mtime, mtime, f.path)
@@ -154,7 +154,9 @@ namespace :gitlab do
desc 'GitLab | Assets | Check that scss mixins do not introduce any sideffects'
task :check_page_bundle_mixins_css_for_sideeffects do
- system('./scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js')
+ unless system('./scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js')
+ abort 'Error: At least one CSS changes introduces an unwanted sideeffect'.color(:red)
+ end
end
end
end
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake
index f908a7606fa..49d2d9fed03 100644
--- a/lib/tasks/gitlab/cleanup.rake
+++ b/lib/tasks/gitlab/cleanup.rake
@@ -15,13 +15,11 @@ namespace :gitlab do
if Gitlab::Auth::Ldap::Access.allowed?(user)
puts " [OK]".color(:green)
+ elsif block_flag
+ user.block! unless user.blocked?
+ puts " [BLOCKED]".color(:red)
else
- if block_flag
- user.block! unless user.blocked?
- puts " [BLOCKED]".color(:red)
- else
- puts " [NOT IN LDAP]".color(:yellow)
- end
+ puts " [NOT IN LDAP]".color(:yellow)
end
end
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 4ef0c396f4a..f0264456201 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -316,6 +316,7 @@ namespace :gitlab do
all_databases.each do |db|
desc "Run migrations on #{db} with instrumentation"
task db => :environment do
+ Gitlab::Database::Migrations::Runner.batched_migrations_last_id(db).store
Gitlab::Database::Migrations::Runner.up(database: db).run
end
end
@@ -406,7 +407,7 @@ namespace :gitlab do
Rails.application.eager_load!
tables = Gitlab::Database.database_base_models.flat_map { |_, m| m.connection.tables }
- classes = tables.to_h { |t| [t, []] }
+ classes = tables.index_with { [] }
Gitlab::Database.database_base_models.each do |_, model_class|
model_class
diff --git a/lib/tasks/gitlab/db/lock_writes.rake b/lib/tasks/gitlab/db/lock_writes.rake
index 421c6a90fdd..a856aa77abc 100644
--- a/lib/tasks/gitlab/db/lock_writes.rake
+++ b/lib/tasks/gitlab/db/lock_writes.rake
@@ -6,7 +6,8 @@ namespace :gitlab do
task lock_writes: [:environment, 'gitlab:db:validate_config'] do
Gitlab::Database::EachDatabase.each_database_connection(include_shared: false) do |connection, database_name|
schemas_for_connection = Gitlab::Database.gitlab_schemas_for_connection(connection)
- Gitlab::Database::GitlabSchema.tables_to_schema.each do |table_name, schema_name|
+
+ Gitlab::Database::LockWritesManager.tables_to_lock(connection) do |table_name, schema_name|
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834
next if schema_name == :gitlab_geo
@@ -30,7 +31,7 @@ namespace :gitlab do
desc "GitLab | DB | Remove all triggers that prevents writes from all databases"
task unlock_writes: :environment do
Gitlab::Database::EachDatabase.each_database_connection do |connection, database_name|
- Gitlab::Database::GitlabSchema.tables_to_schema.each do |table_name, schema_name|
+ Gitlab::Database::LockWritesManager.tables_to_lock(connection) do |table_name, schema_name|
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834
next if schema_name == :gitlab_geo
diff --git a/lib/tasks/gitlab/feature_categories.rake b/lib/tasks/gitlab/feature_categories.rake
new file mode 100644
index 00000000000..cecfaf3cb36
--- /dev/null
+++ b/lib/tasks/gitlab/feature_categories.rake
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+
+namespace :gitlab do
+ namespace :feature_categories do
+ desc 'GitLab | Feature categories | Build index page for groups'
+ task index: :environment do
+ require 'pathname'
+
+ controller_actions = Gitlab::RequestEndpoints
+ .all_controller_actions
+ .each_with_object({}) do |(controller, action), hash|
+ feature_category = controller.feature_category_for_action(action).to_s
+
+ hash[feature_category] ||= []
+ hash[feature_category] << {
+ klass: controller.to_s,
+ action: action,
+ source_location: source_location(controller, action)
+ }
+ end
+
+ endpoints = Gitlab::RequestEndpoints.all_api_endpoints.each_with_object({}) do |route, hash|
+ klass = route.app.options[:for]
+ path = API::Base.path_for_app(route.app)
+ feature_category = klass.feature_category_for_action(path).to_s
+
+ hash[feature_category] ||= []
+ hash[feature_category] << {
+ klass: klass.to_s,
+ action: path,
+ source_location: source_location(klass)
+ }
+ end
+
+ workers = Gitlab::SidekiqConfig.workers_for_all_queues_yml.flatten.each_with_object({}) do |worker, hash|
+ feature_category = worker.get_feature_category.to_s
+
+ next unless worker.klass.name
+
+ hash[feature_category] ||= []
+ hash[feature_category] << {
+ klass: worker.klass.name,
+ source_location: source_location(worker.klass.name)
+ }
+ end
+
+ database_tables = Dir['db/docs/*.yml'].each_with_object({}) do |file, hash|
+ yaml = YAML.safe_load(File.read(file))
+ table_name = yaml['table_name']
+
+ yaml['feature_categories'].each do |feature_category|
+ hash[feature_category] ||= []
+ hash[feature_category] << table_name
+ end
+ end
+
+ puts YAML.dump('controller_actions' => controller_actions,
+ 'api_endpoints' => endpoints,
+ 'sidekiq_workers' => workers,
+ 'database_tables' => database_tables)
+ end
+
+ def source_location(klass, method = nil)
+ file, line =
+ if method && klass.method_defined?(method)
+ klass.instance_method(method).source_location
+ else
+ Kernel.const_source_location(klass.to_s)
+ end
+
+ relative = Pathname.new(file).relative_path_from(Rails.root).to_s
+
+ if relative.starts_with?('../') || relative.starts_with?('/')
+ nil
+ else
+ [relative, line]
+ end
+ end
+ end
+end
diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake
index 161c7dd38ac..4f7053b7629 100644
--- a/lib/tasks/gitlab/info.rake
+++ b/lib/tasks/gitlab/info.rake
@@ -85,11 +85,9 @@ namespace :gitlab do
puts ""
puts "GitLab Shell".color(:yellow)
puts "Version:\t#{Gitlab::Shell.version || "unknown".color(:red)}"
- puts "Repository storage paths:"
- Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- Gitlab.config.repositories.storages.each do |name, repository_storage|
- puts "- #{name}: \t#{repository_storage.legacy_disk_path}"
- end
+ puts "Repository storages:"
+ Gitlab.config.repositories.storages.each do |name, repository_storage|
+ puts "- #{name}: \t#{repository_storage.gitaly_address}"
end
puts "GitLab Shell path:\t\t#{Gitlab.config.gitlab_shell.path}"
end
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
index cf9876366aa..a5dcb23450f 100644
--- a/lib/tasks/gitlab/shell.rake
+++ b/lib/tasks/gitlab/shell.rake
@@ -53,13 +53,11 @@ namespace :gitlab do
path_to_repo = project.repository.path_to_repo
if File.exist?(path_to_repo)
print '-'
- else
- if Gitlab::Shell.new.create_repository(project.repository_storage,
+ elsif Gitlab::Shell.new.create_repository(project.repository_storage,
project.disk_path)
- print '.'
- else
- print 'F'
- end
+ print '.'
+ else
+ print 'F'
end
end
end
@@ -81,7 +79,7 @@ namespace :gitlab do
authorized_keys.clear
- Key.find_in_batches(batch_size: 1000) do |keys|
+ Key.auth.find_in_batches(batch_size: 1000) do |keys|
unless authorized_keys.batch_add_keys(keys)
puts "Failed to add keys...".color(:red)
exit 1
diff --git a/lib/tasks/gitlab/sidekiq.rake b/lib/tasks/gitlab/sidekiq.rake
index dc472305304..34ef4b139c3 100644
--- a/lib/tasks/gitlab/sidekiq.rake
+++ b/lib/tasks/gitlab/sidekiq.rake
@@ -10,21 +10,21 @@ namespace :gitlab do
desc 'GitLab | Sidekiq | Migrate jobs in the scheduled set to new queue names'
task schedule: :environment do
::Gitlab::SidekiqMigrateJobs
- .new(::Gitlab::SidekiqConfig.worker_queue_mappings, logger: Logger.new($stdout) )
+ .new(::Gitlab::SidekiqConfig.worker_queue_mappings, logger: Logger.new($stdout))
.migrate_set('schedule')
end
desc 'GitLab | Sidekiq | Migrate jobs in the retry set to new queue names'
task retry: :environment do
::Gitlab::SidekiqMigrateJobs
- .new(::Gitlab::SidekiqConfig.worker_queue_mappings, logger: Logger.new($stdout) )
+ .new(::Gitlab::SidekiqConfig.worker_queue_mappings, logger: Logger.new($stdout))
.migrate_set('retry')
end
desc 'GitLab | Sidekiq | Migrate jobs in queues outside of routing rules'
task queued: :environment do
::Gitlab::SidekiqMigrateJobs
- .new(::Gitlab::SidekiqConfig.worker_queue_mappings, logger: Logger.new($stdout) )
+ .new(::Gitlab::SidekiqConfig.worker_queue_mappings, logger: Logger.new($stdout))
.migrate_queues
end
end
@@ -130,5 +130,10 @@ namespace :gitlab do
end
end
end
+
+ namespace :queues do
+ desc 'GitLab | Sidekiq | Validate all_queues.yml and sidekiq_queues.yml match worker definitions'
+ task check: ['gitlab:sidekiq:all_queues_yml:check', 'gitlab:sidekiq:sidekiq_queues_yml:check', :environment]
+ end
end
end
diff --git a/lib/tasks/gitlab/tw/codeowners.rake b/lib/tasks/gitlab/tw/codeowners.rake
index 7a2dee3e2e4..ec2ea623e02 100644
--- a/lib/tasks/gitlab/tw/codeowners.rake
+++ b/lib/tasks/gitlab/tw/codeowners.rake
@@ -81,6 +81,10 @@ namespace :tw do
CodeOwnerRule.new('Workspace', '@lciutacu')
].freeze
+ ERRORS_EXCLUDED_FILES = [
+ '/doc/architecture'
+ ].freeze
+
CODEOWNERS_BLOCK_BEGIN = "# Begin rake-managed-docs-block"
CODEOWNERS_BLOCK_END = "# End rake-managed-docs-block"
@@ -105,16 +109,17 @@ namespace :tw do
Dir.glob(path) do |file|
yaml_data = YAML.load_file(file)
document = Document.new(yaml_data['group'], yaml_data['redirect_to'])
+ relative_file = file.delete_prefix(Dir.pwd)
if document.missing_metadata?
- errors << file
+ errors << relative_file unless ERRORS_EXCLUDED_FILES.any? { |element| relative_file.starts_with?(element) }
next
end
writer = writer_for_group(document.group)
next unless writer
- mappings << DocumentOwnerMapping.new(file.delete_prefix(Dir.pwd), writer) if document.has_a_valid_group?
+ mappings << DocumentOwnerMapping.new(relative_file, writer) if document.has_a_valid_group?
end
deduplicated_mappings = Set.new
@@ -139,10 +144,16 @@ namespace :tw do
File.write(codeowners_path, new_codeowners_content)
+ if current_codeowners_content == new_codeowners_content
+ puts "~ CODEOWNERS already up to date".color(:yellow)
+ else
+ puts "✓ CODEOWNERS updated".color(:green)
+ end
+
if errors.present?
- puts "-----"
- puts "ERRORS - the following files are missing the correct metadata:"
- errors.map { |file| puts file.gsub(Dir.pwd, ".") }
+ puts ""
+ puts "✘ Files with missing metadata found:".color(:red)
+ errors.map { |file| puts file }
end
end
end
diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake
index d67ad340007..e87f478ac42 100644
--- a/lib/tasks/gitlab/update_templates.rake
+++ b/lib/tasks/gitlab/update_templates.rake
@@ -24,10 +24,11 @@ namespace :gitlab do
raise "This rake task is not meant for production instances"
end
- admin = User.find_by(admin: true)
+ # Find an admin user with an SSH key
+ admin = User.where(admin: true).joins(:keys).where.not(keys: { id: nil }).take
unless admin
- raise "No admin user could be found"
+ raise "No admin user with SSH key could be found"
end
tmp_namespace_path = "tmp-project-import-#{Time.now.to_i}"
@@ -73,6 +74,8 @@ namespace :gitlab do
Commit SHA: #{commit_sha}
MSG
+ local_remote = project.ssh_url_to_repo
+
Dir.mktmpdir do |tmpdir|
Dir.chdir(tmpdir) do
Gitlab::TaskHelpers.run_command!(['wget', project_archive_uri, '-O', 'archive.tar.gz'])
@@ -80,13 +83,9 @@ namespace :gitlab do
extracted_project_basename = Dir['*/'].first
Dir.chdir(extracted_project_basename) do
Gitlab::TaskHelpers.run_command!(%w(git init --initial-branch=master))
+ Gitlab::TaskHelpers.run_command!(%W(git remote add origin #{local_remote}))
Gitlab::TaskHelpers.run_command!(%w(git add .))
Gitlab::TaskHelpers.run_command!(['git', 'commit', '--author', 'GitLab <root@localhost>', '--message', commit_message])
-
- # Hacky workaround to push to the project in a way that works with both GDK and the test environment
- Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- Gitlab::TaskHelpers.run_command!(['git', 'remote', 'add', 'origin', "file://#{project.repository.raw.path}"])
- end
Gitlab::TaskHelpers.run_command!(['git', 'push', '-u', 'origin', 'master'])
end
end
diff --git a/lib/tasks/gitlab/usage_data.rake b/lib/tasks/gitlab/usage_data.rake
index 159b70cd673..32db5e2dff6 100644
--- a/lib/tasks/gitlab/usage_data.rake
+++ b/lib/tasks/gitlab/usage_data.rake
@@ -51,9 +51,12 @@ namespace :gitlab do
desc 'GitLab | UsageDataMetrics | Generate raw SQL metrics queries for RSpec'
task generate_sql_metrics_queries: :environment do
+ require 'active_support/testing/time_helpers'
+ include ActiveSupport::Testing::TimeHelpers
+
path = Rails.root.join('tmp', 'test')
- queries = Timecop.freeze(2021, 1, 1) do
+ queries = travel_to(Time.utc(2021, 1, 1)) do
Gitlab::Usage::ServicePingReport.for(output: :metrics_queries)
end