summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 08:43:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 08:43:02 +0000
commitd9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch)
tree2341ef426af70ad1e289c38036737e04b0aa5007 /lib/tasks
parentd6e514dd13db8947884cd58fe2a9c2a063400a9b (diff)
downloadgitlab-ce-d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb.tar.gz
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/frontend.rake23
-rw-r--r--lib/tasks/gitlab/assets.rake2
-rw-r--r--lib/tasks/gitlab/db.rake35
-rw-r--r--lib/tasks/gitlab/packages/composer.rake20
-rw-r--r--lib/tasks/gitlab/snowplow.rake11
-rw-r--r--lib/tasks/gitlab/usage_data.rake26
-rw-r--r--lib/tasks/import.rake13
-rw-r--r--lib/tasks/lint.rake8
-rw-r--r--lib/tasks/rubocop.rake3
9 files changed, 64 insertions, 77 deletions
diff --git a/lib/tasks/frontend.rake b/lib/tasks/frontend.rake
index b2d2c4e3f2b..e768c42736d 100644
--- a/lib/tasks/frontend.rake
+++ b/lib/tasks/frontend.rake
@@ -4,6 +4,11 @@ unless Rails.env.production?
namespace :frontend do
desc 'GitLab | Frontend | Generate fixtures for JavaScript tests'
RSpec::Core::RakeTask.new(:fixtures, [:pattern]) do |t, args|
+ require 'fileutils'
+ require_relative '../../spec/support/helpers/javascript_fixtures_helpers'
+
+ FileUtils.rm_r(JavaScriptFixturesHelpers.fixture_root_path, force: true)
+
directories = %w[spec]
directories << 'ee/spec' if Gitlab.ee?
directory_glob = "{#{directories.join(',')}}"
@@ -13,12 +18,30 @@ 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 db10428e0dc..cbafed16852 100644
--- a/lib/tasks/gitlab/assets.rake
+++ b/lib/tasks/gitlab/assets.rake
@@ -7,6 +7,7 @@ module Tasks
module Assets
FOSS_ASSET_FOLDERS = %w[app/assets fixtures/emojis vendor/assets/javascripts].freeze
EE_ASSET_FOLDERS = %w[ee/app/assets].freeze
+ JH_ASSET_FOLDERS = %w[jh/app/assets].freeze
JS_ASSET_PATTERNS = %w[*.js config/**/*.js].freeze
JS_ASSET_FILES = %w[package.json yarn.lock].freeze
MASTER_MD5_HASH_FILE = 'master-assets-hash.txt'
@@ -28,6 +29,7 @@ module Tasks
def self.assets_impacting_webpack_compilation
assets_folders = FOSS_ASSET_FOLDERS
assets_folders += EE_ASSET_FOLDERS if ::Gitlab.ee?
+ assets_folders += JH_ASSET_FOLDERS if ::Gitlab.jh?
asset_files = Dir.glob(JS_ASSET_PATTERNS)
asset_files += JS_ASSET_FILES
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index a6738b01f18..e2647021914 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -211,37 +211,16 @@ namespace :gitlab do
exit 0
end
- desc 'Run migrations with instrumentation'
- task migration_testing: :environment do
- result_dir = Gitlab::Database::Migrations::Instrumentation::RESULT_DIR
- FileUtils.mkdir_p(result_dir)
-
- verbose_was = ActiveRecord::Migration.verbose
- ActiveRecord::Migration.verbose = true
-
- ctx = ActiveRecord::Base.connection.migration_context
- existing_versions = ctx.get_all_versions.to_set
-
- pending_migrations = ctx.migrations.reject do |migration|
- existing_versions.include?(migration.version)
+ namespace :migration_testing do
+ desc 'Run migrations with instrumentation'
+ task up: :environment do
+ Gitlab::Database::Migrations::Runner.up.run
end
- instrumentation = Gitlab::Database::Migrations::Instrumentation.new
-
- pending_migrations.each do |migration|
- instrumentation.observe(version: migration.version, name: migration.name) do
- ActiveRecord::Migrator.new(:up, ctx.migrations, ctx.schema_migration, migration.version).run
- end
- end
- ensure
- if instrumentation
- File.open(File.join(result_dir, Gitlab::Database::Migrations::Instrumentation::STATS_FILENAME), 'wb+') do |io|
- io << instrumentation.observations.to_json
- end
+ desc 'Run down migrations in current branch with instrumentation'
+ task down: :environment do
+ Gitlab::Database::Migrations::Runner.down.run
end
-
- ActiveRecord::Base.clear_cache!
- ActiveRecord::Migration.verbose = verbose_was
end
desc 'Run all pending batched migrations'
diff --git a/lib/tasks/gitlab/packages/composer.rake b/lib/tasks/gitlab/packages/composer.rake
deleted file mode 100644
index 97f1da0ff63..00000000000
--- a/lib/tasks/gitlab/packages/composer.rake
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-require 'logger'
-
-desc "GitLab | Packages | Build composer cache"
-namespace :gitlab do
- namespace :packages do
- task build_composer_cache: :environment do
- logger = Logger.new($stdout)
- logger.info('Starting to build composer cache files')
-
- ::Packages::Package.composer.find_in_batches do |packages|
- packages.group_by { |pkg| [pkg.project_id, pkg.name] }.each do |(project_id, name), packages|
- logger.info("Building cache for #{project_id} -> #{name}")
- Gitlab::Composer::Cache.new(project: packages.first.project, name: name).execute
- end
- end
- end
- end
-end
diff --git a/lib/tasks/gitlab/snowplow.rake b/lib/tasks/gitlab/snowplow.rake
deleted file mode 100644
index 278ba4a471c..00000000000
--- a/lib/tasks/gitlab/snowplow.rake
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-namespace :gitlab do
- namespace :snowplow do
- desc 'GitLab | Snowplow | Generate event dictionary'
- task generate_event_dictionary: :environment do
- items = Gitlab::Tracking::EventDefinition.definitions
- Gitlab::Tracking::Docs::Renderer.new(items).write
- end
- end
-end
diff --git a/lib/tasks/gitlab/usage_data.rake b/lib/tasks/gitlab/usage_data.rake
index 35ddc627389..694c49240ed 100644
--- a/lib/tasks/gitlab/usage_data.rake
+++ b/lib/tasks/gitlab/usage_data.rake
@@ -41,20 +41,32 @@ namespace :gitlab do
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]
+ all_includes = [
+ *repository_includes,
+ ci_template_event('p_ci_templates_implicit_auto_devops'),
+ *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'
- }
+ expanded_template_name = Gitlab::UsageDataCounters::CiTemplateUniqueCounter.expand_template_name("#{template_directory}/#{template}")
+ event_name = Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_template_event_name(expanded_template_name, source)
+
+ ci_template_event(event_name)
end
end
+
+ def ci_template_event(event_name)
+ {
+ 'name' => event_name,
+ 'category' => 'ci_templates',
+ 'redis_slot' => Gitlab::UsageDataCounters::CiTemplateUniqueCounter::REDIS_SLOT,
+ 'aggregation' => 'weekly'
+ }
+ end
end
end
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index b7a5cbe44b9..c93be95e2e0 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -46,21 +46,14 @@ class GithubImport
def import!
@project.import_state.force_start
- import_success = false
-
timings = Benchmark.measure do
- import_success = Gitlab::GithubImport::SequentialImporter
+ Gitlab::GithubImport::SequentialImporter
.new(@project, token: @options[:token])
.execute
end
- if import_success
- @project.after_import
- puts "Import finished. Timings: #{timings}".color(:green)
- else
- puts "Import was not successful. Errors were as follows:"
- puts @project.import_state.last_error
- end
+ @project.after_import
+ puts "Import finished. Timings: #{timings}".color(:green)
end
def new_project
diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake
index 976ec089011..62d31803f6e 100644
--- a/lib/tasks/lint.rake
+++ b/lib/tasks/lint.rake
@@ -14,6 +14,14 @@ unless Rails.env.production?
Gitlab::Utils::Override.verify!
end
+ desc "GitLab | Lint | Static verification with database"
+ task static_verification_with_database: %w[
+ lint:static_verification_env
+ dev:load
+ ] do
+ Gitlab::Utils::DelegatorOverride.verify!
+ end
+
desc "GitLab | Lint | Lint JavaScript files using ESLint"
task :javascript do
Rake::Task['eslint'].invoke
diff --git a/lib/tasks/rubocop.rake b/lib/tasks/rubocop.rake
index a4147ae1bba..8c5edb5de8a 100644
--- a/lib/tasks/rubocop.rake
+++ b/lib/tasks/rubocop.rake
@@ -8,13 +8,14 @@ unless Rails.env.production?
namespace :rubocop do
namespace :todo do
desc 'Generate RuboCop todos'
- task :generate do
+ task :generate do # rubocop:disable Rails/RakeEnvironment
require 'rubocop'
options = %w[
--auto-gen-config
--auto-gen-only-exclude
--exclude-limit=100000
+ --no-offense-counts
]
RuboCop::CLI.new.run(options)