Support CI config `include:rules:changes`
What does this MR do and why?
This MR adds support for rules:changes
(including the subkeys paths
and compare_to
) to include:rules
.
Main changes:
- The
Entry::Include::Rules::Rule
class is augmented with thechanges
entry. - The
pipeline
object is passed intoConfig::External::Context
as it is required to evaluate thechanges
clause. - Refactored and updated
spec/lib/gitlab/ci/config/external/processor_spec.rb
.
Feature flag: ci_support_include_rules_changes
- When the FF is off, the
changes:
keyword is still permitted but it has no effect.
FF Roll-out issue: #421608 (closed)
Resolves the final step (Step 2) of #342209 (closed).
How to set up and validate locally
- Enable the feature flag:
Feature.enable(:ci_support_include_rules_changes)
- In your project root, create 4 files with the following content (replace X with an integer 1-4):
File name: configX.yml
Content:
jobX:
script: echo
- Create another file named
test.txt
with0
in its content. - Update your
.gitlab-ci.yml
with the following:
include:
- local: config1.yml
rules:
- if: $VAR == null # true
changes:
- test.txt
when: never
- exists:
- config1.yml # true
- local: config2.yml
rules:
- if: $VAR == null # true
changes:
- test.txt
- local: config3.yml
rules:
- if: $VAR == 'true' # false
changes:
- test.txt
- local: config4.yml
rules:
- changes:
paths:
- test.txt
compare_to: 'main'
- Create a new branch named
branch1
frommain
. - On
branch1
, update the content of theREADME.md
file (or any file other thantest.txt
) and commit. - View the latest pipeline for
branch1
, it should only havejob1
:
- On
branch1
, update the content oftest.txt
to1
and commit. - View the latest pipeline for
branch1
, it should havejob2
andjob4
:
- Create a new branch named
branch2
frombranch1
. - On
branch2
, update the content oftest.txt
to2
and commit. - View the latest pipeline for
branch2
, it should havejob2
andjob4
:
- On
branch2
, update the content oftest.txt
to0
and commit. - View the latest pipeline for
branch2
, it should only havejob2
:
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #342209 (closed)
Edited by Leaminn Ma