Skip to content
代码片段 群组 项目
提交 69035a80 编辑于 作者: Mayra Cabrera's avatar Mayra Cabrera
浏览文件

Skip Danger failure when package-and-test is being created

The package-and-test execution is required for merge requests targeting
stable branches. Danger should fail when the package-and-test status is
canceled or manual, or when the pipeline is not present. Previous to
this commit there was a bug in the logic: Danger failed when the
package-and-test pipeline was being created, this is because it
only considered the downstream pipeline status rather than the bridge
status.

This commit ensures both status, the brige and the downstream pipeline
are considered, avoiding the Danger failure when the package-and-test is
being created.

Related to https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/2839
上级 c4b93aac
No related branches found
No related tags found
无相关合并请求
......@@ -94,7 +94,7 @@
[
{
'name' => 'e2e:package-and-test',
'status' => 'success',
'status' => pipeline_bridge_state,
'downstream_pipeline' => {
'id' => '123',
'status' => package_and_qa_state
......@@ -103,6 +103,7 @@
]
end
let(:pipeline_bridge_state) { 'running' }
let(:package_and_qa_state) { 'success' }
let(:parsed_response) do
......@@ -183,10 +184,10 @@
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 @@
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' }
......
......@@ -69,7 +69,7 @@ def check!
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 @@ def valid_stable_branch?
!!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 @@ def fetch_last_minor_version_for_major(major)
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
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册