From 11c2ffdbc287fd2d917f9f32a999961d0f249240 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera <mcabrera@gitlab.com> Date: Wed, 15 Mar 2023 15:32:47 -0600 Subject: [PATCH] Update stable checks to consider no downstream pipeline is generated The package-and-test bridge can be canceled which interrupts the generation of the downstream pipeline. This commit updates Danger stable branch checks to account for these scenarios. This will avoid Danger code failures when no downstream pipeline can be found, e.g. https://gitlab.com/gitlab-org/gitlab/-/jobs/3943016314. --- spec/tooling/danger/stable_branch_spec.rb | 21 +++++++++++++++++++-- tooling/danger/stable_branch.rb | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/spec/tooling/danger/stable_branch_spec.rb b/spec/tooling/danger/stable_branch_spec.rb index 6b5c0b8cf2745..4d86e066c2005 100644 --- a/spec/tooling/danger/stable_branch_spec.rb +++ b/spec/tooling/danger/stable_branch_spec.rb @@ -177,20 +177,37 @@ it_behaves_like 'bypassing when flaky test or docs only' end - context 'when no package-and-test job is found' do + context 'when no package-and-test bridge is found' do let(:pipeline_bridges_response) { nil } 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 being created' do + context 'when package-and-test bridge is created' do let(:pipeline_bridge_state) { 'created' } it_behaves_like 'with a warning', described_class::WARN_PACKAGE_AND_TEST_MESSAGE it_behaves_like 'bypassing when flaky test or docs only' end + context 'when package-and-test bridge has been canceled and no downstream pipeline is generated' do + let(:pipeline_bridge_state) { 'canceled' } + + let(:pipeline_bridges_response) do + [ + { + 'name' => 'e2e:package-and-test', + 'status' => pipeline_bridge_state, + 'downstream_pipeline' => nil + } + ] + end + + 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 in a non-successful state' do let(:package_and_qa_state) { 'running' } diff --git a/tooling/danger/stable_branch.rb b/tooling/danger/stable_branch.rb index 65086c8485c6b..9b4671460960d 100644 --- a/tooling/danger/stable_branch.rb +++ b/tooling/danger/stable_branch.rb @@ -102,7 +102,7 @@ def package_and_test_bridge_and_pipeline_status if bridge['status'] == 'created' bridge['status'] else - bridge.fetch('downstream_pipeline').fetch('status') + bridge.fetch('downstream_pipeline')&.fetch('status') end end -- GitLab