Skip to content

Commit

Permalink
Merge pull request #244 from philgyford/ruff-and-django-5
Browse files Browse the repository at this point in the history
Drop Django 3.2, Add Django 5.0, use Ruff for linting and formatting
  • Loading branch information
philgyford authored Dec 12, 2023
2 parents 57ee6f6 + 48078fa commit 2267531
Show file tree
Hide file tree
Showing 108 changed files with 1,014 additions and 1,073 deletions.
40 changes: 17 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

name: Tests

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -16,21 +15,19 @@ jobs:

strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12-dev"]
django-version: ["3.2", "4.1", "4.2", "main"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13-dev"]
django-version: ["4.1", "4.2", "5.0", "main"]
exclude:
# Django 5.0 isn't compatible with python < 3.10
- python-version: "3.9"
django-version: "5.0"
- python-version: "3.9"
django-version: "main"

- python-version: "3.11"
django-version: "3.2"
- python-version: "3.12"
django-version: "4.1"

- python-version: "3.12-dev"
django-version: "3.2"
- python-version: "3.12-dev"
- python-version: "3.13-dev"
django-version: "4.1"

steps:
Expand All @@ -50,8 +47,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v2-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }}
key: ${{ matrix.python-version }}-v2-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v2-
Expand All @@ -68,15 +64,14 @@ jobs:
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3

# The flake8 test in tox.ini won't run with the test job so we need to add it here.
lint:
name: "Lint: ${{ matrix.toxenv }}"
ruff:
name: "Run ruff: ${{ matrix.toxenv }}"
runs-on: ubuntu-latest

strategy:
matrix:
toxenv:
- flake8
- ruff

steps:
- name: Git clone
Expand All @@ -85,7 +80,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Get pip cache dir
id: pip-cache
Expand All @@ -95,8 +90,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v2-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }}
key: ${{ matrix.python-version }}-v2-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v2-
Expand All @@ -112,11 +106,11 @@ jobs:
# https://github.com/8398a7/action-slack/issues/72#issuecomment-649910353
name: Slack notification
runs-on: ubuntu-latest
needs: [test, lint]
needs: [test, ruff]

# this is required, otherwise it gets skipped if any needed jobs fail.
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds
if: always() # Pick up events even if the job fails or is cancelled.
if: always() # Pick up events even if the job fails or is cancelled.

steps:
- uses: technote-space/workflow-conclusion-action@v1
Expand Down
37 changes: 18 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
python: python3.10
python: python3.11

exclude: |
(?x)^(
Expand All @@ -13,29 +13,28 @@ exclude: |
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v3.0.3
hooks:
- id: prettier
types_or:
- css
- javascript
- json
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
Loading

0 comments on commit 2267531

Please sign in to comment.