Add missing keywords to CI schema
What does this MR do and why?
For #218473 (closed)
This adds the missing keywords in our Gitlab CI schema. With this change, the pipeline editor will be able to lint the following rules:
- When to save the cache (
cache:when
) - Trigger child pipeline with files from another project (
trigger:includes
) - Rules in
include
Screenshots or screen recordings
Rule | Recording | Notes |
---|---|---|
When to save the cache | Documentation | |
Trigger child pipeline with files from another project | trigger recording |
Documentation. According to this discussion, file is required when project is given. ref is optional |
Rules in include
|
Documentation. The docs mention that you can only use certain variables for include:rules:if but enforcing this is beyond the scope of the linter/json schema |
How to set up and validate locally
-
Enable the
:schema_linting
feature flag. (rails c
thenFeature.enable(:schema_linting)
) -
Visit to the pipeline editor by going to
CI/CD > Editor
-
You can copy paste the following sample
.gitlab-ci.yml
content. The comments denote where the linter should complain about errors.There should also be a squiggly line underneath the keywords that have errors. You can hover on these to get more information on how to fix them. Fixing these errors should remove the linter complaints. You may also refer to the links above to read more on the rules the linter is enforcing.
include:
- local: builds.yml
rules: # this whole section should pass
- if: '$INCLUDE_BUILDS == "true"'
when: always
stages:
- prepare
prepare_job:
stage: prepare
script:
- echo 'running prepare_job'
cache:
when: 0 # error: should be a one of "on_success", "on_failure", "always"
child-pipeline:
stage: prepare
trigger:
include:
- project: 'my-group/my-pipeline-library' # error: missing 'file' property
# should not complain if you add the optional `ref` property
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.