Skip to content
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

Adding Pre commit hook #1257

Merged
merged 10 commits into from Jul 15, 2021
Merged

Conversation

Casyfill
Copy link
Contributor

@Casyfill Casyfill commented Jul 11, 2021

Waiting for THIS PR to go first.
Looking forward to confirmation/approval to go over the checklist

Adds pre-commit setup for code style auto-check on any commit. Right now (Draft) linked to my fork of codestyle for testing purposes, once PR is merged, will link to the actual codestyle repository.

How to check / test

  1. ensure this file exists
  2. install pre-commit: pip install pre-commit. we'll have to add pre-commit to dev requirements
  3. run pre-commit install ( installis git hook script into ./git/hooks/pre-commit )
  4. Done. Now make any change to python file and try committing - it will run catalyst-make-codestyle automatically and stop without commit if it has job to do (or at least if it fails, but for black it halts if black does any reformating at all).

Pros

  • auto check eliminates the need to manually check for codestyle, reminding people to do it, etc
  • once "deployed", the script is stored in the .git/hooks/pre-commit file, so all developers get it by default, they don't need to read documentation, install codestyle, etc, etc.
  • style requirements can evolve from commit to commit, as we refer to specific hash/version(tag) of codestyle in the repo.

Cons

  • adding one more package to the developer requirements list

Side Notes

  • we can add other checks, for other languages or datasets as well, if we want. One could check for proper docstring formatting, dead reference links, etc.

Before submitting (checklist)

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contribution guide?
  • Did you check the code style? catalyst-make-codestyle && catalyst-check-codestyle (pip install -U catalyst-codestyle).
  • Did you make sure to update the docs? We use Google format for all the methods and classes.
  • Did you check the docs with make check-docs?
  • Did you write any new necessary tests?
  • Did you check that your code passes the unit tests pytest . ?
  • Did you add your new functionality to the docs?
  • Did you update the CHANGELOG?
  • Did you run colab minimal CI/CD with latest and minimal requirements?

Description

Related Issue

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

FAQ

Please review the FAQ before submitting an issue:

ditwoo
ditwoo previously approved these changes Jul 12, 2021
@mergify mergify bot dismissed ditwoo’s stale review July 12, 2021 21:39

Pull request has been modified.

ditwoo
ditwoo previously approved these changes Jul 13, 2021
@Casyfill Casyfill changed the title Draft: Pre commit hook Adding Pre commit hook Jul 13, 2021
@mergify mergify bot dismissed ditwoo’s stale review July 13, 2021 20:29

Pull request has been modified.

@Casyfill
Copy link
Contributor Author

Updated hooks to pull codestyle from official repository (current pr in master). Probably a good idea to switch to release tag once it will be released (or shall we release it as a patch now?)

@Scitator
Copy link
Member

catalyst-codestyle==21.06rc1 released :)
PS. somehow I messed with the date, sorry; but it's Release Candidate still (we need to fix config usage there), so nevermind

Scitator
Scitator previously approved these changes Jul 15, 2021
ditwoo
ditwoo previously approved these changes Jul 15, 2021
@mergify mergify bot dismissed stale reviews from ditwoo and Scitator July 15, 2021 17:01

Pull request has been modified.

@Scitator Scitator merged commit 146885c into catalyst-team:master Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants