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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-17 12:09:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-17 12:09:53 +0300
commit612bb6f624ea7fdf5fd20e3332d543191603db88 (patch)
tree0540ef31b097382b8fd974cc4c41d1938d8caae4 /scripts
parentaf4364040394d0261c8b1c5f78ca60cc1e68e43c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/setup-test-env68
-rwxr-xr-xscripts/static-analysis5
-rwxr-xr-xscripts/used-feature-flags22
3 files changed, 93 insertions, 2 deletions
diff --git a/scripts/setup-test-env b/scripts/setup-test-env
new file mode 100755
index 00000000000..ebd3a48ae15
--- /dev/null
+++ b/scripts/setup-test-env
@@ -0,0 +1,68 @@
+#!/usr/bin/env ruby
+
+# frozen_string_literal: true
+
+require 'bundler/setup'
+
+require 'request_store'
+require 'rake'
+require 'active_support/dependencies'
+require 'active_support/dependencies/autoload'
+require 'active_support/core_ext/numeric'
+require 'active_support/string_inquirer'
+
+ENV['SKIP_RAILS_ENV_IN_RAKE'] = 'true'
+
+module Rails
+ extend self
+
+ def root
+ Pathname.new(File.expand_path('..', __dir__))
+ end
+
+ def env
+ @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test")
+ end
+end
+
+ActiveSupport::Dependencies.autoload_paths << 'lib'
+
+load File.expand_path('../lib/tasks/gitlab/helpers.rake', __dir__)
+load File.expand_path('../lib/tasks/gitlab/gitaly.rake', __dir__)
+
+# Required for config/0_inject_enterprise_edition_module.rb, lib/gitlab/access.rb
+require_dependency File.expand_path('../lib/gitlab', __dir__)
+
+require_dependency File.expand_path('../config/initializers/0_inject_enterprise_edition_module', __dir__)
+
+# Require for lib/gitlab/gitaly_client/storage_settings.rb and config/initializers/1_settings.rb
+require 'active_support/hash_with_indifferent_access'
+
+# Required for lib/gitlab/visibility_level.rb and lib/gitlab/safe_request_store.rb
+require 'active_support/concern'
+require 'active_support/core_ext/module/delegation'
+
+# Required for lib/system_check/helpers.rb
+require_dependency File.expand_path('../lib/gitlab/task_helpers', __dir__)
+
+# Required for lib/tasks/gitlab/helpers.rake
+require_dependency File.expand_path('../lib/system_check/helpers', __dir__)
+
+# Required for config/initializers/1_settings.rb
+require 'omniauth'
+require 'omniauth-github'
+require 'etc'
+require_dependency File.expand_path('../lib/gitlab/access', __dir__)
+
+require_dependency File.expand_path('../config/initializers/1_settings', __dir__)
+
+Gitlab.ee do
+ load File.expand_path('../ee/lib/tasks/gitlab/indexer.rake', __dir__)
+
+ require_dependency File.expand_path('../ee/lib/gitlab/elastic/indexer', __dir__)
+ require_dependency File.expand_path('../lib/gitlab/utils/override', __dir__)
+end
+
+require_dependency File.expand_path('../spec/support/helpers/test_env', __dir__)
+
+TestEnv.init
diff --git a/scripts/static-analysis b/scripts/static-analysis
index 7aa2fbf1594..fc917f1b975 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -24,7 +24,10 @@ class StaticAnalysis
(Gitlab.ee? ? %w[bin/rake gettext:updated_check] : nil) => 410,
# Most of the time, RuboCop finishes in 30 seconds, but sometimes it can take around 1200 seconds so we set a
# duration of 300 to lower the likelihood that it will run in the same job as another long task...
- %w[bundle exec rubocop --parallel] => 300,
+ %w[bundle exec rubocop --parallel --except Gitlab/MarkUsedFeatureFlags] => 300,
+ # We need to disable the cache for this cop since it creates files under tmp/feature_flags/*.used,
+ # the cache would prevent these files from being created.
+ %w[bundle exec rubocop --only Gitlab/MarkUsedFeatureFlags --cache false] => 600,
%w[yarn run lint:eslint:all] => 264,
%w[yarn run lint:prettier] => 134,
%w[bin/rake gettext:lint] => 81,
diff --git a/scripts/used-feature-flags b/scripts/used-feature-flags
index aebd007dda9..07c022a4c1a 100755
--- a/scripts/used-feature-flags
+++ b/scripts/used-feature-flags
@@ -28,6 +28,16 @@ flags_paths = [
# For EE additionally process `ee/` feature flags
if File.exist?('ee/app/models/license.rb') && !%w[true 1].include?(ENV['FOSS_ONLY'].to_s)
flags_paths << 'ee/config/feature_flags/**/*.yml'
+
+ # Geo feature flags are constructed dynamically and there's no explicit checks in the codebase so we mark all
+ # the replicators' derived feature flags as used.
+ # See https://gitlab.com/gitlab-org/gitlab/-/blob/54e802e8fe76b6f93656d75ef9b566bf57b60f41/ee/lib/gitlab/geo/replicator.rb#L183-185
+ Dir.glob('ee/app/replicators/geo/*_replicator.rb').each_with_object(Set.new) do |path, memo|
+ replicator_name = File.basename(path, '.rb')
+ feature_flag_name = "geo_#{replicator_name.delete_suffix('_replicator')}_replication"
+
+ FileUtils.touch(File.join('tmp', 'feature_flags', "#{feature_flag_name}.used"))
+ end
end
all_flags = {}
@@ -41,7 +51,17 @@ flags_paths.each do |flags_path|
feature_flag_name = File.basename(path, '.yml')
# TODO: we need a better way of tracking use of Gitaly FF across Gitaly and GitLab
- next if feature_flag_name.start_with?('gitaly_')
+ if feature_flag_name.start_with?('gitaly_')
+ puts "Skipping the #{feature_flag_name} feature flag since it starts with 'gitaly_'."
+ next
+ end
+
+ # Dynamic feature flag names for redirect to latest CI templates
+ # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/63144/diffs#fa2193ace3f6a02f7ef9995ef9bc519eca92c4ee_57_84
+ if feature_flag_name.start_with?('redirect_to_latest_template_')
+ puts "Skipping the #{feature_flag_name} feature flag since it starts with 'redirect_to_latest_template_'."
+ next
+ end
all_flags[feature_flag_name] = File.exist?(File.join('tmp', 'feature_flags', feature_flag_name + '.used'))
end