diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-03 17:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-03 17:59:07 +0000 |
commit | fc0a2622a00b99a0b20ac7cfd0342879c1e3044a (patch) | |
tree | f3aa0a77dcb356a877c9e02dde3dd43072b7a1ba /tooling/danger/stable_branch.rb | |
parent | 623e40c9bbb8b9c8cbca620ad3a663b33c15abcf (diff) | |
download | gitlab-ce-fc0a2622a00b99a0b20ac7cfd0342879c1e3044a.tar.gz |
Add latest changes from gitlab-org/gitlab@15-9-stable-ee
Diffstat (limited to 'tooling/danger/stable_branch.rb')
-rw-r--r-- | tooling/danger/stable_branch.rb | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/tooling/danger/stable_branch.rb b/tooling/danger/stable_branch.rb index 8fac1cc5fbf..2d1a4ef0845 100644 --- a/tooling/danger/stable_branch.rb +++ b/tooling/danger/stable_branch.rb @@ -46,21 +46,22 @@ module Tooling MSG NEEDS_PACKAGE_AND_TEST_MESSAGE = <<~MSG - The `e2e:package-and-test` job is not present or needs to be triggered manually. Please start the `e2e:package-and-test` - job and re-run `danger-review`. + The `e2e:package-and-test` job is not present, has been canceled, or needs to be automatically triggered. + Please ensure the job is present in the latest pipeline, if necessary, retry the `danger-review` job. + Read the "QA e2e:package-and-test" section for more details. MSG WARN_PACKAGE_AND_TEST_MESSAGE = <<~MSG - The `e2e:package-and-test` job needs to succeed or have approval from a Software Engineer in Test. See the section below - for more details. + **The `e2e:package-and-test` job needs to succeed or have approval from a Software Engineer in Test.** + Read the "QA e2e:package-and-test" section for more details. MSG # rubocop:disable Style/SignalException def check! - return unless non_security_stable_branch? + return unless valid_stable_branch? fail FEATURE_ERROR_MESSAGE if has_feature_label? - fail BUG_ERROR_MESSAGE unless has_bug_label? + fail BUG_ERROR_MESSAGE unless bug_fixes_only? warn VERSION_WARNING_MESSAGE unless targeting_patchable_version? @@ -78,22 +79,27 @@ module Tooling end # rubocop:enable Style/SignalException - def non_security_stable_branch? - !!stable_target_branch && !helper.security_mr? + def encourage_package_and_qa_execution? + valid_stable_branch? && + !has_only_documentation_changes? && + !has_flaky_failure_label? end private + def valid_stable_branch? + !!stable_target_branch && !helper.security_mr? + end + def package_and_test_status mr_head_pipeline_id = gitlab.mr_json.dig('head_pipeline', 'id') return unless mr_head_pipeline_id - pipeline_bridges = gitlab.api.pipeline_bridges(helper.mr_target_project_id, mr_head_pipeline_id) - package_and_test_pipeline = pipeline_bridges&.find { |j| j['name'] == 'e2e:package-and-test' } + pipeline = package_and_test_pipeline(mr_head_pipeline_id) - return unless package_and_test_pipeline + return unless pipeline - package_and_test_pipeline['status'] + pipeline['status'] end def stable_target_branch @@ -116,6 +122,10 @@ module Tooling helper.mr_has_labels?('failure::flaky-test') end + def bug_fixes_only? + has_bug_label? || has_only_documentation_changes? + end + def has_only_documentation_changes? categories_changed = helper.changes_by_category.keys return false unless categories_changed.size == 1 @@ -192,6 +202,17 @@ 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 |