Commit a8bfc498 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch...

Merge branch '282433-implement-a-danger-reminder-with-checklist-to-consider-validating-on-pipeline-changes' into 'master'

Implement a Danger reminder with checklist to consider validating on pipeline changes

See merge request gitlab-org/gitlab!48754
parents 4e09a04d c269619f
# frozen_string_literal: true
MESSAGE = <<~MESSAGE
## Pipeline Changes
This Merge Request contains changes to the pipeline configuration for the GitLab project.
Please consider the effect of the changes in this Merge Request on the following:
- Effects on different [pipeline types](https://docs.gitlab.com/ee/development/pipelines.html#pipelines-for-merge-requests)
- Effects on non-canonical projects (`gitlab-foss`, `security`, etc)
- Effects on [pipeline performance](https://about.gitlab.com/handbook/engineering/quality/performance-indicators/#average-merge-request-pipeline-duration-for-gitlab)
- Effects on fork pipelines
Please consider communicating these changes to the broader team following the [communication guideline for pipeline changes](https://about.gitlab.com/handbook/engineering/quality/engineering-productivity-team/#pipeline-changes)
MESSAGE
if helper.has_ci_changes?
markdown(MESSAGE)
end
......@@ -268,6 +268,10 @@ module Gitlab
def has_database_scoped_labels?(current_mr_labels)
current_mr_labels.any? { |label| label.start_with?('database::') }
end
def has_ci_changes?
changed_files(%r{\A(\.gitlab-ci\.yml|\.gitlab/ci/)}).any?
end
end
end
end
......@@ -14,6 +14,7 @@ class GitlabDanger
product_analytics
utility_css
pajamas
pipeline
].freeze
CI_ONLY_RULES ||= %w[
......
......@@ -591,4 +591,30 @@ RSpec.describe Gitlab::Danger::Helper do
expect(helper.prepare_labels_for_mr([])).to eq('')
end
end
describe '#has_ci_changes?' do
context 'when .gitlab/ci is changed' do
it 'returns true' do
expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb .gitlab/ci/test.yml])
expect(helper.has_ci_changes?).to be_truthy
end
end
context 'when .gitlab-ci.yml is changed' do
it 'returns true' do
expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb .gitlab-ci.yml])
expect(helper.has_ci_changes?).to be_truthy
end
end
context 'when neither .gitlab/ci/ or .gitlab-ci.yml is changed' do
it 'returns false' do
expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb nested/.gitlab-ci.yml])
expect(helper.has_ci_changes?).to be_falsey
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
require 'fast_spec_helper'
RSpec.describe GitlabDanger do
let(:gitlab_danger_helper) { nil }
......@@ -9,7 +9,7 @@ RSpec.describe GitlabDanger do
describe '.local_warning_message' do
it 'returns an informational message with rules that can run' do
expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, karma, database, commit_messages, product_analytics, utility_css, pajamas')
expect(described_class.local_warning_message).to eq("==> Only the following Danger rules can be run locally: #{described_class::LOCAL_RULES.join(', ')}")
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