Skip to content

Commit

Permalink
Add pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Aug 2, 2024
1 parent f06a0bb commit 08244a7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 159 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

14 changes: 6 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: psf/black@stable

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install dependencies
run: pip install pre-commit poetry

- name: Install Poetry
run: pip install poetry
- name: Run pre-commit checks
run: pre-commit run --all-files

- name: Install package
run: poetry install

- name: Run flake8 linter
run: poetry run flake8

- name: Run unit tests
run: poetry run pytest . --cov --cov-report=xml

Expand Down
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
# Prevent giant files from being committed.
- id: check-case-conflict
# Check for files with names that would conflict on a case-insensitive
# filesystem like MacOS HFS+ or Windows FAT.
- id: check-json
# Attempts to load all json files to verify syntax.
- id: check-merge-conflict
# Check for files that contain merge conflict strings.
- id: check-symlinks
# Checks for symlinks which do not point to anything.
- id: check-toml
# Attempts to load all TOML files to verify syntax.
- id: check-xml
# Attempts to load all xml files to verify syntax.
- id: check-yaml
# Attempts to load all yaml files to verify syntax.
- id: detect-private-key
# Checks for the existence of private keys.
- id: end-of-file-fixer
# Makes sure files end in a newline and only a newline.
- id: trailing-whitespace
# Trims trailing whitespace.
exclude_types: [python] # Covered by Ruff W291.
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.5
hooks:
# Run the linter.
- id: ruff
args: ["--extend-select", "I", "--fix"]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/python-poetry/poetry
rev: "1.8.3"
hooks:
- id: poetry-check
- id: poetry-lock
args: ["--no-update"]
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ This package uses [Poetry](https://python-poetry.org) for packaging and Python v

1. [Fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) and [clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#cloning-your-forked-repository) this repository.

2. Install Poetry by following [their installation instructions](https://python-poetry.org/docs/#installation).
2. Install [pre-commit hooks](https://pre-commit.com) by running the following two commands:

3. Install this package and its dependencies by running the following command inside your clone of this repository:
pip install pre-commit
pre-commit install

3. Install Poetry by following [their installation instructions](https://python-poetry.org/docs/#installation).

4. Install this package and its dependencies by running the following command inside your clone of this repository:

poetry install --all-extras

4. Run the following command to launch a shell that is preconfigured with the project's virtual environment:
5. Run the following command to launch a shell that is preconfigured with the project's virtual environment:

poetry shell

Expand Down
145 changes: 1 addition & 144 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pygcn = "*"
prometheus-client = "^0.17.0"

[tool.poetry.group.dev.dependencies]
black = "*"
flake8 = "*"
pytest = "*"
pytest-asyncio = "*"
pytest-cov = "*"
Expand Down

0 comments on commit 08244a7

Please sign in to comment.