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 = [
'Community contribution',
'security',
'bug',
'backstage', # To be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/222360.
'feature',
'feature::addition',
'feature::maintenance',
......
# frozen_string_literal: true
NO_SPECS_LABELS = [
'backstage', # To be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/222360.
'tooling',
'tooling::pipelines',
'tooling::workflow',
......
......@@ -4,7 +4,6 @@ module Gitlab
module Danger
module Changelog
NO_CHANGELOG_LABELS = [
'backstage', # To be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/222360.
'tooling',
'tooling::pipelines',
'tooling::workflow',
......@@ -14,7 +13,7 @@ module Gitlab
NO_CHANGELOG_CATEGORIES = %i[docs none].freeze
def needed?
categories_need_changelog? && (gitlab.mr_labels & NO_CHANGELOG_LABELS).empty?
categories_need_changelog? && without_no_changelog_label?
end
def found
......@@ -34,6 +33,10 @@ module Gitlab
def categories_need_changelog?
(helper.changes_by_category.keys - NO_CHANGELOG_CATEGORIES).any?
end
def without_no_changelog_label?
(gitlab.mr_labels & NO_CHANGELOG_LABELS).empty?
end
end
end
end
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative 'danger_spec_helper'
require 'gitlab/danger/changelog'
RSpec.describe Gitlab::Danger::Changelog do
using RSpec::Parameterized::TableSyntax
include DangerSpecHelper
let(:added_files) { nil }
......@@ -26,34 +24,36 @@ RSpec.describe Gitlab::Danger::Changelog do
subject(:changelog) { fake_danger.new(git: fake_git, gitlab: fake_gitlab, helper: fake_helper) }
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
{ backend: nil } | %w[backend backstage]
{ frontend: nil, docs: nil } | ['ci-build']
{ engineering_productivity: nil, none: nil } | ['meta']
end
subject { changelog.needed? }
with_them do
let(:changes_by_category) { categories }
let(:mr_labels) { labels }
context 'when MR contains only categories requiring no changelog' do
let(:changes_by_category) { { category_without_changelog => nil } }
let(:mr_labels) { [] }
it "is falsy when categories and labels require no changelog" do
it 'is falsey' do
is_expected.to be_falsy
end
end
where(:categories, :labels) do
{ frontend: nil, docs: nil } | ['database::review pending', 'feature']
{ backend: nil } | ['backend', 'technical debt']
{ engineering_productivity: nil, none: nil } | ['frontend']
context 'when MR contains a label that require no changelog' do
let(:changes_by_category) { { category_with_changelog => nil } }
let(:mr_labels) { [label_with_changelog, label_without_changelog] }
it 'is falsey' do
is_expected.to be_falsy
end
end
with_them do
let(:changes_by_category) { categories }
let(:mr_labels) { labels }
context 'when MR contains a category that require changelog and a category that require no changelog' do
let(:changes_by_category) { { category_with_changelog => nil, category_without_changelog => nil } }
let(:mr_labels) { [] }
it "is truthy when categories and labels require a changelog" do
it 'is truthy' do
is_expected.to be_truthy
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