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>2023-03-21 21:15:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-21 21:15:17 +0300
commit248492cc573e85aea19d7493c3a15d459be016c5 (patch)
treec25388f4af2e9a87e06121318982001b964e7573 /scripts
parent97a128c1d1bf45bcc00d5fae037f840eff1ae4e0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create-pipeline-failure-incident.rb59
-rwxr-xr-xscripts/generate-failed-pipeline-slack-message.rb11
-rwxr-xr-xscripts/review_apps/automated_cleanup.rb35
3 files changed, 74 insertions, 31 deletions
diff --git a/scripts/create-pipeline-failure-incident.rb b/scripts/create-pipeline-failure-incident.rb
index bd57abf3740..05cba98d2fc 100755
--- a/scripts/create-pipeline-failure-incident.rb
+++ b/scripts/create-pipeline-failure-incident.rb
@@ -15,7 +15,6 @@ class CreatePipelineFailureIncident
project: nil,
incident_json_file: 'incident.json'
}.freeze
- DEFAULT_LABELS = ['Engineering Productivity', 'master-broken::undetermined'].freeze
def initialize(options)
@project = options.delete(:project)
@@ -48,6 +47,10 @@ class CreatePipelineFailureIncident
ENV['CI_COMMIT_REF_NAME'] =~ /^[\d-]+-stable(-ee)?$/
end
+ def review_apps_incident?
+ project.end_with?('review-apps-broken-incidents')
+ end
+
def failed_jobs
@failed_jobs ||= PipelineFailedJobs.new(API::DEFAULT_OPTIONS.merge(exclude_allowed_to_fail_jobs: true)).execute
end
@@ -76,9 +79,13 @@ class CreatePipelineFailureIncident
end
def description
- return broken_stable_description_content if stable_branch_incident?
-
- broken_master_description_content
+ if stable_branch_incident?
+ broken_stable_description_content
+ elsif review_apps_incident?
+ broken_review_apps_description_content
+ else
+ broken_master_description_content
+ end
end
def broken_master_description_content
@@ -177,17 +184,41 @@ class CreatePipelineFailureIncident
MARKDOWN
end
- def incident_labels
- return ['release-blocker'] if stable_branch_incident?
+ def broken_review_apps_description_content
+ <<~MARKDOWN
+ ## #{project_link} pipeline #{pipeline_link} failed
- master_broken_label =
- if ENV['CI_PROJECT_NAME'] == 'gitlab-foss'
- 'master:foss-broken'
- else
- 'master:broken'
- end
+ **Branch: #{branch_link}**
- DEFAULT_LABELS.dup << master_broken_label
+ **Commit: #{commit_link}**
+
+ **Triggered by** #{triggered_by_link} • **Source:** #{source} • **Duration:** #{pipeline_duration} minutes
+
+ **Failed jobs (#{failed_jobs.size}):**
+
+ #{failed_jobs_list}
+
+ ### General guidelines
+
+ Please refer to [the review-apps triaging process](https://gitlab.com/gitlab-org/quality/engineering-productivity/team/-/blob/main/runbooks/review-apps.md#review-apps-broken-slack-channel-isnt-empty).
+ MARKDOWN
+ end
+
+ def incident_labels
+ if stable_branch_incident?
+ ['release-blocker']
+ elsif review_apps_incident?
+ ['review-apps-broken', 'Engineering Productivity', 'ep::review-apps']
+ else
+ master_broken_label =
+ if ENV['CI_PROJECT_NAME'] == 'gitlab-foss'
+ 'master:foss-broken'
+ else
+ 'master:broken'
+ end
+
+ [master_broken_label, 'Engineering Productivity', 'master-broken::undetermined']
+ end
end
def assignee_ids
@@ -249,7 +280,7 @@ if $PROGRAM_NAME == __FILE__
end
opts.on("-f", "--incident-json-file file_path", String, "Path to a file where to save the incident JSON data "\
- "(defaults to `#{CreatePipelineFailureIncident::DEFAULT_OPTIONS[:incident_json_file]}`)") do |value|
+ "(defaults to `#{CreatePipelineFailureIncident::DEFAULT_OPTIONS[:incident_json_file] || 'nil'}`)") do |value|
options[:incident_json_file] = value
end
diff --git a/scripts/generate-failed-pipeline-slack-message.rb b/scripts/generate-failed-pipeline-slack-message.rb
index eefdebd5db5..2a406ad7e23 100755
--- a/scripts/generate-failed-pipeline-slack-message.rb
+++ b/scripts/generate-failed-pipeline-slack-message.rb
@@ -9,11 +9,13 @@ require_relative 'api/pipeline_failed_jobs'
class GenerateFailedPipelineSlackMessage
DEFAULT_OPTIONS = {
+ project: nil,
failed_pipeline_slack_message_file: 'failed_pipeline_slack_message.json',
incident_json_file: 'incident.json'
}.freeze
def initialize(options)
+ @project = options.delete(:project)
@incident_json_file = options.delete(:incident_json_file)
end
@@ -73,7 +75,7 @@ class GenerateFailedPipelineSlackMessage
private
- attr_reader :incident_json_file
+ attr_reader :project, :incident_json_file
def failed_jobs
@failed_jobs ||= PipelineFailedJobs.new(API::DEFAULT_OPTIONS.dup.merge(exclude_allowed_to_fail_jobs: true)).execute
@@ -107,7 +109,7 @@ class GenerateFailedPipelineSlackMessage
if incident_exist?
incident['web_url']
else
- "#{ENV['CI_SERVER_URL']}/#{ENV['BROKEN_BRANCH_INCIDENTS_PROJECT']}/-/issues/new?" \
+ "#{ENV['CI_SERVER_URL']}/#{project}/-/issues/new?" \
"issuable_template=incident&issue%5Bissue_type%5D=incident"
end
end
@@ -153,6 +155,11 @@ if $PROGRAM_NAME == __FILE__
options = GenerateFailedPipelineSlackMessage::DEFAULT_OPTIONS.dup
OptionParser.new do |opts|
+ opts.on("-p", "--project PROJECT", String, "Full project path where the incidents are stored (defaults to "\
+ "`#{GenerateFailedPipelineSlackMessage::DEFAULT_OPTIONS[:project]}`)") do |value|
+ options[:project] = value
+ end
+
opts.on("-i", "--incident-json-file file_path", String, "Path to a file where the incident JSON data "\
"can be found (defaults to "\
"`#{GenerateFailedPipelineSlackMessage::DEFAULT_OPTIONS[:incident_json_file]}`)") do |value|
diff --git a/scripts/review_apps/automated_cleanup.rb b/scripts/review_apps/automated_cleanup.rb
index 0fe6867483d..36472056e76 100755
--- a/scripts/review_apps/automated_cleanup.rb
+++ b/scripts/review_apps/automated_cleanup.rb
@@ -24,6 +24,25 @@ module ReviewApps
].freeze
ENVIRONMENTS_NOT_FOUND_THRESHOLD = 3
+ def self.parse_args(argv)
+ options = {
+ dry_run: false
+ }
+
+ OptionParser.new do |opts|
+ opts.on("-d BOOLEAN", "--dry-run BOOLEAN", String, "Whether to perform a dry-run or not.") do |value|
+ options[:dry_run] = true if value == 'true'
+ end
+
+ opts.on("-h", "--help", "Prints this help") do
+ puts opts
+ exit
+ end
+ end.parse!(argv)
+
+ options
+ end
+
# $GITLAB_PROJECT_REVIEW_APP_CLEANUP_API_TOKEN => `Automated Review App Cleanup` project token
def initialize(
project_path: ENV['CI_PROJECT_PATH'],
@@ -279,21 +298,7 @@ def timed(task)
end
if $PROGRAM_NAME == __FILE__
- options = {
- dry_run: false
- }
-
- OptionParser.new do |opts|
- opts.on("-d", "--dry-run BOOLEAN", String, "Whether to perform a dry-run or not.") do |value|
- options[:dry_run] = true if value == 'true'
- end
-
- opts.on("-h", "--help", "Prints this help") do
- puts opts
- exit
- end
- end.parse!
-
+ options = ReviewApps::AutomatedCleanup.parse_args(ARGV)
automated_cleanup = ReviewApps::AutomatedCleanup.new(options: options)
timed('Docs Review Apps cleanup') do