Skip to content

Commit 3cab725

Browse files
authored
Update repo and CI setup (#65)
* Add Django 6.0 * Add Python 3.13 * Add Python 3.14 * Drop Python 3.9 (EoL) * Use UV to manage CI processes * Drop binary test assets * Change PyPi release to OIDC * Setup pre-commit.ci over custom linter setup
1 parent 0b74f4a commit 3cab725

File tree

1,079 files changed

+222
-25803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,079 files changed

+222
-25803
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
4-
directory: "/"
5-
schedule:
6-
interval: daily
7-
- package-ecosystem: github-actions
8-
directory: "/"
9-
schedule:
10-
interval: daily
3+
- package-ecosystem: pip
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: github-actions
8+
directory: "/"
9+
schedule:
10+
interval: daily

.github/workflows/ci.yml

Lines changed: 35 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,98 @@
11
name: CI
2-
32
on:
43
push:
54
branches:
65
- main
76
pull_request:
8-
97
jobs:
10-
11-
lint:
12-
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
lint-command:
16-
- bandit -r . -x ./tests
17-
- black --check --diff .
18-
- flake8 .
19-
- isort --check-only --diff .
20-
- pydocstyle .
21-
steps:
22-
- uses: actions/checkout@v6
23-
- uses: actions/setup-python@v6
24-
with:
25-
python-version: "3.x"
26-
cache: 'pip'
27-
cache-dependency-path: 'pyproject.toml'
28-
- run: python -m pip install -e .[lint]
29-
- run: ${{ matrix.lint-command }}
30-
318
dist:
329
runs-on: ubuntu-latest
3310
steps:
3411
- uses: actions/checkout@v6
35-
- uses: actions/setup-python@v6
36-
with:
37-
python-version: "3.x"
38-
- run: python -m pip install --upgrade pip build wheel twine
39-
- run: python -m build --sdist --wheel
40-
- run: python -m twine check dist/*
12+
- uses: astral-sh/setup-uv@v7
13+
- run: uvx --from build pyproject-build --sdist --wheel
14+
- run: uvx twine check dist/*
4115
- uses: actions/upload-artifact@v6
4216
with:
4317
path: dist/*
44-
4518
pytest-python:
4619
name: PyTest
47-
needs:
48-
- lint
4920
strategy:
5021
matrix:
5122
python-version:
52-
- "3.9"
5323
- "3.10"
5424
- "3.11"
5525
- "3.12"
26+
- "3.13"
27+
- "3.14"
5628
django-version:
57-
- "4.2" # LTS
29+
- "5.2" # LTS
5830
runs-on: ubuntu-latest
5931
steps:
6032
- uses: actions/checkout@v6
61-
- name: Set up Python ${{ matrix.python-version }}
62-
uses: actions/setup-python@v6
33+
- uses: astral-sh/setup-uv@v7
6334
with:
6435
python-version: ${{ matrix.python-version }}
65-
- run: python -m pip install .[test]
66-
- run: python -m pip install django~=${{ matrix.django-version }}.0
67-
- run: python -m pytest
36+
- uses: actions/setup-node@v6
37+
with:
38+
node-version: "lts/*"
39+
- run: |
40+
cd tests
41+
npm install
42+
- run: uv run tests/manage.py collectstatic --noinput
43+
- run: uv run ${{ matrix.extras }} --with django~=${{ matrix.django-version }}.0 pytest
6844
- uses: codecov/codecov-action@v5
6945
with:
7046
flags: py${{ matrix.python-version }}
7147
token: ${{ secrets.CODECOV_TOKEN }}
72-
7348
pytest-django:
7449
name: PyTest
75-
needs:
76-
- lint
7750
strategy:
7851
matrix:
7952
python-version:
80-
- "3.11"
53+
- "3.12"
8154
django-version:
8255
# oldest LTS gets tested on all Python versions
8356
- "5.1"
8457
- "5.2"
58+
- "6.0"
8559
runs-on: ubuntu-latest
8660
steps:
8761
- uses: actions/checkout@v6
88-
- name: Set up Python ${{ matrix.python-version }}
89-
uses: actions/setup-python@v6
62+
- uses: astral-sh/setup-uv@v7
9063
with:
9164
python-version: ${{ matrix.python-version }}
92-
- run: python -m pip install .[test]
93-
- run: python -m pip install django~=${{ matrix.django-version }}.0
94-
- run: python -m pytest
65+
- uses: actions/setup-node@v6
66+
with:
67+
node-version: "lts/*"
68+
- run: |
69+
cd tests
70+
npm install
71+
- run: uv run tests/manage.py collectstatic --noinput
72+
- run: uv run ${{ matrix.extras }} --with django~=${{ matrix.django-version }}.0 pytest
9573
- uses: codecov/codecov-action@v5
9674
with:
9775
flags: dj${{ matrix.django-version }}
9876
token: ${{ secrets.CODECOV_TOKEN }}
99-
10077
pytest-extras:
10178
name: PyTest
102-
needs:
103-
- lint
10479
strategy:
10580
matrix:
10681
extras:
107-
- "whitenoise"
82+
- "--extra whitenoise"
10883
runs-on: ubuntu-latest
10984
steps:
11085
- uses: actions/checkout@v6
111-
- name: Set up Python ${{ matrix.python-version }}
112-
uses: actions/setup-python@v6
86+
- uses: astral-sh/setup-uv@v7
87+
- uses: actions/setup-node@v6
11388
with:
114-
python-version: 3.x
115-
- run: python -m pip install .[test,${{ matrix.extras }}]
116-
- run: python -m pytest
89+
node-version: "lts/*"
90+
- run: |
91+
cd tests
92+
npm install
93+
- run: uv run tests/manage.py collectstatic --noinput
94+
- run: uv run ${{ matrix.extras }} pytest
11795
- uses: codecov/codecov-action@v5
11896
with:
11997
flags: dj${{ matrix.extras }}
12098
token: ${{ secrets.CODECOV_TOKEN }}
121-
122-
codeql:
123-
name: CodeQL
124-
needs: [ dist, pytest-python, pytest-django ]
125-
runs-on: ubuntu-latest
126-
permissions:
127-
actions: read
128-
contents: read
129-
security-events: write
130-
strategy:
131-
fail-fast: false
132-
matrix:
133-
language: [ python ]
134-
steps:
135-
- name: Checkout
136-
uses: actions/checkout@v6
137-
- name: Initialize CodeQL
138-
uses: github/codeql-action/init@v4
139-
with:
140-
languages: ${{ matrix.language }}
141-
queries: +security-and-quality
142-
- name: Autobuild
143-
uses: github/codeql-action/autobuild@v4
144-
- name: Perform CodeQL Analysis
145-
uses: github/codeql-action/analyze@v4
146-
with:
147-
category: "/language:${{ matrix.language }}"

.github/workflows/release.yml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
name: Release
2-
32
on:
43
release:
54
types: [published]
6-
5+
workflow_dispatch:
6+
permissions:
7+
id-token: write
78
jobs:
8-
PyPi:
9-
9+
release-build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v6
13-
- uses: actions/setup-python@v6
14-
with:
15-
python-version: "3.x"
16-
- run: python -m pip install --upgrade pip build wheel twine
17-
- run: python -m build --sdist --wheel
18-
- run: python -m twine upload dist/*
19-
env:
20-
TWINE_USERNAME: __token__
21-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
12+
- uses: actions/checkout@v6
13+
- uses: actions/setup-python@v6
14+
with:
15+
python-version: "3.x"
16+
- run: python -m pip install --upgrade pip build wheel
17+
- run: python -m build --sdist --wheel
18+
- uses: actions/upload-artifact@v6
19+
with:
20+
name: release-dists
21+
path: dist/
22+
pypi-publish:
23+
runs-on: ubuntu-latest
24+
needs:
25+
- release-build
26+
permissions:
27+
id-token: write
28+
steps:
29+
- uses: actions/download-artifact@v7
30+
with:
31+
name: release-dists
32+
path: dist/
33+
- uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,6 @@ package-lock.json
169169

170170
# Django
171171
tests/staticfiles/
172+
173+
# Node.js
174+
node_modules/

.pre-commit-config.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: check-merge-conflict
9+
- id: check-ast
10+
- id: check-toml
11+
- id: check-yaml
12+
- id: debug-statements
13+
- id: end-of-file-fixer
14+
- id: name-tests-test
15+
args: ["--pytest-test-first"]
16+
exclude: ^tests\/(testapp\/|manage.py)
17+
- id: no-commit-to-branch
18+
args: [--branch, main]
19+
- repo: https://github.com/asottile/pyupgrade
20+
rev: v3.21.2
21+
hooks:
22+
- id: pyupgrade
23+
- repo: https://github.com/adamchainz/django-upgrade
24+
rev: 1.29.1
25+
hooks:
26+
- id: django-upgrade
27+
- repo: https://github.com/hukkin/mdformat
28+
rev: 1.0.0
29+
hooks:
30+
- id: mdformat
31+
additional_dependencies:
32+
- mdformat-ruff
33+
- mdformat-footnote
34+
- mdformat-gfm
35+
- mdformat-gfm-alerts
36+
- repo: https://github.com/astral-sh/ruff-pre-commit
37+
rev: v0.14.9
38+
hooks:
39+
- id: ruff-check
40+
args: [--fix, --exit-non-zero-on-fix]
41+
- id: ruff-format
42+
- repo: https://github.com/google/yamlfmt
43+
rev: v0.20.0
44+
hooks:
45+
- id: yamlfmt
46+
# See https://pre-commit.ci/
47+
ci:
48+
autoupdate_schedule: weekly
49+
skip:
50+
- no-commit-to-branch

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Django ESM
22

3+
<p align="center">
4+
<picture>
5+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/codingjoe/django-esm/raw/main/images/logo-dark.svg">
6+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/codingjoe/django-esm/raw/main/images/logo-light.svg">
7+
<img alt="Django ESM: NextGen JavaScript ESM module support for Django" src="https://github.com/codingjoe/django-esm/raw/main/images/logo-light.svg">
8+
</picture>
9+
</p>
10+
311
NextGen JavaScript ESM module support for Django.
412

513
[![PyPi Version](https://img.shields.io/pypi/v/django-esm.svg)](https://pypi.python.org/pypi/django-esm/)
@@ -8,11 +16,11 @@ NextGen JavaScript ESM module support for Django.
816

917
## Highlights
1018

11-
* easy transition
12-
* smart cache busting
13-
* no more bundling
14-
* native ESM support
15-
* local vendoring with npm
19+
- easy transition
20+
- smart cache busting
21+
- no more bundling
22+
- native ESM support
23+
- local vendoring with npm
1624

1725
## Setup
1826

django_esm/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def get_settings():
1111
(),
1212
{
1313
"PACKAGE_DIR": Path(getattr(settings, "BASE_DIR", "")),
14-
"STATIC_DIR": Path(getattr(settings, "STATIC_ROOT")) / "esm",
14+
"STATIC_DIR": Path(settings.STATIC_ROOT) / "esm",
1515
"STATIC_PREFIX": "esm",
1616
**getattr(settings, "ESM", {}),
1717
},

django_esm/management/commands/collectstatic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import subprocess # nosec
1+
import subprocess
22
import sys
33

44
from django.contrib.staticfiles.management.commands import collectstatic
@@ -18,7 +18,7 @@ def add_arguments(self, parser):
1818

1919
def handle(self, **options):
2020
if not options["no_esm"]:
21-
subprocess.check_call( # nosec
21+
subprocess.check_call( # noqa: S603, S607
2222
[
2323
"npx",
2424
"--yes",
@@ -35,9 +35,9 @@ def handle(self, **options):
3535
except ImportError:
3636
pass
3737
else:
38-
subprocess.check_call( # nosec
38+
subprocess.check_call( # noqa: S603
3939
[
40-
"python3",
40+
sys.executable,
4141
"-m",
4242
"whitenoise.compress",
4343
get_settings().STATIC_DIR,

django_esm/management/commands/esm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import subprocess # nosec
1+
import subprocess
22
import sys
33

44
from django.core.management import BaseCommand
@@ -26,7 +26,7 @@ def add_arguments(self, parser):
2626
)
2727

2828
def handle(self, *args, **options):
29-
subprocess.check_call( # nosec
29+
subprocess.check_call( # noqa: S603
3030
(
3131
[
3232
"npx",

django_esm/templatetags/esm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ def importmap():
4343
).open() as f:
4444
raw_importmap = json.load(f)
4545
importmap_json = _resolve_importmap_urls(raw_importmap)
46-
return mark_safe(importmap_json) # nosec
46+
return mark_safe(importmap_json) # noqa: S308

0 commit comments

Comments
 (0)