CI jobs with rules::changes may not trigger in MRs with large diffs
Summary
Given a merge request for a branch that changes a large number files, the rules::changes CI keyword may not detect changes that are lexically after the cutoff number of changes in the diff file limit. This behavior causes jobs to potentially be omitted from merge request pipelines when they should be included.
Steps to reproduce
-
Create a project with the following pipeline configuration
job_a: stage: build rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' changes: - /foo/version.txt -
Create a branch and merge request that both changes
/foo/version.txtand adds a number of files to/bar/*exceeding the configured file diff limit (default 1000) -
Trigger a merge request pipeline for the new branch.
job_awill not be included in the pipeline due to the changes to/foo/version.txtbeing lexically after the cutoff of file diffs from the additions to/bar/*
What is the current bug behavior?
- rules::changes may not properly trigger CI jobs if the file / directory is truncated from a large file diff for an MR
What is the expected correct behavior?
-
rules::changesproperly triggers jobs in all circumstances, including when MRs contain large file diffs that exceed the configured limit.
Implementation Plan
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 9dadef6bd3b6..606e9a493111 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -1246,7 +1246,7 @@ def branch_updated?
def modified_paths
strong_memoize(:modified_paths) do
if merge_request?
- merge_request.modified_paths
+ merge_request.modified_paths(fallback_on_overflow: true)
elsif branch_updated?
push_details.modified_paths
elsif external_pull_request?
Edited by 🤖 GitLab Bot 🤖