summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /lib/tasks
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
downloadgitlab-ce-71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e.tar.gz
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/artifacts/migrate.rake6
-rw-r--r--lib/tasks/gitlab/backup.rake10
-rw-r--r--lib/tasks/gitlab/cleanup.rake3
-rw-r--r--lib/tasks/gitlab/db.rake122
-rw-r--r--lib/tasks/gitlab/db/lock_writes.rake51
-rw-r--r--lib/tasks/gitlab/dependency_proxy/migrate.rake2
-rw-r--r--lib/tasks/gitlab/incoming_email.rake23
-rw-r--r--lib/tasks/gitlab/service_desk_email.rake23
-rw-r--r--lib/tasks/gitlab/tw/codeowners.rake33
-rw-r--r--lib/tasks/import.rake53
-rw-r--r--lib/tasks/lint.rake5
-rw-r--r--lib/tasks/migrate/schema_check.rake6
12 files changed, 199 insertions, 138 deletions
diff --git a/lib/tasks/gitlab/artifacts/migrate.rake b/lib/tasks/gitlab/artifacts/migrate.rake
index 084e7c78906..47b356aa6e6 100644
--- a/lib/tasks/gitlab/artifacts/migrate.rake
+++ b/lib/tasks/gitlab/artifacts/migrate.rake
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'logger'
-require 'resolv-replace'
-
desc 'GitLab | Artifacts | Migrate files for artifacts to comply with new storage format'
namespace :gitlab do
+ require 'logger'
+ require 'resolv-replace'
+
namespace :artifacts do
task migrate: :environment do
logger = Logger.new($stdout)
diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake
index 6647a10898f..06a032316c5 100644
--- a/lib/tasks/gitlab/backup.rake
+++ b/lib/tasks/gitlab/backup.rake
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'active_record/fixtures'
-
namespace :gitlab do
+ require 'active_record/fixtures'
+
namespace :backup do
PID = Process.pid.freeze
PID_FILE = "#{Rails.application.root}/tmp/backup_restore.pid"
@@ -44,15 +44,13 @@ namespace :gitlab do
namespace :db do
task create: :gitlab_environment do
lock do
- Backup::Manager.new(progress).run_create_task('main_db')
- Backup::Manager.new(progress).run_create_task('ci_db')
+ Backup::Manager.new(progress).run_create_task('db')
end
end
task restore: :gitlab_environment do
lock do
- Backup::Manager.new(progress).run_restore_task('main_db')
- Backup::Manager.new(progress).run_restore_task('ci_db')
+ Backup::Manager.new(progress).run_restore_task('db')
end
end
end
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake
index 49d2d9fed03..1753483b091 100644
--- a/lib/tasks/gitlab/cleanup.rake
+++ b/lib/tasks/gitlab/cleanup.rake
@@ -1,7 +1,8 @@
# frozen_string_literal: true
-require 'set'
namespace :gitlab do
+ require 'set'
+
namespace :cleanup do
desc "GitLab | Cleanup | Block users that have been removed in LDAP"
task block_removed_ldap_users: :gitlab_environment do
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 9c92aa5eb28..c4dc7b938cc 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -283,6 +283,36 @@ namespace :gitlab do
end
end
+ namespace :execute_async_index_operations do
+ each_database(databases) do |database_name|
+ task database_name, [:pick] => :environment do |_, args|
+ args.with_defaults(pick: 2)
+
+ if Feature.disabled?(:database_async_index_operations, type: :ops)
+ puts <<~NOTE.color(:yellow)
+ Note: database async index operations feature is currently disabled.
+
+ Enable with: Feature.enable(:database_async_index_operations)
+ NOTE
+ exit
+ end
+
+ Gitlab::Database::EachDatabase.each_database_connection(only: database_name) do
+ Gitlab::Database::AsyncIndexes.execute_pending_actions!(how_many: args[:pick].to_i)
+ end
+ end
+ end
+
+ task :all, [:pick] => :environment do |_, args|
+ default_pick = Gitlab.dev_or_test_env? ? 1000 : 2
+ args.with_defaults(pick: default_pick)
+
+ each_database(databases) do |database_name|
+ Rake::Task["gitlab:db:execute_async_index_operations:#{database_name}"].invoke(args[:pick])
+ end
+ end
+ end
+
desc 'Check if there have been user additions to the database'
task active: :environment do
if ActiveRecord::Base.connection.migration_context.needs_migration?
@@ -306,7 +336,7 @@ namespace :gitlab do
namespace :migration_testing do
# Not possible to import Gitlab::Database::DATABASE_NAMES here
# Specs verify that a task exists for each entry in that array.
- all_databases = %i[main ci]
+ all_databases = %i[main ci main_clusterwide]
task up: :environment do
Gitlab::Database::Migrations::Runner.up(database: 'main', legacy_mode: true).run
@@ -399,64 +429,73 @@ namespace :gitlab do
namespace :dictionary do
DB_DOCS_PATH = File.join(Rails.root, 'db', 'docs')
+ EE_DICTIONARY_PATH = File.join(Rails.root, 'ee', 'db', 'docs')
desc 'Generate database docs yaml'
task generate: :environment do
- FileUtils.mkdir_p(DB_DOCS_PATH) unless Dir.exist?(DB_DOCS_PATH)
+ FileUtils.mkdir_p(DB_DOCS_PATH)
+ FileUtils.mkdir_p(EE_DICTIONARY_PATH) if Gitlab.ee?
Rails.application.eager_load!
- tables = Gitlab::Database.database_base_models.flat_map { |_, m| m.connection.tables }
+ version = Gem::Version.new(File.read('VERSION'))
+ milestone = version.release.segments[0..1].join('.')
- views = Gitlab::Database.database_base_models.flat_map { |_, m| m.connection.views }
+ classes = {}
- sources = tables + views
+ Gitlab::Database.database_base_models.each do |_, model_class|
+ tables = model_class.connection.tables
- classes = sources.index_with { [] }
+ views = model_class.connection.views
+
+ sources = tables + views
+
+ model_classes = sources.index_with { [] }
+
+ classes.merge!(model_classes) { |_, sources, new_sources| sources + new_sources }
- Gitlab::Database.database_base_models.each do |_, model_class|
model_class
.descendants
.reject(&:abstract_class)
.reject { |c| c.name =~ /^(?:EE::)?Gitlab::(?:BackgroundMigration|DatabaseImporters)::/ }
.reject { |c| c.name =~ /^HABTM_/ }
.each { |c| classes[c.table_name] << c.name if classes.has_key?(c.table_name) }
- end
- version = Gem::Version.new(File.read('VERSION'))
- milestone = version.release.segments[0..1].join('.')
+ sources.each do |source_name|
+ next if source_name.start_with?('_test_') # Ignore test tables
- sources.each do |source_name|
- file = dictionary_file_path(source_name, views)
- key_name = "#{data_source_type(source_name, views)}_name"
+ database = model_class.connection_db_config.name
+ file = dictionary_file_path(source_name, views, database)
+ key_name = "#{data_source_type(source_name, views)}_name"
- table_metadata = {
- key_name => source_name,
- 'classes' => classes[source_name]&.sort&.uniq,
- 'feature_categories' => [],
- 'description' => nil,
- 'introduced_by_url' => nil,
- 'milestone' => milestone
- }
+ table_metadata = {
+ key_name => source_name,
+ 'classes' => classes[source_name]&.sort&.uniq,
+ 'feature_categories' => [],
+ 'description' => nil,
+ 'introduced_by_url' => nil,
+ 'milestone' => milestone
+ }
- if File.exist?(file)
- outdated = false
+ if File.exist?(file)
+ outdated = false
- existing_metadata = YAML.safe_load(File.read(file))
+ existing_metadata = YAML.safe_load(File.read(file))
- if existing_metadata[key_name] != table_metadata[key_name]
- existing_metadata[key_name] = table_metadata[key_name]
- outdated = true
- end
+ if existing_metadata[key_name] != table_metadata[key_name]
+ existing_metadata[key_name] = table_metadata[key_name]
+ outdated = true
+ end
- if existing_metadata['classes'].sort != table_metadata['classes'].sort
- existing_metadata['classes'] = table_metadata['classes']
- outdated = true
- end
+ if existing_metadata['classes'] && existing_metadata['classes'].sort != table_metadata['classes'].sort
+ existing_metadata['classes'] = table_metadata['classes']
+ outdated = true
+ end
- File.write(file, existing_metadata.to_yaml) if outdated
- else
- File.write(file, table_metadata.to_yaml)
+ File.write(file, existing_metadata.to_yaml) if outdated
+ else
+ File.write(file, table_metadata.to_yaml)
+ end
end
end
end
@@ -469,16 +508,17 @@ namespace :gitlab do
'table'
end
- def dictionary_file_path(source_name, views)
+ def dictionary_file_path(source_name, views, database)
sub_directory = views.include?(source_name) ? 'views' : ''
- File.join(DB_DOCS_PATH, sub_directory, "#{source_name}.yml")
+ path = database == 'geo' ? EE_DICTIONARY_PATH : DB_DOCS_PATH
+
+ File.join(path, sub_directory, "#{source_name}.yml")
end
- # Temporary disable this, see https://gitlab.com/gitlab-org/gitlab/-/merge_requests/85760#note_998452069
- # Rake::Task['db:migrate'].enhance do
- # Rake::Task['gitlab:db:dictionary:generate'].invoke if Rails.env.development?
- # end
+ Rake::Task['db:migrate'].enhance do
+ Rake::Task['gitlab:db:dictionary:generate'].invoke if Rails.env.development?
+ end
end
end
end
diff --git a/lib/tasks/gitlab/db/lock_writes.rake b/lib/tasks/gitlab/db/lock_writes.rake
index 212d60a7231..59478d47d12 100644
--- a/lib/tasks/gitlab/db/lock_writes.rake
+++ b/lib/tasks/gitlab/db/lock_writes.rake
@@ -4,49 +4,22 @@ namespace :gitlab do
namespace :db do
desc "GitLab | DB | Install prevent write triggers on all databases"
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::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
-
- lock_writes_manager = Gitlab::Database::LockWritesManager.new(
- table_name: table_name,
- connection: connection,
- database_name: database_name,
- with_retries: true,
- logger: Logger.new($stdout),
- dry_run: ENV['DRY_RUN'] == 'true'
- )
-
- if schemas_for_connection.include?(schema_name.to_sym)
- lock_writes_manager.unlock_writes
- else
- lock_writes_manager.lock_writes
- end
- end
- end
+ logger = Logger.new($stdout)
+ logger.level = Gitlab::Utils.to_boolean(ENV['VERBOSE']) ? Logger::INFO : Logger::WARN
+ Gitlab::Database::TablesLocker.new(
+ logger: logger,
+ dry_run: Gitlab::Utils.to_boolean(ENV['DRY_RUN'], default: false)
+ ).lock_writes
end
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::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
-
- lock_writes_manager = Gitlab::Database::LockWritesManager.new(
- table_name: table_name,
- connection: connection,
- database_name: database_name,
- with_retries: true,
- logger: Logger.new($stdout)
- )
-
- lock_writes_manager.unlock_writes
- end
- end
+ logger = Logger.new($stdout)
+ logger.level = Gitlab::Utils.to_boolean(ENV['VERBOSE']) ? Logger::INFO : Logger::WARN
+ Gitlab::Database::TablesLocker.new(
+ logger: logger,
+ dry_run: Gitlab::Utils.to_boolean(ENV['DRY_RUN'], default: false)
+ ).unlock_writes
end
end
end
diff --git a/lib/tasks/gitlab/dependency_proxy/migrate.rake b/lib/tasks/gitlab/dependency_proxy/migrate.rake
index fa35eacc59d..7a4b8800c34 100644
--- a/lib/tasks/gitlab/dependency_proxy/migrate.rake
+++ b/lib/tasks/gitlab/dependency_proxy/migrate.rake
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require 'logger'
-
desc "GitLab | Dependency Proxy | Migrate dependency proxy files to remote storage"
namespace :gitlab do
namespace :dependency_proxy do
diff --git a/lib/tasks/gitlab/incoming_email.rake b/lib/tasks/gitlab/incoming_email.rake
new file mode 100644
index 00000000000..eaceeb91ad0
--- /dev/null
+++ b/lib/tasks/gitlab/incoming_email.rake
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+namespace :gitlab do
+ namespace :incoming_email do
+ namespace :secret do
+ desc 'GitLab | Incoming Email | Secret | Write Incoming Email secrets'
+ task write: [:environment] do
+ content = $stdin.tty? ? $stdin.gets : $stdin.read
+ Gitlab::EncryptedIncomingEmailCommand.write(content)
+ end
+
+ desc 'GitLab | Incoming Email | Secret | Edit Incoming Email secrets'
+ task edit: [:environment] do
+ Gitlab::EncryptedIncomingEmailCommand.edit
+ end
+
+ desc 'GitLab | Incoming Email | Secret | Show Incoming Email secrets'
+ task show: [:environment] do
+ Gitlab::EncryptedIncomingEmailCommand.show
+ end
+ end
+ end
+end
diff --git a/lib/tasks/gitlab/service_desk_email.rake b/lib/tasks/gitlab/service_desk_email.rake
new file mode 100644
index 00000000000..39c9d40bf5c
--- /dev/null
+++ b/lib/tasks/gitlab/service_desk_email.rake
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+namespace :gitlab do
+ namespace :service_desk_email do
+ namespace :secret do
+ desc 'GitLab | Service Desk Email | Secret | Write Service Desk Email secrets'
+ task write: [:environment] do
+ content = $stdin.tty? ? $stdin.gets : $stdin.read
+ Gitlab::EncryptedServiceDeskEmailCommand.write(content)
+ end
+
+ desc 'GitLab | Service Desk Email | Secret | Edit Service Desk Email secrets'
+ task edit: [:environment] do
+ Gitlab::EncryptedServiceDeskEmailCommand.edit
+ end
+
+ desc 'GitLab | Service Desk Email | Secret | Show Service Desk Email secrets'
+ task show: [:environment] do
+ Gitlab::EncryptedServiceDeskEmailCommand.show
+ end
+ end
+ end
+end
diff --git a/lib/tasks/gitlab/tw/codeowners.rake b/lib/tasks/gitlab/tw/codeowners.rake
index b3559bde988..77f5eb87725 100644
--- a/lib/tasks/gitlab/tw/codeowners.rake
+++ b/lib/tasks/gitlab/tw/codeowners.rake
@@ -14,7 +14,7 @@ namespace :tw do
end
def directory
- @directory ||= File.dirname(path)
+ @directory ||= "#{File.dirname(path)}/"
end
end
@@ -26,9 +26,10 @@ namespace :tw do
CodeOwnerRule.new('Certify', '@msedlakjakubowski'),
CodeOwnerRule.new('Code Review', '@aqualls'),
CodeOwnerRule.new('Compliance', '@eread'),
+ CodeOwnerRule.new('Commerce Integrations', '@drcatherinepope'),
CodeOwnerRule.new('Composition Analysis', '@rdickenson'),
CodeOwnerRule.new('Configure', '@phillipwells'),
- CodeOwnerRule.new('Container Registry', '@claytoncornell'),
+ CodeOwnerRule.new('Container Registry', '@dianalogan'),
CodeOwnerRule.new('Contributor Experience', '@eread'),
CodeOwnerRule.new('Conversion', '@kpaizee'),
CodeOwnerRule.new('Database', '@aqualls'),
@@ -50,15 +51,15 @@ namespace :tw do
CodeOwnerRule.new('Knowledge', '@aqualls'),
CodeOwnerRule.new('Application Performance', '@jglassman1'),
CodeOwnerRule.new('Monitor', '@msedlakjakubowski'),
- CodeOwnerRule.new('Observability', '@msedlakjakubowski'),
+ CodeOwnerRule.new('Observability', '@drcatherinepope'),
CodeOwnerRule.new('Optimize', '@lciutacu'),
- CodeOwnerRule.new('Package Registry', '@claytoncornell'),
+ CodeOwnerRule.new('Package Registry', '@dianalogan'),
CodeOwnerRule.new('Pipeline Authoring', '@marcel.amirault'),
- CodeOwnerRule.new('Pipeline Execution', '@marcel.amirault'),
+ CodeOwnerRule.new('Pipeline Execution', '@drcatherinepope'),
CodeOwnerRule.new('Pipeline Insights', '@marcel.amirault'),
CodeOwnerRule.new('Portfolio Management', '@msedlakjakubowski'),
CodeOwnerRule.new('Product Analytics', '@lciutacu'),
- CodeOwnerRule.new('Product Intelligence', '@claytoncornell'),
+ CodeOwnerRule.new('Product Intelligence', '@dianalogan'),
CodeOwnerRule.new('Product Planning', '@msedlakjakubowski'),
CodeOwnerRule.new('Project Management', '@msedlakjakubowski'),
CodeOwnerRule.new('Provision', '@fneill'),
@@ -69,15 +70,15 @@ namespace :tw do
CodeOwnerRule.new('Runner', '@fneill'),
CodeOwnerRule.new('Runner SaaS', '@fneill'),
CodeOwnerRule.new('Pods', '@jglassman1'),
- CodeOwnerRule.new('Security Policies', '@claytoncornell'),
+ CodeOwnerRule.new('Security Policies', '@dianalogan'),
CodeOwnerRule.new('Source Code', '@aqualls'),
CodeOwnerRule.new('Static Analysis', '@rdickenson'),
CodeOwnerRule.new('Style Guide', '@sselhorn'),
CodeOwnerRule.new('Testing', '@eread'),
- CodeOwnerRule.new('Threat Insights', '@claytoncornell'),
+ CodeOwnerRule.new('Threat Insights', '@dianalogan'),
CodeOwnerRule.new('Tutorials', '@kpaizee'),
CodeOwnerRule.new('Utilization', '@fneill'),
- CodeOwnerRule.new('Vulnerability Research', '@claytoncornell'),
+ CodeOwnerRule.new('Vulnerability Research', '@dianalogan'),
CodeOwnerRule.new('Organization', '@lciutacu')
].freeze
@@ -122,16 +123,20 @@ namespace :tw do
mappings << DocumentOwnerMapping.new(relative_file, writer) if document.has_a_valid_group?
end
- deduplicated_mappings = Set.new
-
- mappings.each do |mapping|
+ transformed_mappings = mappings.map do |mapping|
if mapping.writer_owns_directory?(mappings)
- deduplicated_mappings.add("#{mapping.directory}/ #{mapping.writer}")
+ DocumentOwnerMapping.new(mapping.directory, mapping.writer)
else
- deduplicated_mappings.add("#{mapping.path} #{mapping.writer}")
+ DocumentOwnerMapping.new(mapping.path, mapping.writer)
end
end
+ deduplicated_mappings = Set.new
+
+ transformed_mappings
+ .reject { |mapping| transformed_mappings.any? { |m| m.path == mapping.directory && m.writer == mapping.writer } }
+ .each { |mapping| deduplicated_mappings.add("#{mapping.path} #{mapping.writer}") }
+
new_docs_owners = deduplicated_mappings.sort.join("\n")
codeowners_path = Rails.root.join('.gitlab/CODEOWNERS')
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index c93be95e2e0..d2056338350 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -4,8 +4,8 @@ require 'benchmark'
require 'rainbow/ext/string'
class GithubImport
- def self.run!(*args)
- new(*args).run!
+ def self.run!(...)
+ new(...).run!
end
def initialize(token, gitlab_username, project_path, extras)
@@ -35,8 +35,8 @@ class GithubImport
private
def show_warning!
- puts "This will import GitHub #{@repo.full_name.bright} into GitLab #{@project_path.bright} as #{@current_user.name}"
- puts "Permission checks are ignored. Press any key to continue.".color(:red)
+ puts "This will import GitHub #{@repo[:full_name].bright} into GitLab #{@project_path.bright} as #{@current_user.name}"
+ puts 'Permission checks are ignored. Press any key to continue.'.color(:red)
$stdin.getch
@@ -57,43 +57,34 @@ class GithubImport
end
def new_project
- Project.transaction do
- namespace_path, _sep, name = @project_path.rpartition('/')
- namespace = find_or_create_namespace(namespace_path)
+ namespace_path, _sep, project_name = @project_path.rpartition('/')
+ target_namespace = Namespace.find_by_full_path(namespace_path)
+
+ raise 'Namespace or group to import repository into does not exist.' unless target_namespace
+ Project.transaction do
project = Projects::CreateService.new(
@current_user,
- name: name,
- path: name,
- description: @repo.description,
- namespace_id: namespace.id,
+ name: project_name,
+ path: project_name,
+ description: @repo[:description],
+ namespace_id: target_namespace.id,
visibility_level: visibility_level,
- skip_wiki: @repo.has_wiki
+ skip_wiki: @repo[:has_wiki]
).execute
project.update!(
import_type: 'github',
- import_source: @repo.full_name,
- import_url: @repo.clone_url.sub('://', "://#{@options[:token]}@")
+ import_source: @repo[:full_name],
+ import_url: @repo[:clone_url].sub('://', "://#{@options[:token]}@")
)
project
end
end
- def find_or_create_namespace(names)
- return @current_user.namespace if names == @current_user.namespace_path
- return @current_user.namespace unless @current_user.can_create_group?
-
- Groups::NestedCreateService.new(@current_user, group_path: names).execute
- end
-
- def full_path_namespace(names)
- @full_path_namespace ||= Namespace.find_by_full_path(names)
- end
-
def visibility_level
- @repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.current_application_settings.default_project_visibility
+ @repo[:private] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.current_application_settings.default_project_visibility
end
end
@@ -110,17 +101,17 @@ class GithubRepos
return found_github_repo if @github_repo
repos.each do |repo|
- print "ID: #{repo.id.to_s.bright}".color(:green)
- print "\tName: #{repo.full_name}\n".color(:green)
+ print "ID: #{repo[:id].to_s.bright}".color(:green)
+ print "\tName: #{repo[:full_name]}\n".color(:green)
end
print 'ID? '.bright
- repos.find { |repo| repo.id == repo_id }
+ repos.find { |repo| repo[:id] == repo_id }
end
def found_github_repo
- repos.find { |repo| repo.full_name == @github_repo }
+ repos.find { |repo| repo[:full_name] == @github_repo }
end
def repo_id
@@ -128,7 +119,7 @@ class GithubRepos
end
def repos
- @client.octokit.list_repositories
+ @repos ||= @client.repos
end
end
diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake
index 62d31803f6e..6e50e417776 100644
--- a/lib/tasks/lint.rake
+++ b/lib/tasks/lint.rake
@@ -34,6 +34,11 @@ unless Rails.env.production?
exit(1)
end
+ desc "GitLab | Lint | Lint docs Markdown files"
+ task :markdown do
+ sh "./scripts/lint-doc.sh"
+ end
+
desc "GitLab | Lint | Run several lint checks"
task :all do
status = 0
diff --git a/lib/tasks/migrate/schema_check.rake b/lib/tasks/migrate/schema_check.rake
index 76f1f23c7bd..e15304afcff 100644
--- a/lib/tasks/migrate/schema_check.rake
+++ b/lib/tasks/migrate/schema_check.rake
@@ -6,10 +6,14 @@ task schema_version_check: :environment do
schema_version = ActiveRecord::Migrator.current_version
+ minimum_migration_version = Gitlab::Database.read_minimum_migration_version
+
+ raise 'Unable to find any migration files in db/migrate.' if minimum_migration_version.nil?
+
# Ensure migrations are being run from a supported schema version
# A schema verison of 0 is a fresh db, and should be safe to run migrations
# But a database with existing migrations less than our min version is not
- if schema_version > 0 && schema_version < Gitlab::Database::MIN_SCHEMA_VERSION
+ if schema_version > 0 && schema_version < minimum_migration_version
raise "Your current database version is too old to be migrated. " \
"You should upgrade to GitLab #{Gitlab::Database::MIN_SCHEMA_GITLAB_VERSION} before moving to this version. " \
"Please see https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations"