Skip to content

WIP: ci-fairy: handle local include directives during linting

Where an include: tag is present with a local: directive, load that file. The current approach is to load it into the YAML dictionary and then overwrite any keys of the parent (where applicable). This works with Python 3.6+ because the new dict() implementation keeps the insertion order and that order is guaranteed ABI as of 3.7.

Dumping the thing again requires some custom formatting. One to add linebreaks between top-level nodes and one to break out any multiline statements. Which works, mostly, but not totally. Good enough to submit it to the linter though albeit the line numbers will be out. But they'll be out anyway because if you're dealing with includes your line numbers cannot be correct, at least not with the gitlab linter as it works atm.

Note: another approach would be to parse the YAML line-by-line and replace the lines of the include node with the content of the include files. Which may or may not be more sensible...

Merge request reports