-
Notifications
You must be signed in to change notification settings - Fork 300
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
4
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
4 commits
Select commit
Hold shift + click to select a range
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$' | ||
| - 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.
I guess whitespaces only rules are ok for now. But I'm not sure about more complex rules.
I see 3 options:
This would be unconvenient for both, reviewer and author. Especialy for external contributors. We could ask to fix linting in a separate first to split linting and feature changes. But still confusing for external contributors.
Any more ideas on this?
Do you want to proceed with option 2? If yes, maybe we could start with this plan in this PR and fix whitespaces?
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.
2 is the best
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.
I've added Darker and yes, path 2 is the good one. Whitespaces is in around 200+ files. So i'll make it as a separate PR after this one.