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
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/gitlab')
-rw-r--r--lib/tasks/gitlab/db.rake8
-rw-r--r--lib/tasks/gitlab/docs/compile_deprecations.rake29
-rw-r--r--lib/tasks/gitlab/gitaly.rake5
-rw-r--r--lib/tasks/gitlab/graphql.rake4
-rw-r--r--lib/tasks/gitlab/product_intelligence.rake24
-rw-r--r--lib/tasks/gitlab/sidekiq.rake5
-rw-r--r--lib/tasks/gitlab/usage_data.rake28
7 files changed, 70 insertions, 33 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 51f15f5a56a..a6738b01f18 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -118,7 +118,7 @@ namespace :gitlab do
desc 'Create missing dynamic database partitions'
task create_dynamic_partitions: :environment do
- Gitlab::Database::Partitioning::PartitionManager.new.sync_partitions
+ Gitlab::Database::Partitioning.sync_partitions
end
# This is targeted towards deploys and upgrades of GitLab.
@@ -151,6 +151,12 @@ namespace :gitlab do
# initializers here as the application can continue to run while
# a rake task reloads the database schema.
Rake::Task['db:test:load'].enhance do
+ # Due to bug in `db:test:load` if many DBs are used
+ # the `ActiveRecord::Base.connection` might be switched to another one
+ # This is due to `if should_reconnect`:
+ # https://github.com/rails/rails/blob/a81aeb63a007ede2fe606c50539417dada9030c7/activerecord/lib/active_record/railties/databases.rake#L622
+ ActiveRecord::Base.establish_connection :main
+
Rake::Task['gitlab:db:create_dynamic_partitions'].invoke
end
diff --git a/lib/tasks/gitlab/docs/compile_deprecations.rake b/lib/tasks/gitlab/docs/compile_deprecations.rake
new file mode 100644
index 00000000000..0fd43775015
--- /dev/null
+++ b/lib/tasks/gitlab/docs/compile_deprecations.rake
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+namespace :gitlab do
+ namespace :docs do
+ desc "Generate deprecation list from individual files"
+ task :compile_deprecations do
+ require_relative '../../../../tooling/deprecations/docs'
+
+ File.write(Deprecations::Docs.path, Deprecations::Docs.render)
+
+ puts "Deprecations compiled to #{Deprecations::Docs.path}"
+ end
+
+ desc "Check that the deprecation doc is up to date"
+ task :check_deprecations do
+ require_relative '../../../../tooling/deprecations/docs'
+
+ contents = Deprecations::Docs.render
+ doc = File.read(Deprecations::Docs.path)
+
+ if doc == contents
+ puts "Deprecations doc is up to date."
+ else
+ format_output('Deprecations doc is outdated! Please update it by running `bundle exec rake gitlab:docs:compile_deprecations`.')
+ abort
+ end
+ end
+ end
+end
diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake
index 6675439e430..ef58c9339f1 100644
--- a/lib/tasks/gitlab/gitaly.rake
+++ b/lib/tasks/gitlab/gitaly.rake
@@ -15,8 +15,7 @@ namespace :gitlab do
gdk_gitaly_dir = ENV.fetch('GDK_GITALY', Rails.root.join('../gitaly'))
# Our test setup expects a git repo, so clone rather than copy
- version = Gitlab::GitalyClient.expected_server_version
- checkout_or_clone_version(version: version, repo: gdk_gitaly_dir, target_dir: args.dir, clone_opts: %w[--depth 1])
+ clone_repo(gdk_gitaly_dir, args.dir, clone_opts: %w[--depth 1]) unless Dir.exist?(args.dir)
# We assume the GDK gitaly already compiled binaries
build_dir = File.join(gdk_gitaly_dir, '_build')
@@ -31,7 +30,7 @@ namespace :gitlab do
FileUtils.cp_r(ruby_bundle_file, args.dir)
gitaly_binary = File.join(build_dir, 'bin', 'gitaly')
- warn_gitaly_out_of_date!(gitaly_binary, version)
+ warn_gitaly_out_of_date!(gitaly_binary, Gitlab::GitalyClient.expected_server_version)
rescue Errno::ENOENT => e
puts "Could not copy files, did you run `gdk update`? Error: #{e.message}"
diff --git a/lib/tasks/gitlab/graphql.rake b/lib/tasks/gitlab/graphql.rake
index 52c5c680292..b9137aa0d4c 100644
--- a/lib/tasks/gitlab/graphql.rake
+++ b/lib/tasks/gitlab/graphql.rake
@@ -111,7 +111,7 @@ namespace :gitlab do
desc 'GitLab | GraphQL | Generate GraphQL docs'
task compile_docs: [:environment, :enable_feature_flags] do
- renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options)
+ renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, **render_options)
renderer.write
@@ -120,7 +120,7 @@ namespace :gitlab do
desc 'GitLab | GraphQL | Check if GraphQL docs are up to date'
task check_docs: [:environment, :enable_feature_flags] do
- renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options)
+ renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, **render_options)
doc = File.read(Rails.root.join(OUTPUT_DIR, 'index.md'))
diff --git a/lib/tasks/gitlab/product_intelligence.rake b/lib/tasks/gitlab/product_intelligence.rake
deleted file mode 100644
index 329cd9c8c2a..00000000000
--- a/lib/tasks/gitlab/product_intelligence.rake
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-namespace :gitlab do
- namespace :product_intelligence do
- # @example
- # bundle exec rake gitlab:product_intelligence:activate_metrics MILESTONE=14.0
-
- desc 'GitLab | Product Intelligence | Update milestone metrics status to data_available'
- task activate_metrics: :environment do
- milestone = ENV['MILESTONE']
- raise "Please supply the MILESTONE env var".color(:red) unless milestone.present?
-
- Gitlab::Usage::MetricDefinition.definitions.values.each do |metric|
- next if metric.attributes[:milestone] != milestone || metric.attributes[:status] != 'implemented'
-
- metric.attributes[:status] = 'data_available'
- path = metric.path
- File.open(path, "w") { |file| file << metric.to_h.deep_stringify_keys.to_yaml }
- end
-
- puts "Task completed successfully"
- end
- end
-end
diff --git a/lib/tasks/gitlab/sidekiq.rake b/lib/tasks/gitlab/sidekiq.rake
index d3060d92e88..90ed91221ae 100644
--- a/lib/tasks/gitlab/sidekiq.rake
+++ b/lib/tasks/gitlab/sidekiq.rake
@@ -86,9 +86,8 @@ namespace :gitlab do
# 3: high priority
# 5: _super_ high priority, this should only be used for _very_ important queues
#
- # As per http://stackoverflow.com/a/21241357/290102 the formula for calculating
- # the likelihood of a job being popped off a queue (given all queues have work
- # to perform) is:
+ # The formula for calculating the likelihood of a job being popped off a queue
+ # (given all queues have work to perform) is:
#
# chance = (queue weight / total weight of all queues) * 100
BANNER
diff --git a/lib/tasks/gitlab/usage_data.rake b/lib/tasks/gitlab/usage_data.rake
index ddd3424acda..35ddc627389 100644
--- a/lib/tasks/gitlab/usage_data.rake
+++ b/lib/tasks/gitlab/usage_data.rake
@@ -28,5 +28,33 @@ namespace :gitlab do
task generate_from_yaml: :environment do
puts Gitlab::Json.pretty_generate(Gitlab::UsageDataMetrics.uncached_data)
end
+
+ desc 'GitLab | UsageDataMetrics | Generate known_events/ci_templates.yml based on template definitions'
+ task generate_ci_template_events: :environment do
+ banner = <<~BANNER
+ # This file is generated automatically by
+ # bin/rake gitlab:usage_data:generate_ci_template_events
+ #
+ # Do not edit it manually!
+ BANNER
+
+ repository_includes = ci_template_includes_hash(:repository_source)
+ auto_devops_jobs_includes = ci_template_includes_hash(:auto_devops_source, 'Jobs')
+ auto_devops_security_includes = ci_template_includes_hash(:auto_devops_source, 'Security')
+ all_includes = [*repository_includes, *auto_devops_jobs_includes, *auto_devops_security_includes]
+
+ File.write(Gitlab::UsageDataCounters::CiTemplateUniqueCounter::KNOWN_EVENTS_FILE_PATH, banner + YAML.dump(all_includes).gsub(/ *$/m, ''))
+ end
+
+ def ci_template_includes_hash(source, template_directory = nil)
+ Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_templates("lib/gitlab/ci/templates/#{template_directory}").map do |template|
+ {
+ 'name' => Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_template_event_name("#{template_directory}/#{template}", source),
+ 'category' => 'ci_templates',
+ 'redis_slot' => Gitlab::UsageDataCounters::CiTemplateUniqueCounter::REDIS_SLOT,
+ 'aggregation' => 'weekly'
+ }
+ end
+ end
end
end