-
Notifications
You must be signed in to change notification settings - Fork 29
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
github: formatting: add check on push and pull-request #810
base: main
Are you sure you want to change the base?
Conversation
Add pre-commit to allow local check before commit. This requires installing pre-commit on local machine. Flow to install and check/debug: pip install pre-commit pre-commit install \# run pre-commit on single file file_to_check.txt pre-commit run --verbose --files file_to_check.txt \# run pre-commit on all files pre-commit run --verbose --all-files Rules for pre-commit are in .pre-commit-config.yaml: Currently rules are: check-added-large-files: Will stop commit if large files to the repo mixed-line-ending: args: ['--fix', 'no'] Reports rule and stops on when file has mixed line endings will run on all files in repository excluding files ending with .cmd mixed-line-ending: args: ['--fix', 'crlf'] files: '\.cmd$' Will *automatically* correct lf to crlf on files ending with .cmd To uphold rules on server new github workflow is added that will execute pre-commit run --all-files Lastly I changed .gitattributes to also force crlf in cmd files. Signed-off-by: Krzysztof Kanas <[email protected]>
@kkanas will this pre-commit hook make git fail when committing anything that invalidates the rules? Sorry im new to these hooks and trying to see the differences/advantages in them. |
Hi Yes this should fail when you commit anything that invalidates the rules.
So if we ran this on server we should have build failures when pull request is filed when those rules are not uphold. Now the how we want to run pre-commit, either in way of showing violation |
I added .gitattributes and .pre-commit-config.yaml to enforce line endings. Line endings were fixed by running `pre-commit run --all-files` Signed-off-by: Krzysztof Kanas <[email protected]>
…cific Formatting done by running: pre-commit run --all-files Signed-off-by: Krzysztof Kanas <[email protected]>
Signed-off-by: Krzysztof Kanas <[email protected]>
Formatting done by running: pre-commit run --all-files Signed-off-by: Krzysztof Kanas <[email protected]>
Corupus files are exclude due them beeing binary files and new line would construct new corpus with empty line Signed-off-by: Krzysztof Kanas <[email protected]>
Formatting done using: pre-commit run --all-files Signed-off-by: Krzysztof Kanas <[email protected]>
AhmedBM |
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.
👌
@@ -27,4 +27,4 @@ The OSConfig Core team will respond to a PR that passes all checks in 3 business | |||
|
|||
# Contact | |||
|
|||
You may contact the OSConfig Core team at [[email protected]](mailto:[email protected]) to ask questions about OSConfig, to report bugs, to suggest new features, or inquire about any other OSConfig related topic. |
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.
Please do not remove this
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.
We need CONTRIBUTING.md restored. It appears it was deleted? (at least on my side). Also, it appears lots of files gained a new EOL at the last line, adding one blank line at the end. Can we remove that? Thanks
Add pre-commit to allow local check before commit. This requires installing pre-commit on local machine. Flow to install and check/debug:
pip install pre-commit
pre-commit install
# run pre-commit on single file file_to_check.txt pre-commit run --verbose --files file_to_check.txt # run pre-commit on all files
pre-commit run --verbose --all-files
Rules for pre-commit are in .pre-commit-config.yaml: Currently rules are:
check-added-large-files:
Will stop commit if large files to the repo
mixed-line-ending:
args: ['--fix', 'no']
Reports rule and stops on when file has mixed line endings
will run on all files in repository excluding files ending with .cmd
mixed-line-ending:
args: ['--fix', 'crlf']
files: '.cmd$'
Will automatically correct lf to crlf on files ending with .cmd
To uphold rules on server new github workflow is added that will execute pre-commit run --all-files
Lastly I changed .gitattributes to also force crlf in cmd files.
Description
Describe your changes in as much detail as possible. Provide a link/reference to the issue solved with this request if any.
Checklist
main
branch prior to this PR submission.main
branch.