From 001b311e9899c61424b65a436113e9287c85f153 Mon Sep 17 00:00:00 2001 From: Arnav Choudhury Date: Wed, 22 Sep 2021 20:45:31 +0530 Subject: [PATCH] pre-commit will manage all the linting (#1447) Linting will be managed through tox instead of in a github action job. This will make require one to only maintain the pre-commit hooks in .pre-commit-config.yaml file and the same configuration will automatically run on ci.yaml (through tox) and get updated due to another github action (pre-commit-autoupdate.yaml) --- .github/workflows/ci.yml | 19 +------------------ .pre-commit-config.yaml | 7 ------- tox.ini | 17 +++++------------ 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 852295320e..2c53f2b03b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,28 +7,11 @@ on: branches: [master] jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install dependencies - run: python -m pip install flake8 isort black . djangorestframework - - name: Install and Run Pre-commit - uses: pre-commit/action@v2.0.3 - - name: Check for missing migrations - run: python manage.py makemigrations --check --dry-run - env: - DJSTRIPE_TEST_DB_VENDOR: sqlite -# todo remove lint job and manage everything in tox.ini # todo remove docs job and manage everything in tox.ini docs: runs-on: ubuntu-latest - needs: ["lint"] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 @@ -44,7 +27,7 @@ jobs: tests: runs-on: ubuntu-latest - needs: ["lint", "docs"] + needs: ["docs"] strategy: fail-fast: true matrix: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cf1cad547..c635dc9f84 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,10 +25,3 @@ repos: hooks: - id: flake8 additional_dependencies: [flake8-isort] - - -# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date -ci: - autoupdate_schedule: weekly - skip: [] - submodules: false diff --git a/tox.ini b/tox.ini index 9c08580119..e6ccb8bf70 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,7 @@ [tox] isolated_build = True envlist = + pre-commit py{36,37}-django{22,30,31,32}-{postgres,postgres-nativejson,mysql,sqlite} py{38,39}-django{22,30}-{postgres,postgres-nativejson,mysql,sqlite} py{38,39}-django{31,32,main}-{postgres,mysql,sqlite}{,-nativejson} @@ -10,7 +11,7 @@ skip_missing_interpreters = True python = 3.6: py36 3.7: py37 - 3.8: py38 + 3.8: py38, pre-commit 3.9: py39 [testenv] @@ -38,16 +39,10 @@ deps = pytest-django pytest-cov -[testenv:lint] +[testenv:pre-commit] skip_install = True -deps = - flake8 - isort - black -commands = - flake8 {toxinidir} {posargs} - isort {toxinidir} --check --diff - black {toxinidir} --check +deps = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure [pytest] @@ -78,5 +73,3 @@ max-line-length = 88 # todo add a section for docs -# todo add lint to gh-actions and envlist -# todo add a section for pre-commit