Skip to content

Conversation

mssalvatore
Copy link
Collaborator

What does this PR do?

Adds pre-commit config. Resolves #974.

Includes pre-commit hooks for black, flake8, and isort.

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by running git commit

  • If applicable, add screenshots or log transcripts of the feature working

image

mssalvatore and others added 8 commits April 5, 2021 07:53
pre-commit (https://pre-commit.com/) is a tool that helps you easily
manage pre-commit hooks. We are using this largely for quality control
by running tools like flake8 and black.
Fix the versions of black, flake8, and isort in travis so that the same
versions are being used to pass/fail the build as developers are using
in their pre-commit hooks
Co-authored-by: Shreya Malviya <shreya.malviya@gmail.com>
@@ -24,7 +24,7 @@ install:
# Python
- pip freeze
- pip install -r monkey/monkey_island/requirements.txt # for unit tests
- pip install flake8 pytest pytest-cov dlint isort # for next stages
- pip install black==20.8b1 flake8==3.9.0 pytest pytest-cov dlint isort==5.8.0 # for next stages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we use the same in our requirement file for island

Copy link
Collaborator Author

@mssalvatore mssalvatore Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit uses the .pre-commit-config.yaml to track these requirements. I believe it installs them in a virtualenv separate from the rest of the python libraries on the system. You can then run all of the hooks using pre-commit run or pre-commit run -a.

Copy link
Contributor

@VakarisZ VakarisZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but make sure that travis dependencies match island's.

@mssalvatore mssalvatore merged commit 958fa50 into develop Apr 7, 2021
@mssalvatore mssalvatore deleted the pre-commit branch April 15, 2021 11:30
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.

Run code validation checks with pre-commit
3 participants