From 2d948c6f2a26efb3fa99e3cf85ae522ac723f404 Mon Sep 17 00:00:00 2001 From: Siavash Yousefi <43583410+siavashyj@users.noreply.github.com> Date: Sat, 22 Jun 2024 12:19:09 -0400 Subject: [PATCH] feat: add pre-commit github action. --- .github/workflows/pre-commit.yml | 26 ++++++++++++++++++++++ .pre-commit-config.yaml | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..6b58465 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,26 @@ +name: Pre-commit +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' # adjust this to match your project's Python version + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pre-commit + - name: Cache pre-commit hooks + uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run pre-commit + run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..dce18db --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,38 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: debug-statements + - id: detect-private-key + +- repo: https://github.com/psf/black + rev: 24.4.2 + hooks: + - id: black + +- repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + +- repo: https://github.com/PyCQA/flake8 + rev: 7.1.0 + hooks: + - id: flake8 + args: [--max-line-length=120] + additional_dependencies: [flake8-bugbear] + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.10.0 + hooks: + - id: mypy + additional_dependencies: [types-all] + +- repo: https://github.com/asottile/pyupgrade + rev: v3.16.0 + hooks: + - id: pyupgrade + args: [--py310-plus]