-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from altheaden/add-pre-commit
Add `pre-commit` for code linting
- Loading branch information
Showing
57 changed files
with
395 additions
and
348 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[flake8] | ||
# https://pep8.readthedocs.io/en/latest/intro.html#error-codes | ||
ignore = | ||
# line break after operator | ||
W504 | ||
# Max width of Github code review is 79 characters | ||
max-line-length = 79 | ||
max-complexity = 18 | ||
per-file-ignores = | ||
*/__init__.py: F401 | ||
exclude = | ||
.git, | ||
docs, | ||
.idea, | ||
.mypy_cache, | ||
.pytest_cache, |
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 |
---|---|---|
|
@@ -16,6 +16,34 @@ env: | |
PATHS_IGNORE: '["**/README.md", "**/docs/**"]' | ||
|
||
jobs: | ||
pre-commit-hooks: | ||
name: lint with pre-commit | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- id: skip_check | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
cancel_others: ${{ env.CANCEL_OTHERS }} | ||
paths_ignore: ${{ env.PATHS_IGNORE }} | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
name: Checkout Code Repository | ||
uses: actions/checkout@v4 | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
name: Set up Python 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
# Run all pre-commit hooks on all the files. | ||
# Getting only staged files can be tricky in case a new PR is opened | ||
# since the action is run on a branch in detached head state | ||
name: Install and Run Pre-commit | ||
uses: pre-commit/[email protected] | ||
|
||
build: | ||
name: test geometric_features - python ${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
|
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 |
---|---|---|
|
@@ -8,6 +8,9 @@ on: | |
release: | ||
types: [published] | ||
|
||
env: | ||
PYTHON_VERSION: "3.10" | ||
|
||
jobs: | ||
publish-docs: | ||
runs-on: ubuntu-latest | ||
|
@@ -40,14 +43,14 @@ jobs: | |
channels: conda-forge | ||
channel-priority: strict | ||
auto-update-conda: true | ||
python-version: ${{ matrix.python-version }} | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }} | ||
name: Install geometric_features | ||
run: | | ||
git config --global url."https://github.com/".insteadOf "[email protected]:" | ||
conda create -n geometric_features_dev --file dev-spec.txt \ | ||
python=${{ matrix.python-version }} | ||
python=${{ env.PYTHON_VERSION }} | ||
conda activate geometric_features_dev | ||
python -m pip install -vv --no-deps --no-build-isolation -e . | ||
|
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,35 @@ | ||
exclude: "docs|.git|geometric_data|geometric_features/features_and_tags.json" | ||
default_stages: [pre-commit] | ||
fail_fast: true | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
|
||
# Can run individually with `pre-commit run isort --all-files` | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
exclude: "geometric_features/__init__.py" | ||
|
||
# Can run individually with `flynt [file]` or `flynt [source]` | ||
- repo: https://github.com/ikamensh/flynt | ||
rev: '1.0.1' | ||
hooks: | ||
- id: flynt | ||
args: ["--fail-on-change", "--verbose"] | ||
require_serial: true | ||
|
||
# Can run individually with `pre-commit run flake8 --all-files` | ||
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab | ||
# https://github.com/pre-commit/pre-commit/issues/1206 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 7.1.1 | ||
hooks: | ||
- id: flake8 | ||
args: ["--config=.flake8"] | ||
additional_dependencies: [flake8-isort] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ shapely>=2.0,<3.0 | |
pip | ||
pytest | ||
setuptools>=60 | ||
pre-commit | ||
isort | ||
flake8 | ||
|
||
# Documentation | ||
sphinx | ||
|
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
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.