diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-28 21:09:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-28 21:09:29 +0300 |
commit | 953180403c1798ba42d396742e0691d5772da3a5 (patch) | |
tree | 6fd3476f98b6fe6576164b50dbc9b924ce9ee825 /scripts | |
parent | 3a25b40d5572a1de4220a9bd284025bf5be1d16b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/api/create_issue_discussion.rb | 32 | ||||
-rwxr-xr-x | scripts/create-pipeline-failure-incident.rb | 20 | ||||
-rwxr-xr-x | scripts/review_apps/k8s-resources-count-checks.sh | 3 | ||||
-rwxr-xr-x | scripts/used-feature-flags | 3 |
4 files changed, 52 insertions, 6 deletions
diff --git a/scripts/api/create_issue_discussion.rb b/scripts/api/create_issue_discussion.rb new file mode 100644 index 00000000000..74a9f3ae378 --- /dev/null +++ b/scripts/api/create_issue_discussion.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'gitlab' +require_relative 'default_options' + +class CreateIssueDiscussion + def initialize(options) + @project = options.fetch(:project) + + # Force the token to be a string so that if api_token is nil, it's set to '', + # allowing unauthenticated requests (for forks). + api_token = options.delete(:api_token).to_s + + warn "No API token given." if api_token.empty? + + @client = Gitlab.client( + endpoint: options.delete(:endpoint) || API::DEFAULT_OPTIONS[:endpoint], + private_token: api_token + ) + end + + def execute(discussion_data) + client.post( + "/projects/#{client.url_encode project}/issues/#{discussion_data.delete(:issue_iid)}/discussions", + body: discussion_data + ) + end + + private + + attr_reader :project, :client +end diff --git a/scripts/create-pipeline-failure-incident.rb b/scripts/create-pipeline-failure-incident.rb index c38f80699e6..bbabfb7dfce 100755 --- a/scripts/create-pipeline-failure-incident.rb +++ b/scripts/create-pipeline-failure-incident.rb @@ -7,6 +7,7 @@ require 'json' require_relative 'api/pipeline_failed_jobs' require_relative 'api/create_issue' +require_relative 'api/create_issue_discussion' class CreatePipelineFailureIncident DEFAULT_OPTIONS = { @@ -28,7 +29,12 @@ class CreatePipelineFailureIncident labels: incident_labels } - CreateIssue.new(project: project, api_token: api_token).execute(payload) + CreateIssue.new(project: project, api_token: api_token).execute(payload).tap do |incident| + CreateIssueDiscussion.new(project: project, api_token: api_token) + .execute(issue_iid: incident.iid, body: "## Root Cause Analysis") + CreateIssueDiscussion.new(project: project, api_token: api_token) + .execute(issue_iid: incident.iid, body: "## Investigation Steps") + end end private @@ -44,8 +50,16 @@ class CreatePipelineFailureIncident end def title - "#{now.strftime('%A %F %R UTC')} - `#{ENV['CI_PROJECT_PATH']}` broken `#{ENV['CI_COMMIT_REF_NAME']}` " \ - "with #{failed_jobs.size} failed jobs" + @title ||= begin + full_title = "#{now.strftime('%A %F %R UTC')} - `#{ENV['CI_PROJECT_PATH']}` " \ + "broken `#{ENV['CI_COMMIT_REF_NAME']}` with #{failed_jobs.map(&:name).join(', ')}" + + if full_title.size >= 255 + "#{full_title[...252]}..." # max title length is 255, and we add an elipsis + else + full_title + end + end end def description diff --git a/scripts/review_apps/k8s-resources-count-checks.sh b/scripts/review_apps/k8s-resources-count-checks.sh index ae4c8e163e5..b63fa043065 100755 --- a/scripts/review_apps/k8s-resources-count-checks.sh +++ b/scripts/review_apps/k8s-resources-count-checks.sh @@ -56,8 +56,6 @@ cat > k8s-resources-count.out <<COMMANDS $(k8s_resource_count daemonsets.apps) daemonsets.apps $(k8s_resource_count deployments.apps) deployments.apps $(k8s_resource_count endpoints) endpoints - $(k8s_resource_count endpointslices.discovery.k8s.io) endpointslices.discovery.k8s.io - $(k8s_resource_count events) events $(k8s_resource_count frontendconfigs.networking.gke.io) frontendconfigs.networking.gke.io $(k8s_resource_count horizontalpodautoscalers.autoscaling) horizontalpodautoscalers.autoscaling $(k8s_resource_count ingressclasses) ingressclasses @@ -71,7 +69,6 @@ cat > k8s-resources-count.out <<COMMANDS $(k8s_resource_count orders.acme.cert-manager.io) orders.acme.cert-manager.io $(k8s_resource_count persistentvolumeclaims) persistentvolumeclaims $(k8s_resource_count poddisruptionbudgets.policy) poddisruptionbudgets.policy - $(k8s_resource_count pods.metrics.k8s.io) pods.metrics.k8s.io $(k8s_resource_count pods) pods $(k8s_resource_count podtemplates) podtemplates $(k8s_resource_count replicasets.apps) replicasets.apps diff --git a/scripts/used-feature-flags b/scripts/used-feature-flags index eb7e85be229..74180d02a91 100755 --- a/scripts/used-feature-flags +++ b/scripts/used-feature-flags @@ -114,6 +114,9 @@ if unused_flags.count > 0 puts puts "If they are really no longer needed REMOVE their .yml definition".red puts "If they are needed you need to ENSURE that their usage is covered with specs to continue.".red + puts "Feature flag usage is detected via Rubocop, which is unable to resolve dynamic feature flag usage,".red.bold + puts "interpolated strings however are optimistically matched. For more details consult test suite:".red + puts "https://gitlab.com/gitlab-org/gitlab/-/blob/69cb5d36db95881b495966c95655672cfb816f62/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb".red puts unused_flags.keys.sort.each do |name| puts "- #{name}".yellow |