Skip to content

[yamllint-fixer] fix: trim trailing whitespace in generated YAML to reduce yamllint noise - #45620

Merged
pelikhan merged 3 commits into
mainfrom
fix/yamllint-trailing-spaces-generator-99cac96be91d0ffc
Jul 15, 2026
Merged

[yamllint-fixer] fix: trim trailing whitespace in generated YAML to reduce yamllint noise#45620
pelikhan merged 3 commits into
mainfrom
fix/yamllint-trailing-spaces-generator-99cac96be91d0ffc

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Reduces yamllint noise in generated *.lock.yml files by fixing root causes in the Go
YAML generator code. Source-file trailing whitespace (in embedded shell/jq/JS scripts and
prompt text) was carried verbatim into the compiled lock files, producing trailing-spaces
warnings. The generator now trims trailing whitespace at the YAML emission points.

yamllint config used:

{extends: default, rules: {line-length: disable, document-start: disable, truthy: {check-keys: false}, comments: {require-starting-space: true, min-spaces-from-content: 1}}}

Results

Metric Before After Reduction
Total warnings 16 4 12 (75%)

Warning breakdown

Category Before After
trailing-spaces 12 0
comments-indentation 3 3
empty-lines 1 1

All 12 trailing-spaces warnings are eliminated. The remaining comments-indentation (3)
and empty-lines (1) warnings were intentionally left untouched — fixing them safely requires
riskier structural changes (re-indenting generated on:-block comments and collapsing blank
lines inside user prompt content, which could alter fenced code blocks). Those are better
handled as separate, focused changes.

Changes

All changes trim trailing whitespace ( /\t) from each content line as it is written into
the lock file. Trailing whitespace is never semantically meaningful in the emitted contexts
(YAML keys/values, run:/script: block-scalar shell/JS bodies, and LLM prompt text), and
there is existing precedent for this in header.go.

  • pkg/workflow/compiler_yaml_step_conversion.goConvertStepToYAML (shared by all
    engines; covers on.steps / pre-activation job steps such as the github-script bodies in
    issue-monster).
  • pkg/workflow/compiler_yaml.gowriteStepsSection already computed a trimmed value
    but then wrote the untrimmed line; now emits the trimmed line (covers pre/post steps).
  • pkg/workflow/compiler_yaml_runtime_setup.goaddCustomStepsAsIs and
    addCustomStepsWithRuntimeInsertion (custom steps: from shared includes, e.g. the jq
    scripts in dataflow-pr-discussion-dataset and deep-report).
  • pkg/workflow/unified_prompt_step.gogenerateUnifiedPromptCreationStep built-in
    sections and user prompt chunks (e.g. markdown prompt lines in smoke-claude).
  • pkg/workflow/testdata/TestWasmGolden_CompileFixtures/smoke-copilot.golden
    regenerated golden fixture (2 lines: trailing spaces removed).

Verified: go build ./... passes, go test ./pkg/workflow/ passes, and gh aw compile
recompiles all 256 workflows with 0 errors.

Notes

Generated by 🧹 Daily yamllint Fixer · ⌖ 10.9 AIC ·

  • expires on Jul 21, 2026, 8:13 PM UTC-08:00

Reduces yamllint noise in generated *.lock.yml files by trimming trailing
whitespace from script and prompt body lines at the YAML emission points in
the generator, rather than carrying source-file trailing whitespace verbatim.

Fixes four emission paths:
- ConvertStepToYAML (on.steps / pre-activation job steps)
- writeStepsSection (pre/post steps; previously computed a trimmed value but
  wrote the untrimmed line)
- addCustomStepsAsIs / addCustomStepsWithRuntimeInsertion (custom steps)
- generateUnifiedPromptCreationStep (built-in sections + user prompt chunks)

Eliminates all 12 trailing-spaces warnings across the workflow set (16 -> 4).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pelikhan
pelikhan marked this pull request as ready for review July 15, 2026 04:17
Copilot AI review requested due to automatic review settings July 15, 2026 04:17
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #45620 does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (25 additions detected, threshold is 100).

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are consistent and correct. Trimming trailing spaces/tabs before writing each line to the YAML builder is safe across all code paths — yamllint treats trailing whitespace as noise regardless of block-scalar context. The golden-file update confirms the output is clean.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 10.4 AIC · ⌖ 4.9 AIC · ⊞ 5K

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Attempts to reduce yamllint warnings in generated lock files by trimming trailing whitespace during YAML compilation.

Changes:

  • Trims generated step and custom-step lines.
  • Trims built-in and user prompt heredocs.
  • Updates the WASM golden fixture.
Show a summary per file
File Description
pkg/workflow/compiler_yaml.go Trims pre/post-step output.
pkg/workflow/compiler_yaml_runtime_setup.go Trims custom-step output.
pkg/workflow/compiler_yaml_step_conversion.go Trims converted step YAML.
pkg/workflow/unified_prompt_step.go Trims prompt content lines.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/smoke-copilot.golden Updates expected generated output.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/5 changed files
  • Comments generated: 8
  • Review effort level: Medium

