diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..34c1806 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,43 @@ +name: Pre-Commit + +on: + pull_request: + branches: + - main + - dev + types: + - opened + - synchronize + - reopened + +jobs: + pre-commit: + name: Run pre-commit checks + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v7 + with: + python-version: "3.10" + - name: Cache pip + uses: actions/cache@v6 + with: + path: ~/.cache/pip + key: pip-${{ runner.os }}-${{ hashFiles('requirements.txt', 'requirements/requirements.async.txt', 'requirements/requirements.build.txt', 'requirements/requirements.crypto.txt', 'requirements/requirements.dev.txt', 'requirements/requirements.docs.txt', 'requirements/requirements.fastapi.txt', 'requirements/requirements.test.txt') }} + - name: Install pre-commit and dependencies + run: | + python -m pip install -U pip + python -m pip install ".[dev]" + - name: Cache pre-commit + uses: actions/cache@v6 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run pre-commit on all files + run: | + pre-commit run --all-files --show-diff-on-failure --color=always diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a8416d..e68c59b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -172,23 +172,6 @@ repos: entry: "python -m pyright" files: \.pyi?$ - # --- Tests --- - # - repo: local - # hooks: - # - id: pytest-collect - # name: "🧪 pytest-collect (local) - Validate test formatting" - # language: system - # entry: "python -m pytest --collect-only" - # pass_filenames: false - # always_run: true - - # - id: pytest - # name: "🧪 pytest (local) - Run tests" - # language: system - # entry: "./scripts/test.sh -l -v -c" - # pass_filenames: false - # always_run: true - # --- Cleanup --- # - repo: local # hooks: