-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CI: Run pre-commit gh action on only changed files #39505
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
CI: Run pre-commit gh action on only changed files #39505
Conversation
Resolves : GH38862 Since pre-commit in comment-bot runs on all files, it's a bit slow. Running it only on diff should speed it up significantly.
Thanks @gunjan-solanki ! |
hmm would be ok with doing this locally but is there a reason to do this in the CI itself? iow if there is a failure in a prior commit that is not corrected this would ignore it right? |
Just checking I've understood - you're asking what happens if someone makes a commit with some linting error, then makes another commit, then pushes, and then uses this comment bot? If so, then it should be fine, e.g.: $ git reset --hard upstream/master
HEAD is now at 339b1a658a CI: Run pre-commit gh action on only changed files (#39505)
$ git checkout -b tmp
Switched to a new branch 'tmp'
$ # add trailing whitespace
$ git diff
diff --git a/pandas/io/formats/info.py b/pandas/io/formats/info.py
index b1675fa5c5..cc8929be08 100644
--- a/pandas/io/formats/info.py
+++ b/pandas/io/formats/info.py
@@ -228,7 +228,7 @@ class DataFrameInfo(BaseInfo):
"""
def __init__(
- self,
+ self,
data: DataFrame,
memory_usage: Optional[Union[bool, str]] = None,
):
$ git commit -a -m 'add trailing whitespace' --no-verify
[tmp 4c40756c9c] add trailing whitespace
1 file changed, 1 insertion(+), 1 deletion(-)
$ git commit -m 'noop' --allow-empty --no-verify
[tmp 4c9b6d1d4c] noop
$ pre-commit run --from-ref=master --to-ref=HEAD --all-files
black..................................................................................................Failed
- hook id: black
- files were modified by this hook
reformatted pandas/io/formats/info.py
All done! ✨ 🍰 ✨
1 file reformatted.
flake8.................................................................................................Passed
flake8 (cython)....................................................................(no files to check)Skipped
flake8 (cython template)...........................................................(no files to check)Skipped
isort..................................................................................................Passed
pyupgrade..............................................................................................Passed
rst ``code`` is two backticks......................................................(no files to check)Skipped
rst directives end with two colons.....................................................................Passed
rst ``inline code`` next to normal text................................................................Passed
Generate pip dependency from conda.................................................(no files to check)Skipped
flake8-rst.........................................................................(no files to check)Skipped
Check for non-standard imports.........................................................................Passed
Check for non-standard numpy.random-related imports excluding pandas/_testing.py.......................Passed
Check for non-standard imports in test suite.......................................(no files to check)Skipped
Check for incorrect code block or IPython directives...................................................Passed
Check for use of not concatenated strings..............................................................Passed
Check for strings with wrong placed spaces.............................................................Passed
Check for import of private attributes across modules..................................................Passed
Check for use of private functions across modules......................................................Passed
Check for use of bare pytest raises................................................(no files to check)Skipped
Check for inconsistent use of pandas namespace in tests............................(no files to check)Skipped
Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias..........................Passed
Check for use of foo.__class__ instead of type(foo)....................................................Passed
Check for outdated annotation syntax and missing error codes...........................................Passed
Check for use of np.bool instead of np.bool_...........................................................Passed
Check code for instances of os.remove..............................................(no files to check)Skipped
Check code for instances of pd.api.types...........................................(no files to check)Skipped
Strip unnecessary `# noqa`s............................................................................Passed
Fix End of Files.......................................................................................Passed
Trim Trailing Whitespace...............................................................................Passed
codespell..............................................................................................Passed
no-string-hints........................................................................................Passed Just to clarify, the change in this PR only affects the comment bot. The job which runs the CI checks, which is run on every pull requests, still runs the checks on all files |
ok as long as we run in all files in CI this is fine |
Since pre-commit in comment-bot runs on all files, it's a bit slow. Running it only on diff should speed it up significantly.