-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve developer workflow with pre-commit (#351)
## Description <!-- Provide a brief description of the PR's purpose here. --> Pre-commit is a highly popular framework for installing pre-commit hooks into git projects. This PR adds pre-commit to improve quality-of-life for developers — with pre-commit, developers can easily enforce our style when contributing to pyribs. Adding pre-commit also necessitated fixing files which threw formatting and linting errors. ## TODO <!-- Notable points that this PR has either accomplished or will accomplish. --> - [x] Add pre-commit to CI - [x] Run YAPF on files and make changes - [x] Run prettier on Markdown/YAML files and make changes - [x] Update pylint config — previously, we threw many warnings when running the latest pylint because our pylint config included features only intended for Python 2 compatibility - [x] Allow `__init__` methods to not have docstrings - [x] Install pytest in the CI so the tests can import it during the pylint check ## Questions <!-- Any concerns or points of confusion? --> ## Status - [x] I have read the guidelines in [CONTRIBUTING.md](https://github.com/icaros-usc/pyribs/blob/master/CONTRIBUTING.md) - [x] I have formatted my code using `yapf` - [x] I have tested my code by running `pytest` - [x] I have linted my code with `pylint` - [x] I have added a one-line description of my change to the changelog in `HISTORY.md` - [x] This PR is ready to go
- Loading branch information
Showing
18 changed files
with
128 additions
and
152 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -11,6 +11,20 @@ on: | |
- master | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
env: | ||
# Skipped for now since we just added pre-commit and not all of our code | ||
# perfectly passes pylint. | ||
SKIP: pylint | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.11 | ||
- name: Install all deps and pylint (to be available to pre-commit) | ||
run: pip install .[all] pylint | ||
- uses: pre-commit/[email protected] | ||
# The visualize extra is only tested with pinned reqs because different | ||
# Matplotlib versions have slightly different outputs. | ||
test: | ||
|
@@ -133,7 +147,7 @@ jobs: | |
run: make docs | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: [test, pin, coverage, benchmarks, examples, tutorials] | ||
needs: [pre-commit, test, pin, coverage, benchmarks, examples, tutorials] | ||
if: startsWith(github.ref, 'refs/tags') | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
This file contains 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,40 @@ | ||
exclude: LICENSE | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
# See https://pre-commit.com/hooks.html | ||
- id: check-added-large-files | ||
- id: check-symlinks | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
- repo: https://github.com/google/yapf | ||
rev: v0.33.0 | ||
hooks: | ||
- id: yapf | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.11.5 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v3.0.2 | ||
hooks: | ||
- id: prettier | ||
types_or: [markdown, yaml] | ||
# pylint runs locally due to importing modules. See | ||
# https://pylint.pycqa.org/en/latest/user_guide/installation/pre-commit-integration.html | ||
- repo: local | ||
hooks: | ||
- id: pylint | ||
name: pylint | ||
entry: pylint | ||
language: system | ||
types: [python] | ||
args: [ | ||
"-rn", # Only display messages | ||
"-sn", # Don't display the score | ||
] |
This file contains 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
This file contains 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
This file contains 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
This file contains 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.