Skip to content

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

Merged
merged 1 commit into from
Jan 31, 2021

Conversation

gunjan-solanki
Copy link
Contributor


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.

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.
@gunjan-solanki gunjan-solanki marked this pull request as ready for review January 31, 2021 18:58
@MarcoGorelli MarcoGorelli added this to the 1.3 milestone Jan 31, 2021
@MarcoGorelli MarcoGorelli added CI Continuous Integration Code Style Code style, linting, code_checks labels Jan 31, 2021
@MarcoGorelli MarcoGorelli merged commit 339b1a6 into pandas-dev:master Jan 31, 2021
@MarcoGorelli
Copy link
Member

Thanks @gunjan-solanki !

@jreback
Copy link
Contributor

jreback commented Jan 31, 2021

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?

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Jan 31, 2021

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

@jreback
Copy link
Contributor

jreback commented Jan 31, 2021

ok as long as we run in all files in CI this is fine

@gunjan-solanki gunjan-solanki deleted the use-diff-comment-bot branch February 1, 2021 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI speed-up @github-actions pre-commit by only running it on changed files
3 participants