Add new keyword needs to rules
What does this MR do and why?
Main issue where the details of this work can be found.
Feature flag rollout issue.
Adding the ability to have needs in rules on builds and bridges.
I added a feature flag to this feature as we need to add docs as well as test some edge cases before a full release.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
With FF enabled:
- In rails console enable the feature flag fully or per project
Feature.enable(:introduce_rules_with_needs, project)
- Checkout my branch
- Create a project with yml file eg
main_job:
script: 'echo job'
needs: [rspec_job]
rules:
- if: $var == null
needs: [lint_job, rspec_job]
lint_job:
script: 'echo lint_job'
rules:
- if: $var == null
needs: [rspec_job]
rspec_job:
script: 'echo rspec_job'
rules:
- if: $var == null
or
main_job:
script: 'echo job'
needs: [rspec_job]
rules:
- if: $var == null
needs:
- job: lint_job
- rspec_job
lint_job:
script: 'echo lint_job'
rules:
- if: $var == null
needs:
- job: rspec_job
rspec_job:
script: 'echo rspec_job'
rules:
- if: $var == null
- When code pushed, the jobs should run in the following sequance:
rspec_job -> lint_job -> main_job
which indicates that the rule needs have taken precedence over needs set directly on the main_job
This MR enables below keywords under rule needs: job, artifacts, optional
main_job:
script: 'echo job'
needs: [rspec_job]
rules:
- if: $var == null
needs:
- job: lint_job
artifacts: false
optional: true
With FF disabled:
- In rails console disable the feature flag fully or per project
Feature.disable(:introduce_rules_with_needs, project)
- Checkout my branch
- Create a project with yml file eg
main_job:
script: 'echo job'
needs: [rspec_job]
rules:
- if: $var == null
needs: [lint_job, rspec_job]
lint_job:
script: 'echo lint_job'
rules:
- if: $var == null
needs: [rspec_job]
rspec_job:
script: 'echo rspec_job'
rules:
- if: $var == null
- When code pushed, the jobs should run in the following sequence:
rspec_job -> main_job -> lint_job
which indicates that the job needs have taken precedence over rules needs.
QA
When a rule needs refer to a job in the later stage, an error is raised:
When a rule needs refer to a job that doesn't exist, an error is raised:
When a rule needs includes duplicate jobs
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.