-
Notifications
You must be signed in to change notification settings - Fork 7
Add runtime switch for Tend workflows #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Inspect the parsed YAML node so the extra YAML 1.1 boolean words (yes/no/on/off) | ||
| # do not diverge from the YAML 1.2 parser used by `tend init`. | ||
| require "psych" | ||
|
|
||
| path = ARGV.fetch(0) | ||
| documents = Psych.parse_stream(File.read(path, mode: "r:bom|utf-8")).children | ||
| unless documents.length == 1 | ||
| abort "tend config must contain exactly one YAML document" | ||
| end | ||
|
|
||
| mapping = documents.first.root | ||
| unless mapping.is_a?(Psych::Nodes::Mapping) | ||
| abort "tend config must contain a YAML mapping" | ||
| end | ||
|
|
||
| def has_yaml_merge_key?(node) | ||
| case node | ||
| when Psych::Nodes::Mapping | ||
| node.children.each_slice(2).any? do |key, value| | ||
| (key.is_a?(Psych::Nodes::Scalar) && key.plain && key.value == "<<") || | ||
| has_yaml_merge_key?(key) || has_yaml_merge_key?(value) | ||
| end | ||
| when Psych::Nodes::Sequence | ||
| node.children.any? { |value| has_yaml_merge_key?(value) } | ||
| else | ||
| false | ||
| end | ||
| end | ||
|
|
||
| if has_yaml_merge_key?(mapping) | ||
| abort "tend config: YAML merge keys (<<) are not supported" | ||
| end | ||
|
|
||
| matches = mapping.children.each_slice(2).select do |key, _value| | ||
| key.is_a?(Psych::Nodes::Scalar) && key.value == "enabled" | ||
| end | ||
| abort "tend config: enabled must appear at most once" if matches.length > 1 | ||
|
|
||
| value = matches.dig(0, 1) | ||
| enabled = true | ||
| if value | ||
| bool_tag = value.respond_to?(:tag) && value.tag == "tag:yaml.org,2002:bool" | ||
| literal = value.value.downcase if value.is_a?(Psych::Nodes::Scalar) | ||
| unless value.is_a?(Psych::Nodes::Scalar) && | ||
| (value.plain || bool_tag) && | ||
| ["true", "false"].include?(literal) | ||
| abort "tend config: enabled must be true or false" | ||
| end | ||
| enabled = literal == "true" | ||
| end | ||
|
|
||
| puts "enabled=#{enabled}" | ||
|
|
||
| unless enabled | ||
| warn "::notice title=Tend disabled::The tend config sets enabled: false; skipping this job" | ||
| end | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.