Skip to content

feat(actions): added YAML linting action using yamlfmt, and linted existing YAML files#6075

Merged
tombch merged 12 commits into
mainfrom
yamlfmt-lint
Mar 9, 2026
Merged

feat(actions): added YAML linting action using yamlfmt, and linted existing YAML files#6075
tombch merged 12 commits into
mainfrom
yamlfmt-lint

Conversation

@tombch

@tombch tombch commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

This PR adds an action yamlfmt-lint which checks for correctly formatted YAML, for all YAML files excluding the helm templates and Github actions.

The linting is done using yamlfmt, and a couple of settings have been added in the .yamlfmt.yml:

  • trim_trailing_whitespace: true: trims trailing whitespace, and was required to preserve multiline script/run tags in GitHub actions (mentioned here: Multiline syntax with pipe (|) not retained google/yamlfmt#185).
  • retain_line_breaks_single: true: any instance of multiple line breaks is squashed down into a single line break.

Any suggestions for this are very welcome! Some caveats I have noticed with the formatting is that it does not preserve any indenting/aligning within comments (mentioned here: google/yamlfmt#290)

For the Github actions, it forces any run/script tags to use |- rather than |. Possibly the workflows shouldn't be included in linting? (Github actions are now excluded from linting)

PR Checklist

  • All necessary documentation has been adapted.
  • The implemented feature is covered by appropriate, automated tests.
  • Any manual testing that has been done is documented (i.e. what exactly was tested?)

🚀 Preview: Add preview label to enable

@anna-parker

Copy link
Copy Markdown
Contributor

Hi @tombch this is amazing! if the github actions are hard to do you can start with excluding them and we can add them in a later PR - thanks for finding this and working on it!

Comment thread .github/workflows/add-preview-url.yml
@tombch tombch changed the title feat(actions): added YAML linting action using yamlfmt, and linted exist YAML files feat(actions): added YAML linting action using yamlfmt, and linted existing YAML files Mar 4, 2026
@tombch tombch marked this pull request as ready for review March 5, 2026 15:29
@claude

claude Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Claude finished @tombch's task in 2m 9s —— View job


Code Review

  • Gather context and read changed files
  • Review workflow file
  • Review yamlfmt config
  • Review pre-commit config changes
  • Review reformatted YAML files
  • Post final review

Overall this is a clean, well-scoped addition. The yamlfmt CI action works correctly (the yamlfmt-lint check passes ✅), and the exclusions for .github workflows and helm templates are the right call given the caveats mentioned in the PR description.

Two things worth addressing:

  1. Pin the container image versionghcr.io/google/yamlfmt:latest in the workflow can cause non-deterministic failures if a new release changes formatting rules. Pinning to a tag (e.g. v0.16.0) keeps the CI reproducible. See inline comment.

  2. No local pre-commit hook — The changes to .pre-commit-config.yaml are just the existing hooks being reformatted by yamlfmt itself. A yamlfmt pre-commit hook isn't actually added, so developers won't get YAML linting when committing locally. See inline comment for a suggested addition.

The YAML formatting changes themselves look correct — the indentation fixes in the references lists in values.yaml are actually semantically meaningful (the list items were previously under-indented relative to their parent key), and the trailing whitespace cleanup is purely cosmetic.

Comment thread .github/workflows/yamlfmt-lint.yml Outdated
Comment thread .pre-commit-config.yaml

@anna-parker anna-parker 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.

lgtm! I would maybe pin to a specific ymlfmt version as suggested to not have main tests potentially go red as soon as there is a new release :-)

@tombch tombch merged commit 6ac4261 into main Mar 9, 2026
47 of 48 checks passed
@tombch tombch deleted the yamlfmt-lint branch March 9, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants