-
Notifications
You must be signed in to change notification settings - Fork 303
Minimal pre-commit implementation #3008
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
Open
sgonorov
wants to merge
6
commits into
openvinotoolkit:master
Choose a base branch
from
sgonorov:precommit_min_implementation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dac3a33
Minimal pre-commit implementation
sgonorov 8bca45f
Removed unnececarry CI steps
sgonorov 725ede5
Adding Darker for Python code formatting
sgonorov 30330bd
Exclude python files fromtrailing-whitespace check
sgonorov 71c003c
Sync python line length with OV
sgonorov c44cb7b
Adding cpp files to whitespace ignore
sgonorov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Lint | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| env: | ||
| OV_BRANCH: master | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint Changed Files | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| fetch-depth: 0 | ||
| submodules: recursive | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Run pre-commit on changed files | ||
| uses: pre-commit/[email protected] | ||
| with: | ||
| extra_args: --from-ref origin/${{ github.base_ref || 'master' }} --to-ref HEAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| repos: | ||
| - repo: meta | ||
| hooks: | ||
| - id: identity | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| exclude: '\.(py|c|cpp|h|hpp)$' | ||
| - id: end-of-file-fixer | ||
| - id: check-merge-conflict | ||
| - id: check-case-conflict | ||
| - id: check-symlinks | ||
| - id: detect-private-key | ||
| - id: mixed-line-ending | ||
| args: ["--fix=lf"] | ||
| - id: check-ast | ||
| - id: check-yaml | ||
| - id: check-toml | ||
| - id: check-added-large-files | ||
| args: ["--maxkb=1000"] | ||
| - repo: https://github.com/akaihola/darker | ||
| rev: v3.0.0 | ||
| hooks: | ||
| - id: darker | ||
| args: ["--formatter=ruff"] | ||
| additional_dependencies: | ||
| - ruff==0.14.4 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Am I right that it would be required to fix linting issues for any changed files?
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.
Yes, only for changed ones.
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.
So If I change 2 lines in several hundred loc file I would be required to fix lint for the whole file. Then feature changes would endup hidden in the linting changes. Is it correct?
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, that's the way. We can't partially format file sadly.
But for now it's mostly whitespaces as a starting point so it won't affect much. Later I'll try to make a separate PRs with properly formatted files and new formatters/linters introduction.
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.
BTW, for python there's a formatter called Darker which is compatible with Ruff format, but applies changes only to changed lines. When we get to it, maybe we'll use it instead of simply enabling Ruff across the codebase.
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.
It ignores python files. I can add CPP-related file to exception for now too if needed.
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 "it" refers to?
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.
Whitespace hook - for now it ignores only Pyhton files. We can add cpp files also.
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.
Add cpp to fix #3008 (comment) Any reason not to do so?
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.
Added. Then i'll create some migratiion PRs where fix all the whitespaces and remove these ignores.