Skip to content

[WIP] yaml: Lint yaml files - #15726

Closed
phlax wants to merge 3 commits into
envoyproxy:mainfrom
phlax:lint-yaml
Closed

phlax wants to merge 3 commits into
envoyproxy:mainfrom
phlax:lint-yaml

Conversation

@phlax

@phlax phlax commented Mar 28, 2021

Copy link
Copy Markdown
Member

Signed-off-by: Ryan Northey [email protected]

Commit Message: yaml: Lint yaml files
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]

@phlax phlax changed the title yaml: Lint yaml files [WIP] yaml: Lint yaml files Mar 28, 2021
@phlax
phlax marked this pull request as draft March 28, 2021 10:45
Comment thread test/config/integration/server.yaml Resolved
Comment thread configs/example_configs_validation.py Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is a fix to the config_validation to prevent it borking on yaml parser errors

@phlax
phlax force-pushed the lint-yaml branch 2 times, most recently from 4685a58 to db26866 Compare March 29, 2021 11:43
@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label Mar 29, 2021
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).

🐱

Caused by: #15726 was synchronize by phlax.

see: more, trace.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not sure if this is part of this files badness - but i think it would just be ignore when the yaml was parsed

@phlax
phlax force-pushed the lint-yaml branch 2 times, most recently from d10fafe to 06b8f86 Compare March 29, 2021 17:20
Comment thread .yamllint Resolved
Comment thread .yamllint Resolved
Comment thread .azure-pipelines/pipelines.yml Resolved
@phlax phlax changed the title [WIP] yaml: Lint yaml files yaml: Lint yaml files Mar 31, 2021
@phlax
phlax marked this pull request as ready for review March 31, 2021 10:57
@phlax

phlax commented Mar 31, 2021

Copy link
Copy Markdown
Member Author

further information regarding this PR

working with a principle of least indent:

  • 2 space indent
  • lists are not indented from parent

when i started working with Envoy config i quickly became a convert to not indenting lists as it makes the config much more readable and concise

Envoy config has the complexity of a programming language with inline imports so i think its really important to have a standard way of writing - imho this is way more readable

currently in the docs there are a mixture of styles often in the same files and this makes it much harder to read/copy/fix etc

there is not currently an autofix - but i can look at that as part of #15777

i will also document when updating the style guide #15507

there are some other cleanups to make the linter happy (i think for good reason):

  • dictionary definitions ie { key: value } -> {key: value}
  • interpolation strings - ie {{ somevar }} -> "{{ somevar }}"

this does disambiguate the purpose of these i think, so its probs a better way - we might want too not use dict defs in some cases

Comment thread tools/code_format/yaml_lint.py Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not sure the yamllint config setting is necessary here - its changing to the directory - ie envoy roo

@mattklein123 mattklein123 self-assigned this Apr 1, 2021

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks this is fantastic. It would be really nice to somehow do this also for doc YAML snippets, but that probably isn't easily possible. One small comment about pre push checking. Thank you!

/wait

Comment thread ci/format_pre.sh Outdated
Comment on lines 47 to 53

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I meant to suggest this on the previous PR around whitespace, but before we do more here, can we consolidate as many checks here with https://github.com/envoyproxy/envoy/blob/main/support/hooks/pre-push? Many devs run that pre push script which catches issues before it gets to CI. Can we do YAML linting, glint, etc. on a per-file basis in that script also? I'm not sure we can do all checks, but I think we can do most of them and it saves people a huge amount of time. This is also why it's important to have "fix" targets to also not annoy people and auto fix where possible.

@phlax phlax Apr 1, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

re autofix - unless we dont use the definition dicts then its not so easy to autofix yaml - when its parsed there is no way to discriminate whether its indented code, or a dictionary - so it would change lots of files, and enforce a style we might not want

yep agreed re hooks, but it needs in that case to work on diffs, which is doable but more complex

these scripts are very resource consuming

ill look now at adding

i also want to flag the large amount of yaml changes, which i think is important

Ive done it mostly by hand, checking etc, so i think its good - but, more eyes, etc..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah I will go through all the files later, but let's go ahead and try to make things work on the pre-push hook in the interim.

@phlax phlax Apr 1, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

cool - i think it would make sense to do this separately to the bazel job - i think i can do it with git + yamllint - it probs doesnt make sense to add git as a py dependency right now i think - and i guess it can skip/warn yamllint if its not installed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

there might be an autofix - ill investigate further - adrienverge/yamllint#62 (comment)

@phlax

phlax commented Apr 1, 2021

Copy link
Copy Markdown
Member Author

It would be really nice to somehow do this also for doc YAML snippets, but that probably isn't easily possible

all the envoy docs will be updated with this - did you mean a diffferent doc YAML ?

phlax added 3 commits June 16, 2021 18:24
Signed-off-by: Ryan Northey <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale stalebot believes this issue/PR has not been touched recently label Jul 28, 2021
@phlax phlax added no stalebot Disables stalebot from closing an issue and removed stale stalebot believes this issue/PR has not been touched recently labels Jul 28, 2021
@phlax phlax closed this Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies no stalebot Disables stalebot from closing an issue waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants