Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'danger/feature_flag/Dangerfile')
-rw-r--r--danger/feature_flag/Dangerfile41
1 files changed, 17 insertions, 24 deletions
diff --git a/danger/feature_flag/Dangerfile b/danger/feature_flag/Dangerfile
index bf2194724fc..9b67590f117 100644
--- a/danger/feature_flag/Dangerfile
+++ b/danger/feature_flag/Dangerfile
@@ -41,6 +41,19 @@ def message_for_feature_flag_missing_group!(feature_flag:, mr_group_label:)
end
end
+def message_for_global_rollout(feature_flag)
+ return unless feature_flag.default_enabled == true
+
+ message = <<~SUGGEST_COMMENT
+ You're about to [release the feature with the feature flag](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/issue_templates/Feature%20Flag%20Roll%20Out.md#optional-release-the-feature-with-the-feature-flag).
+ This process can only be done **after** the [global rollout on production](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab/issue_templates/Feature%20Flag%20Roll%20Out.md#global-rollout-on-production).
+ Please make sure in [the rollout issue](#{feature_flag.rollout_issue_url}) that the preliminary steps have already been done. Otherwise, changing the YAML definition might not have the desired effect.
+ SUGGEST_COMMENT
+
+ mr_line = feature_flag.raw.lines.find_index { |l| l.include?('default_enabled:') }
+ markdown(message, file: feature_flag.path, line: mr_line.succ)
+end
+
def message_for_feature_flag_with_group!(feature_flag:, mr_group_label:)
return if feature_flag.group_match_mr_label?(mr_group_label)
@@ -65,30 +78,10 @@ feature_flag.feature_flag_files(change_type: :added).each do |feature_flag|
check_feature_flag_yaml(feature_flag)
end
-if helper.security_mr? && feature_flag_file_added?
- fail "Feature flags are discouraged from security merge requests. Read the [security documentation](https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/security/utilities/feature_flags.md) for details."
+feature_flag.feature_flag_files(change_type: :modified).each do |feature_flag|
+ message_for_global_rollout(feature_flag)
end
-if feature_flag_file_added_or_removed?
- new_mr_title = helper.mr_title.dup
- new_mr_title << ' [RUN ALL RSPEC]' unless helper.run_all_rspec_mr?
- new_mr_title << ' [RUN AS-IF-FOSS]' unless helper.run_as_if_foss_mr?
-
- changes = {}
- changes[:add_labels] = FEATURE_FLAG_LABEL unless helper.mr_has_labels?(FEATURE_FLAG_LABEL)
-
- if new_mr_title != helper.mr_title
- changes[:title] = new_mr_title
- else
- message "You're adding or removing a feature flag, your MR title needs to include `[RUN ALL RSPEC] [RUN AS-IF-FOSS]` (we may have updated it automatically for you and started a new MR pipeline) to ensure everything is covered."
- end
-
- if changes.any?
- gitlab.api.update_merge_request(
- gitlab.mr_json['project_id'],
- gitlab.mr_json['iid'],
- **changes
- )
- gitlab.api.post("/projects/#{gitlab.mr_json['project_id']}/merge_requests/#{gitlab.mr_json['iid']}/pipelines")
- end
+if helper.security_mr? && feature_flag_file_added?
+ fail "Feature flags are discouraged from security merge requests. Read the [security documentation](https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/security/utilities/feature_flags.md) for details."
end