Add support for parsing !reference tag in GitLab CI YAML files#8
Open
chussenot wants to merge 4 commits into
Open
Add support for parsing !reference tag in GitLab CI YAML files#8chussenot wants to merge 4 commits into
chussenot wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This change is required to enable parsing of the
!referencetag, which is used in GitLab CI YAML files to optimize and reuse YAML content. Currently, theyaml-ast-parserdoes not support parsing this tag, which leads to errors when validating GitLab CI files using Spectral. By adding support for!reference, this update will allow Spectral to handle GitLab's YAML references properly, improving compatibility with GitLab CI configurations.Reference to the GitLab documentation: GitLab CI YAML Optimization Reference
Description
I have updated the
src/loader.tsfile to recognize the!referencetag alongside the existing tags like!include. The changes involve modifying the node kind and state when encountering!referenceto correctly parse and handle it as a scalar or reference node, based on its context. I have also updated theYAMLKindenum insrc/yamlAST.tsto include aREFERENCE_REFvalue, allowing the AST parser to distinguish between different types of reference tags.How Has This Been Tested?
The changes have been tested locally by parsing multiple GitLab CI YAML files containing the
!referencetag. These tests confirmed that the parser now properly recognizes and handles these tags without producing errors. Additionally, I have manually verified the behavior against Spectral rules that validate such files.Further automated tests will be implemented to cover a variety of cases where
!referencetags are used in different contexts (e.g., scalar, sequence, mapping).Screenshot(s)/recording(s)
Not applicable.
Types of changes
Checklist