Skip to content

Commit 4b3c687

Browse files
move to using nox and uv (#135)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b7d8e0e commit 4b3c687

File tree

9 files changed

+1814
-235
lines changed

9 files changed

+1814
-235
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424

25-
- uses: actions/setup-python@v5
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
2627
with:
27-
python-version: "3.13"
28-
allow-prereleases: true
29-
30-
- name: Install dependencies
31-
run: |
32-
python -m pip install -U pip uv
33-
python -m uv pip install --system hatch
28+
enable-cache: true
29+
version: "0.4.x"
3430

3531
- name: Build package
3632
run: |
37-
hatch build
33+
uv build
3834
3935
- name: Publish to PyPI
4036
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424

25-
- uses: actions/setup-python@v5
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
2627
with:
27-
python-version: "3.8"
28-
allow-prereleases: true
28+
enable-cache: true
29+
version: "0.4.x"
2930

30-
- name: Install dependencies
31+
- name: Install Python
3132
run: |
32-
python -m pip install -U pip uv
33-
python -m uv pip install --system nox
33+
uv python install 3.10
3434
35-
- id: set-matrix
35+
- name: Generate matrix
36+
id: set-matrix
3637
run: |
37-
python -m nox --session "gha_matrix"
38+
uv run nox --session "gha_matrix"
3839
3940
test:
4041
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
@@ -46,19 +47,18 @@ jobs:
4647
steps:
4748
- uses: actions/checkout@v4
4849

49-
- uses: actions/setup-python@v5
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v3
5052
with:
51-
python-version: "${{ matrix.python-version }}"
52-
allow-prereleases: true
53+
enable-cache: true
54+
version: "0.4.x"
5355

54-
- name: Install dependencies
55-
run: |
56-
python -m pip install -U pip uv
57-
python -m uv pip install --system nox
56+
- name: Install Python
57+
run: uv python install ${{ matrix.python-version }}
5858

5959
- name: Run tests
6060
run: |
61-
nox --session "tests(python='${{ matrix.python-version }}', django='${{ matrix.django-version }}')"
61+
uv run nox --session "tests(python='${{ matrix.python-version }}', django='${{ matrix.django-version }}')"
6262
6363
tests:
6464
runs-on: ubuntu-latest
@@ -77,35 +77,31 @@ jobs:
7777
steps:
7878
- uses: actions/checkout@v4
7979

80-
- uses: actions/setup-python@v5
80+
- name: Install uv
81+
uses: astral-sh/setup-uv@v3
8182
with:
82-
python-version: "3.13"
83-
allow-prereleases: true
83+
enable-cache: true
84+
version: "0.4.x"
8485

85-
- name: Install dependencies
86+
- name: Install Python
8687
run: |
87-
python -m pip install -U pip uv
88-
python -m uv pip install --system nox
88+
uv python install 3.13
8989
90-
- name: Run mypy
90+
- name: Run type checks
9191
run: |
92-
python -m nox --session "mypy"
92+
uv run nox --session "types"
9393
9494
coverage:
9595
runs-on: ubuntu-latest
9696
steps:
9797
- uses: actions/checkout@v4
9898

99-
- uses: actions/setup-python@v5
99+
- name: Install uv
100+
uses: astral-sh/setup-uv@v3
100101
with:
101-
python-version: "3.8"
102-
allow-prereleases: true
103-
104-
- name: Install dependencies
105-
run: |
106-
python -m pip install -U pip uv
107-
python -m uv pip install --system nox
102+
enable-cache: true
103+
version: "0.4.x"
108104

109-
- name: Run coverage
105+
- name: Generate code coverage
110106
run: |
111-
python -m nox --session "coverage"
107+
uv run nox --session "coverage"

.just/copier.just

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
set unstable := true
2+
3+
justfile := justfile_directory() + "/.just/copier.just"
4+
5+
[private]
6+
default:
7+
@just --list --justfile {{ justfile }}
8+
9+
[private]
10+
fmt:
11+
@just --fmt --justfile {{ justfile }}
12+
13+
# Create a copier answers file
14+
[no-cd]
15+
copy TEMPLATE_PATH DESTINATION_PATH=".":
16+
uv run copier copy --trust {{ TEMPLATE_PATH }} {{ DESTINATION_PATH }}
17+
18+
# Recopy the project from the original template
19+
[no-cd]
20+
recopy ANSWERS_FILE *ARGS:
21+
uv run copier recopy --trust --answers-file {{ ANSWERS_FILE }} {{ ARGS }}
22+
23+
# Loop through all answers files and recopy the project using copier
24+
[no-cd]
25+
@recopy-all *ARGS:
26+
for file in `ls .copier/`; do just copier recopy .copier/$file "{{ ARGS }}"; done
27+
28+
# Update the project using a copier answers file
29+
[no-cd]
30+
update ANSWERS_FILE *ARGS:
31+
uv run copier update --trust --answers-file {{ ANSWERS_FILE }} {{ ARGS }}
32+
33+
# Loop through all answers files and update the project using copier
34+
[no-cd]
35+
@update-all *ARGS:
36+
for file in `ls .copier/`; do just copier update .copier/$file "{{ ARGS }}"; done

.just/documentation.just

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
set unstable := true
2+
3+
justfile := justfile_directory() + "/.just/documentation.just"
4+
5+
[private]
6+
default:
7+
@just --list --justfile {{ justfile }}
8+
9+
[private]
10+
fmt:
11+
@just --fmt --justfile {{ justfile }}
12+
13+
# Build documentation using Sphinx
14+
[no-cd]
15+
build LOCATION="docs/_build/html": cog
16+
uv run --extra docs sphinx-build docs {{ LOCATION }}
17+
18+
# Serve documentation locally
19+
[no-cd]
20+
serve PORT="8000": cog
21+
#!/usr/bin/env sh
22+
HOST="localhost"
23+
if [ -f "/.dockerenv" ]; then
24+
HOST="0.0.0.0"
25+
fi
26+
uv run --extra docs sphinx-autobuild docs docs/_build/html --host "$HOST" --port {{ PORT }}
27+
28+
[no-cd]
29+
[private]
30+
cog:
31+
uv run --extra docs cog -r docs/development/just.md

.readthedocs.yaml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,18 @@
44
version: 2
55

66
build:
7-
jobs:
8-
pre_build:
9-
- asdf plugin add just && asdf install just latest && asdf global just latest
10-
- just _cog
117
os: ubuntu-22.04
128
tools:
139
python: "3.12"
10+
commands:
11+
- asdf plugin add just && asdf install just latest && asdf global just latest
12+
- asdf plugin add uv && asdf install uv latest && asdf global uv latest
13+
- just docs cog
14+
- just docs build $READTHEDOCS_OUTPUT/html
1415

1516
sphinx:
16-
configuration: docs/conf.py
17+
configuration: docs/conf.py
1718

1819
formats:
19-
- pdf
20-
- epub
21-
22-
python:
23-
install:
24-
- method: pip
25-
path: .
26-
extra_requirements:
27-
- docs
20+
- pdf
21+
- epub

Justfile

Lines changed: 30 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,45 @@
11
set dotenv-load := true
2+
set unstable := true
23

3-
@_default:
4-
just --list
4+
mod copier ".just/copier.just"
5+
mod docs ".just/documentation.just"
56

6-
demo:
7-
python -m nox -session "demo"
8-
9-
# ----------------------------------------------------------------------
10-
# DEPENDENCIES
11-
# ----------------------------------------------------------------------
12-
13-
bootstrap:
14-
@just pup
15-
@just install
7+
[private]
8+
default:
9+
@just --list
1610

17-
install:
18-
python -m uv pip install --editable '.[dev]'
19-
20-
pup:
21-
python -m pip install --upgrade pip uv
22-
23-
# ----------------------------------------------------------------------
24-
# TESTING/TYPES
25-
# ----------------------------------------------------------------------
11+
[private]
12+
fmt:
13+
@just --fmt
14+
@just copier fmt
15+
@just docs fmt
2616

27-
test *ARGS:
28-
python -m nox --session "test" -- "{{ ARGS }}"
17+
[private]
18+
nox SESSION *ARGS:
19+
uv run nox --session "{{ SESSION }}" -- "{{ ARGS }}"
2920

30-
testall *ARGS:
31-
python -m nox --session "tests" -- "{{ ARGS }}"
21+
bootstrap:
22+
uv python install
23+
uv sync --frozen
3224

3325
coverage:
34-
python -m nox --session "coverage"
35-
36-
types:
37-
python -m nox --session "mypy"
38-
39-
# ----------------------------------------------------------------------
40-
# DJANGO
41-
# ----------------------------------------------------------------------
42-
43-
manage *COMMAND:
44-
#!/usr/bin/env python
45-
import sys
46-
47-
try:
48-
from django.conf import settings
49-
from django.core.management import execute_from_command_line
50-
except ImportError as exc:
51-
raise ImportError(
52-
"Couldn't import Django. Are you sure it's installed and "
53-
"available on your PYTHONPATH environment variable? Did you "
54-
"forget to activate a virtual environment?"
55-
) from exc
26+
@just nox coverage
5627

57-
settings.configure(INSTALLED_APPS=["django_simple_nav"])
58-
execute_from_command_line(sys.argv + "{{ COMMAND }}".split(" "))
59-
60-
alias mm := makemigrations
61-
62-
makemigrations *APPS:
63-
@just manage makemigrations {{ APPS }}
64-
65-
migrate *ARGS:
66-
@just manage migrate {{ ARGS }}
67-
68-
# ----------------------------------------------------------------------
69-
# DOCS
70-
# ----------------------------------------------------------------------
71-
72-
@docs-install:
73-
@just pup
74-
python -m uv pip install 'django-simple-nav[docs] @ .'
75-
76-
@docs-serve:
77-
#!/usr/bin/env sh
78-
just _cog
79-
if [ -f "/.dockerenv" ]; then
80-
sphinx-autobuild docs docs/_build/html --host "0.0.0.0"
81-
else
82-
sphinx-autobuild docs docs/_build/html --host "localhost"
83-
fi
84-
85-
@docs-build LOCATION="docs/_build/html":
86-
just _cog
87-
sphinx-build docs {{ LOCATION }}
88-
89-
_cog:
90-
cog -r docs/development/just.md
91-
92-
# ----------------------------------------------------------------------
93-
# UTILS
94-
# ----------------------------------------------------------------------
95-
96-
# format justfile
97-
fmt:
98-
just --fmt --unstable
28+
demo:
29+
@just nox demo
9930

100-
# run pre-commit on all files
10131
lint:
102-
python -m nox --session "lint"
32+
uv run --with pre-commit-uv pre-commit run --all-files
33+
just fmt
10334

104-
# ----------------------------------------------------------------------
105-
# COPIER
106-
# ----------------------------------------------------------------------
35+
lock *ARGS:
36+
uv lock {{ ARGS }}
10737

108-
# apply a copier template to project
109-
copier-copy TEMPLATE_PATH DESTINATION_PATH=".":
110-
copier copy {{ TEMPLATE_PATH }} {{ DESTINATION_PATH }}
38+
test *ARGS:
39+
@just nox test {{ ARGS }}
11140

112-
# update the project using a copier answers file
113-
copier-update ANSWERS_FILE *ARGS:
114-
copier update --trust --answers-file {{ ANSWERS_FILE }} {{ ARGS }}
41+
testall *ARGS:
42+
@just nox tests {{ ARGS }}
11543

116-
# loop through all answers files and update the project using copier
117-
@copier-update-all *ARGS:
118-
for file in `ls .copier/`; do just copier-update .copier/$file "{{ ARGS }}"; done
44+
types *ARGS:
45+
@just nox types {{ ARGS }}

0 commit comments

Comments
 (0)