Commit 655a14fc authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'caalberts-remove-backstage-in-danger' into 'master'

Remove ~backstage in Danger

See merge request gitlab-org/gitlab!36420
parents 429776f7 986116ae
...@@ -4,7 +4,6 @@ THROUGHPUT_LABELS = [ ...@@ -4,7 +4,6 @@ THROUGHPUT_LABELS = [
'Community contribution', 'Community contribution',
'security', 'security',
'bug', 'bug',
'backstage', # To be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/222360.
'feature', 'feature',
'feature::addition', 'feature::addition',
'feature::maintenance', 'feature::maintenance',
......
# frozen_string_literal: true # frozen_string_literal: true
NO_SPECS_LABELS = [ NO_SPECS_LABELS = [
'backstage', # To be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/222360.
'tooling', 'tooling',
'tooling::pipelines', 'tooling::pipelines',
'tooling::workflow', 'tooling::workflow',
......
...@@ -4,7 +4,6 @@ module Gitlab ...@@ -4,7 +4,6 @@ module Gitlab
module Danger module Danger
module Changelog module Changelog
NO_CHANGELOG_LABELS = [ NO_CHANGELOG_LABELS = [
'backstage', # To be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/222360.
'tooling', 'tooling',
'tooling::pipelines', 'tooling::pipelines',
'tooling::workflow', 'tooling::workflow',
...@@ -14,7 +13,7 @@ module Gitlab ...@@ -14,7 +13,7 @@ module Gitlab
NO_CHANGELOG_CATEGORIES = %i[docs none].freeze NO_CHANGELOG_CATEGORIES = %i[docs none].freeze
def needed? def needed?
categories_need_changelog? && (gitlab.mr_labels & NO_CHANGELOG_LABELS).empty? categories_need_changelog? && without_no_changelog_label?
end end
def found def found
...@@ -34,6 +33,10 @@ module Gitlab ...@@ -34,6 +33,10 @@ module Gitlab
def categories_need_changelog? def categories_need_changelog?
(helper.changes_by_category.keys - NO_CHANGELOG_CATEGORIES).any? (helper.changes_by_category.keys - NO_CHANGELOG_CATEGORIES).any?
end end
def without_no_changelog_label?
(gitlab.mr_labels & NO_CHANGELOG_LABELS).empty?
end
end end
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
require 'fast_spec_helper' require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative 'danger_spec_helper' require_relative 'danger_spec_helper'
require 'gitlab/danger/changelog' require 'gitlab/danger/changelog'
RSpec.describe Gitlab::Danger::Changelog do RSpec.describe Gitlab::Danger::Changelog do
using RSpec::Parameterized::TableSyntax
include DangerSpecHelper include DangerSpecHelper
let(:added_files) { nil } let(:added_files) { nil }
...@@ -26,34 +24,36 @@ RSpec.describe Gitlab::Danger::Changelog do ...@@ -26,34 +24,36 @@ RSpec.describe Gitlab::Danger::Changelog do
subject(:changelog) { fake_danger.new(git: fake_git, gitlab: fake_gitlab, helper: fake_helper) } subject(:changelog) { fake_danger.new(git: fake_git, gitlab: fake_gitlab, helper: fake_helper) }
describe '#needed?' do describe '#needed?' do
subject { changelog.needed? } let(:category_with_changelog) { :backend }
let(:label_with_changelog) { 'frontend' }
let(:category_without_changelog) { Gitlab::Danger::Changelog::NO_CHANGELOG_CATEGORIES.first }
let(:label_without_changelog) { Gitlab::Danger::Changelog::NO_CHANGELOG_LABELS.first }
where(:categories, :labels) do subject { changelog.needed? }
{ backend: nil } | %w[backend backstage]
{ frontend: nil, docs: nil } | ['ci-build']
{ engineering_productivity: nil, none: nil } | ['meta']
end
with_them do context 'when MR contains only categories requiring no changelog' do
let(:changes_by_category) { categories } let(:changes_by_category) { { category_without_changelog => nil } }
let(:mr_labels) { labels } let(:mr_labels) { [] }
it "is falsy when categories and labels require no changelog" do it 'is falsey' do
is_expected.to be_falsy is_expected.to be_falsy
end end
end end
where(:categories, :labels) do context 'when MR contains a label that require no changelog' do
{ frontend: nil, docs: nil } | ['database::review pending', 'feature'] let(:changes_by_category) { { category_with_changelog => nil } }
{ backend: nil } | ['backend', 'technical debt'] let(:mr_labels) { [label_with_changelog, label_without_changelog] }
{ engineering_productivity: nil, none: nil } | ['frontend']
it 'is falsey' do
is_expected.to be_falsy
end
end end
with_them do context 'when MR contains a category that require changelog and a category that require no changelog' do
let(:changes_by_category) { categories } let(:changes_by_category) { { category_with_changelog => nil, category_without_changelog => nil } }
let(:mr_labels) { labels } let(:mr_labels) { [] }
it "is truthy when categories and labels require a changelog" do it 'is truthy' do
is_expected.to be_truthy is_expected.to be_truthy
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment