-
Notifications
You must be signed in to change notification settings - Fork 506
[yamllint-fixer] Fix yamllint indentation warnings in workflow_call on: sections #55921
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
Changes from all commits
8770623
c77229c
b3b0593
06b4ed8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import ( | |
| "strings" | ||
|
|
||
| "github.com/github/gh-aw/pkg/logger" | ||
| "github.com/github/gh-aw/pkg/parser" | ||
| "github.com/goccy/go-yaml" | ||
| ) | ||
|
|
||
|
|
@@ -162,15 +163,16 @@ func (c *Compiler) injectWorkflowCallOutputs(onSection string, safeOutputs *Safe | |
| workflowCallMap["outputs"] = mergedOutputs | ||
| onMap["workflow_call"] = workflowCallMap | ||
|
|
||
| // Re-marshal to YAML | ||
| // Re-marshal to YAML. IndentSequence(true) matches extractTopLevelYAMLSection so | ||
| // sequence items (e.g. schedule cron lists) stay indented under their parent key. | ||
| newOnData := map[string]any{"on": onMap} | ||
| newYAML, err := yaml.Marshal(newOnData) | ||
| newYAML, err := yaml.MarshalWithOptions(newOnData, yaml.IndentSequence(true)) | ||
| if err != nil { | ||
| workflowCallLog.Printf("Warning: failed to marshal on section with workflow_call outputs: %v", err) | ||
|
pelikhan marked this conversation as resolved.
|
||
| return onSection | ||
| } | ||
|
|
||
| return strings.TrimSuffix(string(newYAML), "\n") | ||
| return finalizeWorkflowCallOnSection(newYAML) | ||
| } | ||
|
|
||
| // buildWorkflowCallOutputsMap constructs the outputs map for on.workflow_call.outputs | ||
|
|
@@ -343,11 +345,18 @@ func injectWorkflowCallSecretsSection(onSection string, secrets []string) string | |
|
|
||
| // Re-marshal to YAML. | ||
| newOnData := map[string]any{"on": onMap} | ||
| newYAML, err := yaml.Marshal(newOnData) | ||
| newYAML, err := yaml.MarshalWithOptions(newOnData, yaml.IndentSequence(true)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in b3b0593, extended in 06b4ed8.
{
name: "schedule sequence stays indented and cron stays quoted",
onSection: `"on":
schedule:
- cron: "0 0 */2 * *"
workflow_call: {}`,
secrets: []string{"MY_TOKEN"},
wantContain: []string{"MY_TOKEN", " schedule:\n - cron: \"0 0 */2 * *\""},
wantAbsent: []string{" schedule:\n - cron:", "- cron: 0 0"},
},It asserts the four-space nesting positively and pins the flattened two-space form as absent, plus the unquoted cron form after 06b4ed8 also restored Verified it's a real guard rather than a tautology: reverting the secrets call site back to plain The equivalent case exists for the outputs path at line 142. |
||
| if err != nil { | ||
| workflowCallLog.Printf("Warning: failed to marshal on section with workflow_call secrets: %v", err) | ||
| return onSection | ||
| } | ||
|
|
||
| return strings.TrimSuffix(string(newYAML), "\n") | ||
| return finalizeWorkflowCallOnSection(newYAML) | ||
| } | ||
|
|
||
| // finalizeWorkflowCallOnSection post-processes a re-marshaled on: section so it matches | ||
| // the formatting produced by extractTopLevelYAMLSection. The YAML library drops quotes | ||
| // from cron expressions such as "0 0 */2 * *", so they are re-quoted here. | ||
| func finalizeWorkflowCallOnSection(marshaled []byte) string { | ||
| return strings.TrimSuffix(parser.QuoteCronExpressions(string(marshaled)), "\n") | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.