summaryrefslogtreecommitdiff
path: root/tooling
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /tooling
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'tooling')
-rw-r--r--tooling/danger/feature_flag.rb11
-rw-r--r--tooling/danger/product_intelligence.rb5
-rw-r--r--tooling/danger/project_helper.rb10
-rw-r--r--tooling/lib/tooling/kubernetes_client.rb49
4 files changed, 67 insertions, 8 deletions
diff --git a/tooling/danger/feature_flag.rb b/tooling/danger/feature_flag.rb
index 2e65831ef9f..cef64e52af3 100644
--- a/tooling/danger/feature_flag.rb
+++ b/tooling/danger/feature_flag.rb
@@ -10,7 +10,8 @@ module Tooling
# - :modified
# - :deleted
def feature_flag_files(change_type:)
- files = git.public_send("#{change_type}_files") # rubocop:disable GitlabSecurity/PublicSend
+ files = helper.public_send("#{change_type}_files") # rubocop:disable GitlabSecurity/PublicSend
+
files.select { |path| path =~ %r{\A(ee/)?config/feature_flags/} }.map { |path| Found.new(path) }
end
@@ -29,6 +30,14 @@ module Tooling
@group ||= yaml['group']
end
+ def default_enabled
+ @default_enabled ||= yaml['default_enabled']
+ end
+
+ def rollout_issue_url
+ @rollout_issue_url ||= yaml['rollout_issue_url']
+ end
+
def group_match_mr_label?(mr_group_label)
mr_group_label == group
end
diff --git a/tooling/danger/product_intelligence.rb b/tooling/danger/product_intelligence.rb
index 0f77f6c6a71..2c005b70de0 100644
--- a/tooling/danger/product_intelligence.rb
+++ b/tooling/danger/product_intelligence.rb
@@ -14,7 +14,10 @@ module Tooling
'spec/lib/gitlab/tracking_spec.rb',
'app/helpers/tracking_helper.rb',
'spec/helpers/tracking_helper_spec.rb',
- 'app/assets/javascripts/tracking.js',
+ 'app/assets/javascripts/tracking/index.js',
+ 'app/assets/javascripts/tracking/constants.js',
+ 'app/assets/javascripts/tracking/get_standard_context.js',
+ 'spec/frontend/tracking/get_standard_context_spec.js',
'spec/frontend/tracking_spec.js',
'generator_templates/usage_metric_definition/metric_definition.yml',
'lib/generators/gitlab/usage_metric/usage_metric_generator.rb',
diff --git a/tooling/danger/project_helper.rb b/tooling/danger/project_helper.rb
index a29dc5e5bed..8151e074096 100644
--- a/tooling/danger/project_helper.rb
+++ b/tooling/danger/project_helper.rb
@@ -6,21 +6,23 @@ module Tooling
LOCAL_RULES ||= %w[
changelog
database
- datateam
documentation
duplicate_yarn_dependencies
eslint
+ gitaly
karma
pajamas
pipeline
prettier
product_intelligence
utility_css
+ vue_shared_documentation
].freeze
CI_ONLY_RULES ||= %w[
ce_ee_vue_templates
ci_templates
+ datateam
metadata
feature_flag
roulette
@@ -43,16 +45,18 @@ module Tooling
%r{\Adata/whats_new/} => :docs,
%r{\A(
- app/assets/javascripts/tracking\.js |
+ app/assets/javascripts/tracking/.*\.js |
+ spec/frontend/tracking/.*\.js |
spec/frontend/tracking_spec\.js
)\z}x => [:frontend, :product_intelligence],
%r{\A(ee/)?app/(assets|views)/} => :frontend,
%r{\A(ee/)?public/} => :frontend,
- %r{\A(ee/)?spec/(javascripts|frontend)/} => :frontend,
+ %r{\A(ee/)?spec/(javascripts|frontend|frontend_integration)/} => :frontend,
%r{\A(ee/)?vendor/assets/} => :frontend,
%r{\A(ee/)?scripts/frontend/} => :frontend,
%r{(\A|/)(
\.babelrc |
+ \.browserslistrc |
\.eslintignore |
\.eslintrc(\.yml)? |
\.nvmrc |
diff --git a/tooling/lib/tooling/kubernetes_client.rb b/tooling/lib/tooling/kubernetes_client.rb
index 9bc5626db6b..12c4ee0039f 100644
--- a/tooling/lib/tooling/kubernetes_client.rb
+++ b/tooling/lib/tooling/kubernetes_client.rb
@@ -27,6 +27,13 @@ module Tooling
delete_by_exact_names(resource_type: resource_type, resource_names: resource_names, wait: wait)
end
+ def cleanup_review_app_namespaces(created_before:, wait: true)
+ namespaces = review_app_namespaces_created_before(created_before: created_before)
+ return if namespaces.empty?
+
+ delete_namespaces_by_exact_names(resource_names: namespaces, wait: wait)
+ end
+
private
def delete_by_selector(release_name:, wait:)
@@ -66,6 +73,19 @@ module Tooling
run_command(command)
end
+ def delete_namespaces_by_exact_names(resource_names:, wait:)
+ command = [
+ 'delete',
+ 'namespace',
+ '--now',
+ '--ignore-not-found',
+ %(--wait=#{wait}),
+ resource_names.join(' ')
+ ]
+
+ run_command(command)
+ end
+
def delete_by_matching_name(release_name:)
resource_names = raw_resource_names
command = [
@@ -101,9 +121,32 @@ module Tooling
]
response = run_command(command)
- JSON.parse(response)['items'] # rubocop:disable Gitlab/Json
- .map { |resource| resource.dig('metadata', 'name') if Time.parse(resource.dig('metadata', 'creationTimestamp')) < created_before }
- .compact
+
+ resources_created_before_date(response, created_before)
+ end
+
+ def review_app_namespaces_created_before(created_before:)
+ command = [
+ 'get',
+ 'namespace',
+ "-l tls=review-apps-tls", # Get only namespaces used for review-apps
+ "--sort-by='{.metadata.creationTimestamp}'",
+ '-o json'
+ ]
+
+ response = run_command(command)
+
+ resources_created_before_date(response, created_before)
+ end
+
+ def resources_created_before_date(response, date)
+ items = JSON.parse(response)['items'] # rubocop:disable Gitlab/Json
+
+ items.filter_map do |item|
+ item_created_at = Time.parse(item.dig('metadata', 'creationTimestamp'))
+
+ item.dig('metadata', 'name') if item_created_at < date
+ end
rescue ::JSON::ParserError => ex
puts "Ignoring this JSON parsing error: #{ex}\n\nResponse was:\n#{response}" # rubocop:disable Rails/Output
[]