CI lint API can't lint single file with includes

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Release notes

The CI lint API is useful to validate if a given CI template has any errors. However, if a single file is checked and it contains any local includes, it is not possible to specify which branch they are taken from. This makes it impossible to lint multiple CI templates that are being developed in a feature branch. This can be resolved by allowing API users to specify a ref for the local includes.

Problem to solve

We maintain a repository of multiple CI files that can be included by different projects. To ensure invalid configurations are not merged into the main branch, a CI job lints every template for the feature branches. Due to the fact that the ref parameter is only used for the dry_run branch, and not to search for local includes, any MR that changes one of the included local files will not be correctly checked.

Proposal

The nicest solution is to simply use the existing ref parameter and also use it to look for includes (instead of the default branch). If there's a backwards compatibility concern, a new optional parameter like includes_ref could be added.

Intended users

Feature Usage Metrics

Does this feature require an audit event?

Implementation proposal

Provide the ref parameters as sha when initializing the linter.

Edited by 🤖 GitLab Bot 🤖