summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-07 18:25:23 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-07 18:25:23 +0000
commitf6262510e6642bb91d112f1bf2ea70db8b7b772c (patch)
treeb993c00575cbf7353b6461e01e6556f8afc84955
parentd0d16ef2c479c6704b665178f28225cdaeb963e2 (diff)
downloadgitlab-ce-f6262510e6642bb91d112f1bf2ea70db8b7b772c.tar.gz
Add latest changes from gitlab-org/gitlab@15-9-stable-ee
-rw-r--r--spec/tooling/danger/stable_branch_spec.rb16
-rw-r--r--tooling/danger/stable_branch.rb32
2 files changed, 28 insertions, 20 deletions
diff --git a/spec/tooling/danger/stable_branch_spec.rb b/spec/tooling/danger/stable_branch_spec.rb
index f4008e09ef2..6b5c0b8cf27 100644
--- a/spec/tooling/danger/stable_branch_spec.rb
+++ b/spec/tooling/danger/stable_branch_spec.rb
@@ -94,7 +94,7 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
[
{
'name' => 'e2e:package-and-test',
- 'status' => 'success',
+ 'status' => pipeline_bridge_state,
'downstream_pipeline' => {
'id' => '123',
'status' => package_and_qa_state
@@ -103,6 +103,7 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
]
end
+ let(:pipeline_bridge_state) { 'running' }
let(:package_and_qa_state) { 'success' }
let(:parsed_response) do
@@ -183,10 +184,10 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
it_behaves_like 'bypassing when flaky test or docs only'
end
- context 'when package-and-test job is in manual state' do
- let(:package_and_qa_state) { 'manual' }
+ context 'when package-and-test job is being created' do
+ let(:pipeline_bridge_state) { 'created' }
- it_behaves_like 'with a failure', described_class::NEEDS_PACKAGE_AND_TEST_MESSAGE
+ it_behaves_like 'with a warning', described_class::WARN_PACKAGE_AND_TEST_MESSAGE
it_behaves_like 'bypassing when flaky test or docs only'
end
@@ -197,6 +198,13 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
it_behaves_like 'bypassing when flaky test or docs only'
end
+ context 'when package-and-test job is in manual state' do
+ let(:package_and_qa_state) { 'manual' }
+
+ it_behaves_like 'with a failure', described_class::NEEDS_PACKAGE_AND_TEST_MESSAGE
+ it_behaves_like 'bypassing when flaky test or docs only'
+ end
+
context 'when package-and-test job is canceled' do
let(:package_and_qa_state) { 'canceled' }
diff --git a/tooling/danger/stable_branch.rb b/tooling/danger/stable_branch.rb
index 2d1a4ef0845..65086c8485c 100644
--- a/tooling/danger/stable_branch.rb
+++ b/tooling/danger/stable_branch.rb
@@ -69,7 +69,7 @@ module Tooling
fail PIPELINE_EXPEDITE_ERROR_MESSAGE if has_pipeline_expedite_label?
- status = package_and_test_status
+ status = package_and_test_bridge_and_pipeline_status
if status.nil? || FAILING_PACKAGE_AND_TEST_STATUSES.include?(status) # rubocop:disable Style/GuardClause
fail NEEDS_PACKAGE_AND_TEST_MESSAGE
@@ -91,15 +91,26 @@ module Tooling
!!stable_target_branch && !helper.security_mr?
end
- def package_and_test_status
+ def package_and_test_bridge_and_pipeline_status
mr_head_pipeline_id = gitlab.mr_json.dig('head_pipeline', 'id')
return unless mr_head_pipeline_id
- pipeline = package_and_test_pipeline(mr_head_pipeline_id)
+ bridge = package_and_test_bridge(mr_head_pipeline_id)
- return unless pipeline
+ return unless bridge
- pipeline['status']
+ if bridge['status'] == 'created'
+ bridge['status']
+ else
+ bridge.fetch('downstream_pipeline').fetch('status')
+ end
+ end
+
+ def package_and_test_bridge(mr_head_pipeline_id)
+ gitlab
+ .api
+ .pipeline_bridges(helper.mr_target_project_id, mr_head_pipeline_id)
+ &.find { |bridge| bridge['name'] == 'e2e:package-and-test' }
end
def stable_target_branch
@@ -202,17 +213,6 @@ module Tooling
def version_to_minor_string(version)
"#{version[:major]}.#{version[:minor]}"
end
-
- def package_and_test_pipeline(mr_head_pipeline_id)
- package_and_test_bridge = gitlab
- .api
- .pipeline_bridges(helper.mr_target_project_id, mr_head_pipeline_id)
- &.find { |bridge| bridge['name'] == 'e2e:package-and-test' }
-
- return unless package_and_test_bridge
-
- package_and_test_bridge['downstream_pipeline']
- end
end
end
end