Get Setting[] from workflow.yaml object
#214
Open
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.
✍ Changes
This pull request refactors how runner settings are extracted from workflow files in the
SettingsManagerclass. Instead of relying on regular expressions to parse theruns-onkey from workflow YAML, it introduces a more robust method that traverses the YAML object structure directly. This improves reliability and maintainability when reading runner settings.Runner extraction improvements:
SettingYamlKeyenum to define YAML keys, specificallyruns-on, for more explicit and type-safe access to workflow settings.SettingYamlKey.runnersvalue in thegetSettingmethod, making the extraction logic clearer and less error-prone.getSettingmethod to accept either a regular expression or aSettingYamlKey, enabling more flexible and context-aware extraction of settings.findInYaml, when aSettingYamlKeyis provided, ensuring that YAML keys are searched using object traversal rather than string matching.New YAML traversal utility:
findInYamlmethod, which parses the workflow YAML object by iterative traversal with a stack to locate the specified key and extract runner settings, handling both arrays and single values.Note
There is a comment in
findInYamlabout a singular use-case forruns-onspecifically. I'm not sure another workflow config key allows for a basic string, a string array, or an object, so perhaps quite the edge case. Either way, it's worth the call out and recognition that if other settings can be this varied, then this section would very much need to be refactored and abstracted.Documentation:
@ghbuckto the list of contributors inCONTRIBUTING.md.📋 Checklist