Skip to content

Commit

Permalink
chore: add pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Makcal committed Mar 3, 2024
1 parent 186f136 commit 2f9adf1
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: pre-commit

on: [ push, pull_request ]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install pre-commit
- run: python -m pip freeze --local
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pre-commit run --show-diff-on-failure --color=always --all-files
env:
RUFF_FORMAT: github
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Pre-commit configuration.
# https://pre-commit.com

# pre-commit install
# pre-commit run --all-files

repos:
# Fix some errors with Ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
hooks:
- id: ruff
args: [ --fix, --exit-zero ]
name: "ruff: fixing"

# Reformat Python files with Black
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
name: "black: formatting"

# Lint Python files with Ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
hooks:
- id: ruff
name: "ruff: linting"

# Check other files
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: end-of-file-fixer
197 changes: 196 additions & 1 deletion poetry.lock

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

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ aiogram = "^3.4.1"
aiogram-dialog = "^2.1.0"
python-dotenv = "^1.0.1"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.6.2"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit 2f9adf1

Please sign in to comment.