Skip to content

Commit

Permalink
Moving stuff around in the linters, and adding ruff (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingbuzzman authored Apr 4, 2024
1 parent eefbc65 commit a6bc27c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 31 deletions.
43 changes: 29 additions & 14 deletions .github/workflows/_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
prepare-matrix:
name: Prepare Python/Django matrix
runs-on: ubuntu-latest
continue-on-error: true
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
Expand All @@ -20,6 +21,10 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install the linters
run: |
pip install --upgrade setuptools
python setup.py install_linters
- name: Generate matrix from setup.py
id: set-matrix
run: |
Expand Down Expand Up @@ -53,6 +58,24 @@ jobs:
print(f'::error ::{product} v{version}: EOL was {eol}')
elif eol_date - today < WARNING_DAYS:
print(f'::warning ::{product} v{version}: EOL is coming up on the {eol}')"
- name: iSort check
if: always()
run: isort --check .
- name: Black check
if: always()
run: black --config .black --check .
- name: Flake8 check
if: always()
run: flake8 .
- name: Ruff check
if: always()
run: ruff check .
- name: rst check
if: always()
run: rst-lint .
- name: Continue
if: always()
run: exit 0

tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -84,17 +107,9 @@ jobs:
run: pip install -e '.[test]'
- name: Run tests
run: pytest --cov django_squash --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,RUST
- name: Flake8 check
run: flake8
- name: iSort check
run: isort --check .
- name: Black check
run: black --config .black --check .
- name: rst check
run: rst-lint .
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# with:
# fail_ci_if_error: true
# token: ${{ secrets.CODECOV_TOKEN }}
# env_vars: OS,RUST
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Developing

.. code-block:: shell
docker run --rm -it -v .:/app -v django-squash-pip-cache:/root/.cache/pip -e PYTHONDONTWRITEBYTECODE=1 python:3.12 bash -c "cd app; pip install -e .[test]; echo \"alias linters=\\\"echo '> isort'; isort .; echo '> black'; black --config .black .; echo '> flake8'; flake8 .; echo '> rst-lint'; rst-lint README.rst docs/*\\\"\" >> ~/.bash_profile; printf '\n\n\nrun **pytest** to run tests, **linters** to run linters\n\n'; exec bash --init-file ~/.bash_profile"
docker run --rm -it -v .:/app -v django-squash-pip-cache:/root/.cache/pip -e PYTHONDONTWRITEBYTECODE=1 python:3.12 bash -c "cd app; pip install -e .[test,lint]; echo \"alias linters=\\\"echo '> isort'; isort .; echo '> black'; black --config .black .; echo '> ruff'; ruff check .;echo '> flake8'; flake8 .; echo '> rst-lint'; rst-lint README.rst docs/*\\\"\" >> ~/.bash_profile; printf '\n\n\nrun **pytest** to run tests, **linters** to run linters\n\n'; exec bash --init-file ~/.bash_profile"
Alternatively, you can also create a virtual environment and run

Expand Down Expand Up @@ -89,6 +89,7 @@ Alternatively, you can also create a virtual environment and run
isort .
black --config .black .
flake8 .
ruff check .
rst-lint .
.. _Django: http://djangoproject.com
Expand Down
49 changes: 33 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,44 @@

if __name__ == "__main__":
from setuptools import find_packages, setup
from setuptools.command.build_py import build_py as Command

extras_require = {
"lint": [
"black",
"flake8",
"flake8-tidy-imports",
"isort",
"pygments",
"restructuredtext-lint",
"ruff",
],
"test": [
"black", # tests need black also.
"build",
"ipdb",
"libcst",
"psycopg2-binary",
"pytest-cov",
"pytest-django",
],
}

class InstallLintersCommand(Command):
"""Custom build command to install ONLY the liners."""

def run(self):
req = " ".join(extras_require["lint"])
os.system(f"pip install {req}")

setup(
name="django_squash",
version="0.0.11",
description="A migration squasher that doesn't care how Humpty Dumpty was put together.",
long_description=README,
cmdclass={
"install_linters": InstallLintersCommand,
},
classifiers=[
# See https://pypi.org/pypi?%3Aaction=list_classifiers
"Development Status :: 5 - Production/Stable",
Expand Down Expand Up @@ -64,20 +96,5 @@
f"django>={MIN_DJANGO_VERSION}",
],
tests_require=[],
extras_require={
"test": [
"black",
"build",
"flake8",
"flake8-tidy-imports",
"ipdb",
"isort",
"libcst",
"psycopg2-binary",
"pytest-cov",
"pytest-django",
"restructuredtext-lint",
"setuptools",
],
},
extras_require=extras_require,
)

0 comments on commit a6bc27c

Please sign in to comment.