diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23e9f8e94..966f896d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,20 +23,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - - name: Lint with flake8 - run: | - python -m pip install flake8 - flake8 . --statistics - name: Test with pytest run: | pip install pytest pip install pytest-cov pytest - - name: Lint with isort - run: | - pip install isort - isort . --check --diff - - name: Lint with yapf - run: | - pip install . - yapf . -vv --diff --recursive diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..1d11c2627 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,37 @@ +# Copyright (c) 2023 Sebastian Pipping +# Licensed under the Apache License Version 2.0 + +name: Run pre-commit + +# Drop permissions to minimum for security +permissions: + contents: read + +on: + pull_request: + push: + schedule: + - cron: '0 2 * * 5' # Every Friday at 2am + workflow_dispatch: + +jobs: + pre_commit_run: + name: Run pre-commit + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + + - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 + with: + python-version: 3.11 + + - name: Install yapf (to be available to pre-commit) + run: |- + pip install \ + --disable-pip-version-check \ + --no-warn-script-location \ + --user \ + . + echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}" + + - uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 049a1a2f5..b4adc7cb4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,10 @@ repos: hooks: - id: isort name: isort (python) + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 - repo: local hooks: - id: yapf diff --git a/README.rst b/README.rst index 8b6e78104..25e8c10d8 100644 --- a/README.rst +++ b/README.rst @@ -7,9 +7,13 @@ YAPF :alt: PyPI version .. image:: https://github.com/google/yapf/actions/workflows/ci.yml/badge.svg - :target: https://github.com/google/yapf/actions + :target: https://github.com/google/yapf/actions/workflows/ci.yml :alt: Build status +.. image:: https://github.com/google/yapf/actions/workflows/pre-commit.yml/badge.svg + :target: https://github.com/google/yapf/actions/workflows/pre-commit.yml + :alt: Run pre-commit + .. image:: https://coveralls.io/repos/google/yapf/badge.svg?branch=main :target: https://coveralls.io/r/google/yapf?branch=main :alt: Coverage status