-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add a linter runnable locally and in the CI to ease and enforce trailing blanks trimming #15115
base: master
Are you sure you want to change the base?
Add a linter runnable locally and in the CI to ease and enforce trailing blanks trimming #15115
Conversation
It is even hard to review what new is added to the CI due to big amount of changed files. IMHO: PR1 - extend CI with new check; PR2 - code cleanup |
Thanks for the feedback. As explained in the commit message of the second one, the profile run by the CI only checks files modified since this commit. |
50bd6ec
to
9113c35
Compare
There are again a few files in merge conflicts soon after the second update. Though, from my experience in similar cases, if we rely only on the CI for files changed since this commit, some files are likely to remain untouched. And we will probably never converge to a complete clean-up of the repo. |
9113c35
to
a7d137d
Compare
ec4999b
to
df6a80f
Compare
- add a pre-commit yaml configuration file with a basic profile to remove trailing blanks - add a rule to exclude from its scope - patch files (generated from git diff) Trailing blanks are part of their syntax. - .conf files in the src folder Their trailing blanks removal make some tests fail during build. - jinja templates in docker folder Though trailing blank should not be part of the jinja2 syntax, these files use a known hack that requires trailing blanks. Their removal makes build fail. - create a tox configuration to run/install/uninstall/autoupdate pre-commit in a python venv - create a tox profile for the CI to run pre-commit only on files modified since this commit - add a shell script to ease running pre-commit inside various CI Issue sonic-net#15114 Signed-off-by: Guillaume Lambert <[email protected]>
In azure pipelines configuration - add a linter stage - add to the linter stage a tox job w/ 2 steps to run tox Issue sonic-net#15114 Signed-off-by: Guillaume Lambert <[email protected]> fix
Issue sonic-net#15114 Signed-off-by: Guillaume Lambert <[email protected]>
df6a80f
to
53568f4
Compare
deps = pre-commit | ||
passenv = HOME | ||
commands = | ||
pre-commit run --all-files --show-diff-on-failure --from-ref a73d443c1d02698d9f3e030947c469677798bd32 --to-ref HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it "a73d443c1d02698d9f3e030947c469677798bd32"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it "a73d443c1d02698d9f3e030947c469677798bd32"?
It is the hash that references the commit just below this PR.
Only file modified since this commit will be linted by pre-commit.
$ git log -4 --oneline
53568f4 (HEAD -> trailing_blanks, orangeopensource/trailing_blanks) [CI][doc] Add some documentation for tox and pre-commit
1b1341d [CI] Trigger tox/pre-commit linter(s) in Azure CI
1aebc16 [CI] Add a pre-commit trailing blanks linter via tox
a73d443 [CI][doc][build] Trim src folder files trailing blanks (#15162)
CI changes to prepare and enforce trailing blanks complete clean-up
Why I did it
ease code review and maintainability
#15114
How I did it
Via tox and pre-commit.
The ~17400 lines w/ trailing blanks could hardly be cleaned up manually.
How to verify it
Which release branch to backport (provide reason below if selected)
potentially all
Tested branch (Please provide the tested image version)
master
Description for the changelog
Clean trailing blanks and add a related linter runnable locally and in the CI
A picture of a cute animal (not mandatory but encouraged)
//
('>
/rr
*))_