Lint more YAML files in CI
Context
Closes #359968 (closed)
What does this MR do?
- We are extending the YAML linting to most YAML files in the repo (here is the current denylist).
- We are triggering the YAML job as soon as a YAML file got modified (more on that in the next section)
- We are only catching syntax errors for now.
Rationale
- The CI doesn't allow us (yet) to ignore files to trigger when using changes. We would need to do a whitelist, and it would be a big (brittle) one.
- The YAML job is fairly fast to run (at least locally)
To consider
- It might be too much to run the YAML job every time a YAML file for changed...
- Ideally, there would be a way to run the linting only on the files that got changed, but I could not find it.
How to set up and validate
remotely
I've created an MR to test out the changes in this branch. You can have a look at the pipelines for this MR:
- No changes in the YAML files: The YAML jobs aren't triggered
- A YAML error has been introduced (the same problem as in the original issue): The YAML job errors out
- The YAML problem is fixed, and another valid YAML change is introduced: the YAML jobs are triggered, and they are successful
locally
cd <your-local-gitlab-installation>
docker run -it \
-e LINT_PATHS=".gitlab-ci.yml .gitlab/ci lib/gitlab/ci/templates data/deprecations data/removals data/whats_new" \
-v $PWD:/code \
registry.gitlab.com/pipeline-components/yamllint:latest sh
# Run default linting
yamllint --strict -f colored .
# Run pipeline linting
yamllint -d "{extends: default, rules: {line-length: disable, document-start: disable}}" $LINT_PATHS
echo $?
Edited by Lin Jen-Shin