diff --git a/.github/workflows/precommit.yaml b/.github/workflows/precommit.yaml new file mode 100644 index 00000000..bb6c6e5b --- /dev/null +++ b/.github/workflows/precommit.yaml @@ -0,0 +1,31 @@ +name: Run pre-commit checks + +on: + pull_request: + push: + +jobs: + run-linters: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Configure caching + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: precommit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Install pre-commit + run: | + pip install pre-commit + + - name: Run linters + run: | + pre-commit run --all-files diff --git a/.github/workflows/tests.yml b/.github/workflows/unit-tests.yaml similarity index 92% rename from .github/workflows/tests.yml rename to .github/workflows/unit-tests.yaml index 397f7c15..366d3513 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/unit-tests.yaml @@ -20,7 +20,5 @@ jobs: run: | python -m pip install --upgrade pip pip install tox - - name: Lint - run: tox -epep8 - name: Unit Tests run: tox -epy3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..c315ac43 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: remove-tabs + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: check-merge-conflict + - id: end-of-file-fixer + - id: check-added-large-files + - id: check-case-conflict + - id: detect-private-key + - id: check-yaml + args: [--allow-multiple-documents] + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.1 + hooks: + - id: ruff + args: [ --fix ] + - id: ruff-format