Skip to content

Commit 19de742

Browse files
committed
uv in the noxfile and CI.
1 parent 8eed933 commit 19de742

File tree

2 files changed

+44
-33
lines changed

2 files changed

+44
-33
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,17 @@ name: CI
22

33
on:
44
push:
5+
branches-ignore:
6+
- "wip*"
7+
tags:
8+
- "v*"
59
pull_request:
6-
release:
7-
types: [published]
810
schedule:
911
# Daily at 6:43
1012
- cron: "43 6 * * *"
11-
12-
env:
13-
PIP_DISABLE_PIP_VERSION_CHECK: "1"
14-
PIP_NO_PYTHON_VERSION_WARNING: "1"
13+
workflow_dispatch:
1514

1615
jobs:
17-
pre-commit:
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: actions/checkout@v4
21-
- uses: actions/setup-python@v5
22-
with:
23-
python-version: "3.x"
24-
- uses: pre-commit/[email protected]
25-
2616
list:
2717
runs-on: ubuntu-latest
2818
outputs:
@@ -40,6 +30,7 @@ jobs:
4030
ci:
4131
needs: list
4232
runs-on: ${{ matrix.os }}
33+
4334
strategy:
4435
fail-fast: false
4536
matrix:
@@ -58,16 +49,19 @@ jobs:
5849
uses: actions/setup-python@v5
5950
with:
6051
python-version: |
61-
3.8
6252
3.9
6353
3.10
6454
3.11
6555
3.12
6656
3.13
6757
pypy3.10
6858
allow-prereleases: true
59+
60+
- name: Set up uv
61+
uses: hynek/setup-cached-uv@v2
6962
- name: Set up nox
7063
uses: wntrblm/[email protected]
64+
7165
- name: Run nox
7266
run: nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }}
7367

@@ -77,6 +71,7 @@ jobs:
7771
environment:
7872
name: PyPI
7973
url: https://pypi.org/p/jsonschema-specifications
74+
8075
permissions:
8176
contents: write
8277
id-token: write
@@ -87,10 +82,14 @@ jobs:
8782
uses: actions/setup-python@v5
8883
with:
8984
python-version: "3.x"
85+
- name: Set up uv
86+
uses: hynek/setup-cached-uv@v2
9087
- name: Install dependencies
91-
run: python -m pip install build
88+
run: uv pip install --system build
89+
9290
- name: Create packages
9391
run: python -m build .
92+
9493
- name: Publish to PyPI
9594
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
9695
uses: pypa/gh-action-pypi-publish@release/v1

noxfile.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,30 @@
99
DOCS = ROOT / "docs"
1010
PACKAGE = ROOT / "jsonschema_specifications"
1111

12+
REQUIREMENTS = dict(
13+
docs=DOCS / "requirements.txt",
14+
)
15+
REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other
16+
(path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values()
17+
]
18+
19+
SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"]
20+
LATEST = "3.12" # until 3.13 matures
1221

22+
nox.options.default_venv_backend = "uv|virtualenv"
1323
nox.options.sessions = []
1424

1525

16-
def session(default=True, **kwargs): # noqa: D103
26+
def session(default=True, python=LATEST, **kwargs): # noqa: D103
1727
def _session(fn):
1828
if default:
1929
nox.options.sessions.append(kwargs.get("name", fn.__name__))
20-
return nox.session(**kwargs)(fn)
30+
return nox.session(python=python, **kwargs)(fn)
2131

2232
return _session
2333

2434

25-
@session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3"])
35+
@session(python=SUPPORTED)
2636
def tests(session):
2737
"""
2838
Run the test suite with a corresponding Python version.
@@ -58,7 +68,7 @@ def style(session):
5868
Check Python code style.
5969
"""
6070
session.install("ruff")
61-
session.run("ruff", "check", ROOT)
71+
session.run("ruff", "check", ROOT, __file__)
6272

6373

6474
@session()
@@ -88,7 +98,7 @@ def docs(session, builder):
8898
"""
8999
Build the documentation using a specific Sphinx builder.
90100
"""
91-
session.install("-r", DOCS / "requirements.txt")
101+
session.install("-r", REQUIREMENTS["docs"])
92102
with TemporaryDirectory() as tmpdir_str:
93103
tmpdir = Path(tmpdir_str)
94104
argv = ["-n", "-T", "-W"]
@@ -123,15 +133,17 @@ def docs_style(session):
123133
@session(default=False)
124134
def requirements(session):
125135
"""
126-
Update the project's pinned requirements. Commit the result.
136+
Update the project's pinned requirements.
137+
138+
You should commit the result afterwards.
127139
"""
128-
session.install("pip-tools")
129-
for each in [DOCS / "requirements.in"]:
130-
session.run(
131-
"pip-compile",
132-
"--resolver",
133-
"backtracking",
134-
"--strip-extras",
135-
"-U",
136-
each.relative_to(ROOT),
137-
)
140+
if session.venv_backend == "uv":
141+
cmd = ["uv", "pip", "compile"]
142+
else:
143+
session.install("pip-tools")
144+
cmd = ["pip-compile", "--resolver", "backtracking", "--strip-extras"]
145+
146+
for each, out in REQUIREMENTS_IN:
147+
# otherwise output files end up with silly absolute path comments...
148+
relative = each.relative_to(ROOT)
149+
session.run(*cmd, "--upgrade", "--output-file", out, relative)

0 commit comments

Comments
 (0)