Comment on lines +48 to +50
// Trim trailing whitespace so script/block-scalar body lines carried
// verbatim from the source don't emit yamllint trailing-spaces warnings.
result.WriteString(" " + strings.TrimRight(line, " \t") + "\n")
Comment thread pkg/workflow/compiler_yaml.go Outdated
Comment on lines +960 to +963
if strings.HasPrefix(trimmed, " ") {
yaml.WriteString(" " + trimmed[2:] + "\n")
} else {
yaml.WriteString(" " + line + "\n")
yaml.WriteString(" " + trimmed + "\n")
Comment on lines +322 to +325
// Simply add 6 spaces for job context indentation.
// Trim trailing whitespace so script body lines carried verbatim from the
// source markdown don't emit yamllint trailing-spaces warnings in the lock file.
yaml.WriteString(" " + strings.TrimRight(line, " \t") + "\n")
Comment on lines +353 to +355
// Add the line with proper indentation, trimming trailing whitespace so
// script body lines don't emit yamllint trailing-spaces warnings.
yaml.WriteString(" " + strings.TrimRight(line, " \t") + "\n")
yaml.WriteString("\n")
} else {
yaml.WriteString(" " + nextLine + "\n")
yaml.WriteString(" " + strings.TrimRight(nextLine, " \t") + "\n")
Comment thread pkg/workflow/unified_prompt_step.go Outdated
Comment on lines +487 to +489
// Trim trailing whitespace so prompt lines don't emit yamllint
// trailing-spaces warnings in the lock file.
yaml.WriteString(strings.TrimRight(line, " \t"))
Comment thread pkg/workflow/unified_prompt_step.go Outdated
contentLines := strings.SplitSeq(cleanedContent, "\n")
for line := range contentLines {
yaml.WriteString(" " + line + "\n")
yaml.WriteString(" " + strings.TrimRight(line, " \t") + "\n")
Comment thread pkg/workflow/unified_prompt_step.go Outdated
contentLines := strings.SplitSeq(cleanedContent, "\n")
for line := range contentLines {
yaml.WriteString(" " + line + "\n")
yaml.WriteString(" " + strings.TrimRight(line, " \t") + "\n")

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, focused fix. No blocking issues.

The most notable correction is in writeStepsSection (compiler_yaml.go): the original code computed trimmed but then emitted the untrimmed line — a pre-existing logic bug that this PR fixes correctly. All other changes are consistent applications of strings.TrimRight(line, " \t") at YAML emission points where trailing whitespace is never semantically meaningful.

🔎 Code quality review by PR Code Quality Reviewer · 9.95 AIC · ⌖ 4.28 AIC · ⊞ 5.6K
Comment /review to run again

@github-actions github-actions Bot mentioned this pull request Jul 15, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 25 AIC · ⌖ 4.37 AIC · ⊞ 6.7K
Comment /matt to run again

for _, line := range lines {
if strings.TrimSpace(line) == "" {
result.WriteString("\n")
} else {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] No unit test directly asserts that trailing whitespace is stripped from emitted lines — coverage relies solely on the golden fixture for smoke-copilot.

💡 Suggested test addition

A small table-driven test in compiler_yaml_step_conversion_test.go (or equivalent) would pin this invariant:

func TestConvertStepToYAML_TrimsTrailingWhitespace(t *testing.T) {
    stepMap := map[string]any{
        "run": "echo hello   \n  indented   ",
    }
    got, err := ConvertStepToYAML(stepMap)
    require.NoError(t, err)
    for _, line := range strings.Split(got, "\n") {
        assert.Equal(t, strings.TrimRight(line, " \t"), line,
            "emitted line must have no trailing whitespace")
    }
}

This is a fast, self-contained regression guard that doesn't require recompiling all 256 workflows.

@copilot please address this.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill and address the unresolved review feedback below before rerunning checks.

Unresolved review threads (newest first):

Run: https://github.com/github/gh-aw/actions/runs/29389971239

Generated by 👨‍🍳 PR Sous Chef · 11.7 AIC · ⌖ 7.11 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 15, 2026 05:05
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Per reviewer feedback, trimming block-scalar content changes parsed values:
- run/script bodies (\\  is a shell line continuation)
- custom step with:/run blocks (heredoc payloads, multiline data)
- prompt heredocs (two trailing spaces = Markdown hard break)

Reverts all trimming changes introduced in abf2f9e and restores the
smoke-copilot.golden fixture to its original state.

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@copilot please run the pr-finisher skill and address the unresolved review feedback below before rerunning checks.

Unresolved review threads (newest first):...

Addressed all eight review threads. All trimming changes have been reverted — block-scalar bodies (run/script/with values and prompt heredocs) are emitted unchanged, preserving shell line continuations, heredoc payloads, and Markdown hard breaks. The smoke-copilot.golden fixture is also restored to its original state. Local make fmt and make test-unit pass cleanly.

Copilot AI requested a review from gh-aw-bot July 15, 2026 05:08
@pelikhan
pelikhan merged commit ef826f1 into main Jul 15, 2026
@pelikhan
pelikhan deleted the fix/yamllint-trailing-spaces-generator-99cac96be91d0ffc branch July 15, 2026 05:18
@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.82.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce yamllint noise in generated *.lock.yml

4 participants