Skip to content

Commit 2f299b9

Browse files
committed
Use uv in CI.
1 parent e9bc018 commit 2f299b9

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,32 @@ on:
77
tags:
88
- "v*"
99
pull_request:
10-
release:
11-
types: [published]
1210
schedule:
1311
# Daily at 3:21
1412
- cron: "21 3 * * *"
1513
workflow_dispatch:
1614

17-
env:
18-
PIP_DISABLE_PIP_VERSION_CHECK: "1"
19-
PIP_NO_PYTHON_VERSION_WARNING: "1"
20-
2115
jobs:
22-
pre-commit:
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/checkout@v4
26-
- uses: actions/setup-python@v5
27-
with:
28-
python-version: "3.x"
29-
- uses: pre-commit/[email protected]
30-
3116
list:
3217
runs-on: ubuntu-latest
3318
outputs:
3419
noxenvs: ${{ steps.noxenvs-matrix.outputs.noxenvs }}
3520
steps:
3621
- uses: actions/checkout@v4
37-
- name: Set up nox
38-
uses: wntrblm/[email protected]
22+
- name: Set up uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
enable-cache: true
3926
- id: noxenvs-matrix
4027
run: |
4128
echo >>$GITHUB_OUTPUT noxenvs=$(
42-
nox --list-sessions --json | jq '[.[].session]'
29+
uvx nox --list-sessions --json | jq '[.[].session]'
4330
)
4431
4532
ci:
4633
needs: list
4734
runs-on: ${{ matrix.os }}
35+
4836
strategy:
4937
fail-fast: false
5038
matrix:
@@ -53,10 +41,10 @@ jobs:
5341
posargs: [""]
5442
include:
5543
- os: ubuntu-latest
56-
noxenv: "tests-3.11(format)"
44+
noxenv: "tests-3.13(format)"
5745
posargs: coverage github
5846
- os: ubuntu-latest
59-
noxenv: "tests-3.11(no-extras)"
47+
noxenv: "tests-3.13(no-extras)"
6048
posargs: coverage github
6149
exclude:
6250
- os: windows-latest
@@ -89,20 +77,25 @@ jobs:
8977
3.13
9078
pypy3.10
9179
allow-prereleases: true
92-
- name: Set up nox
93-
uses: wntrblm/[email protected]
9480
- name: Enable UTF-8 on Windows
9581
run: echo "PYTHONUTF8=1" >> $env:GITHUB_ENV
9682
if: runner.os == 'Windows' && startsWith(matrix.noxenv, 'tests')
83+
84+
- name: Set up uv
85+
uses: astral-sh/setup-uv@v5
86+
with:
87+
enable-cache: true
88+
9789
- name: Run nox
98-
run: nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }}
90+
run: uvx nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }}
9991

10092
packaging:
10193
needs: ci
10294
runs-on: ubuntu-latest
10395
environment:
10496
name: PyPI
10597
url: https://pypi.org/p/jsonschema
98+
10699
permissions:
107100
contents: write
108101
id-token: write
@@ -111,14 +104,14 @@ jobs:
111104
- uses: actions/checkout@v4
112105
with:
113106
fetch-depth: 0
114-
- name: Set up Python
115-
uses: actions/setup-python@v5
107+
- name: Set up uv
108+
uses: astral-sh/setup-uv@v5
116109
with:
117-
python-version: "3.x"
118-
- name: Install dependencies
119-
run: python -m pip install build
120-
- name: Create packages
121-
run: python -m build .
110+
enable-cache: true
111+
112+
- name: Build our distributions
113+
run: uv run --with 'build[uv]' -m build --installer=uv
114+
122115
- name: Publish to PyPI
123116
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
124117
uses: pypa/gh-action-pypi-publish@release/v1

noxfile.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
docs=DOCS / "requirements.txt",
2323
)
2424
REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other
25-
path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values()
25+
(path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values()
2626
]
2727

2828
NONGPL_LICENSES = [
@@ -38,6 +38,7 @@
3838
SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"]
3939
LATEST_STABLE = SUPPORTED[-1]
4040

41+
nox.options.default_venv_backend = "uv|virtualenv"
4142
nox.options.sessions = []
4243

4344

@@ -136,9 +137,15 @@ def build(session):
136137
"""
137138
Build a distribution suitable for PyPI and check its validity.
138139
"""
139-
session.install("build", "docutils", "twine")
140+
session.install("build[uv]", "docutils", "twine")
140141
with TemporaryDirectory() as tmpdir:
141-
session.run("python", "-m", "build", ROOT, "--outdir", tmpdir)
142+
session.run(
143+
"pyproject-build",
144+
"--installer=uv",
145+
ROOT,
146+
"--outdir",
147+
tmpdir,
148+
)
142149
session.run("twine", "check", "--strict", tmpdir + "/*")
143150
session.run(
144151
"python", "-m", "docutils", "--strict", CHANGELOG, os.devnull,
@@ -247,13 +254,13 @@ def requirements(session):
247254
248255
You should commit the result afterwards.
249256
"""
250-
session.install("pip-tools")
251-
for each in REQUIREMENTS_IN:
252-
session.run(
253-
"pip-compile",
254-
"--resolver",
255-
"backtracking",
256-
"--strip-extras",
257-
"-U",
258-
each.relative_to(ROOT),
259-
)
257+
if session.venv_backend == "uv":
258+
cmd = ["uv", "pip", "compile"]
259+
else:
260+
session.install("pip-tools")
261+
cmd = ["pip-compile", "--resolver", "backtracking", "--strip-extras"]
262+
263+
for each, out in REQUIREMENTS_IN:
264+
# otherwise output files end up with silly absolute path comments...
265+
relative = each.relative_to(ROOT)
266+
session.run(*cmd, "--upgrade", "--output-file", out, relative)

0 commit comments

Comments
 (0)