Skip to content

Commit b24a4ac

Browse files
authored
Nox and ci updates (#466)
* nox: cleanup and update the noxfile * ci: update flavours on dependabot updates * dependabot: group prs * ci: update to use uv * nox: fix typo * ci: avoid triggering post dependabot workflow
1 parent 21edea2 commit b24a4ac

5 files changed

Lines changed: 102 additions & 61 deletions

File tree

.github/dependabot.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ updates:
66
schedule:
77
interval: "weekly"
88
labels:
9-
- "maintenance"
9+
- "maintenance :construction:"
10+
groups:
11+
# Group all pip dependencies into one PR
12+
pip-dependencies:
13+
patterns:
14+
- "*"
1015
# Update via cruft
1116
ignore:
1217
- dependency-name: "mkdocs*"
@@ -19,7 +24,7 @@ updates:
1924
schedule:
2025
interval: "weekly"
2126
labels:
22-
- "maintenance"
27+
- "maintenance :construction:"
2328
# Update via cruft
2429
ignore:
2530
- dependency-name: "actions/checkout"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Post Dependabot Update
2+
on:
3+
pull_request:
4+
branches: [main]
5+
paths:
6+
- dev/**
7+
8+
jobs:
9+
auto-update:
10+
if: github.actor == 'dependabot[bot]'
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.head_ref }}
19+
20+
- uses: hynek/setup-cached-uv@v2
21+
22+
- name: Run tests
23+
run: uvx nox --sessions flavours-codegen
24+
25+
- name: Commit changes
26+
run: |
27+
git config user.name "github-actions[bot]"
28+
git config user.email "github-actions[bot]@users.noreply.github.com"
29+
git add upath/_flavour_sources.py
30+
git commit -m "Auto-update generated flavours" || echo "No changes"
31+
git push

.github/workflows/release.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,10 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23-
- name: Set up Python 3.10
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: '3.10'
27-
28-
- name: Upgrade pip and nox
29-
run: |
30-
pip install --upgrade pip nox
31-
pip --version
32-
nox --version
23+
- uses: hynek/setup-cached-uv@v2
3324

3425
- name: Build package
35-
run: nox -s build
26+
run: uvx nox -s build
3627

3728
- name: Upload package
3829
if: github.event_name == 'release'

.github/workflows/tests.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- uses: hynek/setup-cached-uv@v2
6060

6161
- name: Run tests
62-
run: uvx nox --sessions typesafety --python ${{ matrix.pyv }}
62+
run: uvx nox --sessions type-safety --python ${{ matrix.pyv }}
6363

6464
lint:
6565
runs-on: ubuntu-latest
@@ -70,19 +70,10 @@ jobs:
7070
with:
7171
fetch-depth: 0
7272

73-
- name: Set up Python
74-
uses: actions/setup-python@v5
75-
with:
76-
python-version: '3.10'
77-
78-
- name: Upgrade pip and nox
79-
run: |
80-
python -m pip install --upgrade pip nox
81-
pip --version
82-
nox --version
73+
- uses: hynek/setup-cached-uv@v2
8374

8475
- name: Lint code and check dependencies
85-
run: nox -s lint
76+
run: uvx nox -s lint
8677

8778
build:
8879
needs: [tests, lint]
@@ -93,16 +84,7 @@ jobs:
9384
with:
9485
fetch-depth: 0
9586

96-
- name: Set up Python
97-
uses: actions/setup-python@v5
98-
with:
99-
python-version: '3.10'
100-
101-
- name: Install dependencies
102-
run: |
103-
python -m pip install --upgrade pip nox
104-
pip --version
105-
nox --version
87+
- uses: hynek/setup-cached-uv@v2
10688

10789
- name: Build package
108-
run: nox -s build
90+
run: uvx nox -s build

noxfile.py

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,56 @@
22

33
import glob
44
import os
5+
import sys
56

67
import nox
78

89
nox.options.reuse_existing_virtualenvs = True
910
nox.options.error_on_external_run = True
1011

11-
nox.needs_version = ">=2024.3.2"
12-
nox.options.default_venv_backend = "uv|virtualenv"
12+
nox.needs_version = ">=2024.04.15"
13+
nox.options.default_venv_backend = "uv"
1314

14-
nox.options.sessions = "lint", "tests"
15+
nox.options.sessions = "lint", "tests", "type-checking", "type-safety"
1516
locations = ("upath",)
1617
running_in_ci = os.environ.get("CI", "") != ""
1718

19+
SUPPORTED_PYTHONS = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
20+
BASE_PYTHON = SUPPORTED_PYTHONS[-3]
21+
MIN_PYTHON = SUPPORTED_PYTHONS[0]
22+
23+
24+
@(lambda f: f())
25+
def FSSPEC_MIN_VERSION() -> str:
26+
"""Get the minimum fsspec version boundary from pyproject.toml."""
27+
try:
28+
from packaging.requirements import Requirement
29+
30+
if sys.version_info >= (3, 11):
31+
from tomllib import load as toml_load
32+
else:
33+
from tomli import load as toml_load
34+
except ImportError:
35+
raise RuntimeError(
36+
"We rely on nox>=2024.04.15 depending on `packaging` and `tomli/tomllib`."
37+
" Please report if you see this error."
38+
)
39+
40+
with open("pyproject.toml", "rb") as f:
41+
pyproject_data = toml_load(f)
42+
43+
for requirement in pyproject_data["project"]["dependencies"]:
44+
req = Requirement(requirement)
45+
if req.name == "fsspec":
46+
for specifier in req.specifier:
47+
if specifier.operator == ">=":
48+
return str(specifier.version)
49+
raise RuntimeError("Could not find fsspec minimum version in pyproject.toml")
50+
1851

19-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"])
52+
@nox.session(python=SUPPORTED_PYTHONS)
2053
def tests(session: nox.Session) -> None:
54+
"""Run the test suite."""
2155
# workaround in case no aiohttp binary wheels are available
2256
if session.python == "3.14":
2357
session.env["AIOHTTP_NO_EXTENSIONS"] = "1"
@@ -36,9 +70,9 @@ def tests(session: nox.Session) -> None:
3670
)
3771

3872

39-
@nox.session(python="3.9", name="tests-minversion")
73+
@nox.session(python=MIN_PYTHON, name="tests-minversion")
4074
def tests_minversion(session: nox.Session) -> None:
41-
session.install("fsspec==2024.5.0", ".[tests,dev]")
75+
session.install(f"fsspec=={FSSPEC_MIN_VERSION}", ".[tests,dev]")
4276
session.run("uv", "pip", "freeze", silent=not running_in_ci)
4377
session.run(
4478
"pytest",
@@ -51,8 +85,12 @@ def tests_minversion(session: nox.Session) -> None:
5185
)
5286

5387

88+
tests_minversion.__doc__ = f"Run the test suite with fsspec=={FSSPEC_MIN_VERSION}."
89+
90+
5491
@nox.session
5592
def lint(session: nox.Session) -> None:
93+
"""Run pre-commit hooks."""
5694
session.install("pre-commit")
5795
session.install("-e", ".[tests]")
5896

@@ -70,6 +108,7 @@ def safety(session: nox.Session) -> None:
70108

71109
@nox.session
72110
def build(session: nox.Session) -> None:
111+
"""Build sdists and wheels."""
73112
session.install("build", "setuptools", "twine")
74113
session.run("python", "-m", "build")
75114
dists = glob.glob("dist/*")
@@ -79,31 +118,19 @@ def build(session: nox.Session) -> None:
79118
@nox.session
80119
def develop(session: nox.Session) -> None:
81120
"""Sets up a python development environment for the project."""
82-
args = session.posargs or ("venv",)
83-
venv_dir = os.fsdecode(os.path.abspath(args[0]))
84-
85-
session.log(f"Setting up virtual environment in {venv_dir}")
86-
session.install("virtualenv")
87-
session.run("virtualenv", venv_dir, silent=True)
121+
session.run("uv", "venv", external=True)
88122

89-
python = os.path.join(venv_dir, "bin/python")
90-
session.run(python, "-m", "pip", "install", "-e", ".[tests,dev]", external=True)
91123

92-
93-
@nox.session
94-
def black(session):
95-
print("please run `nox -s lint` instead")
96-
raise SystemExit(1)
97-
98-
99-
@nox.session
124+
@nox.session(name="type-checking", python=BASE_PYTHON)
100125
def type_checking(session):
126+
"""Run mypy checks."""
101127
session.install("-e", ".[typechecking]")
102128
session.run("python", "-m", "mypy")
103129

104130

105-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"])
106-
def typesafety(session):
131+
@nox.session(name="type-safety", python=SUPPORTED_PYTHONS)
132+
def type_safety(session):
133+
"""Run typesafety tests."""
107134
session.install("-e", ".[typechecking]")
108135
session.run(
109136
"python",
@@ -119,7 +146,12 @@ def typesafety(session):
119146
)
120147

121148

122-
@nox.session(python="3.12")
149+
@nox.session(name="flavours-upgrade-deps", python=BASE_PYTHON)
150+
def upgrade_flavours(session):
151+
session.run("uvx", "pur", "-r", "dev/requirements.txt")
152+
153+
154+
@nox.session(name="flavours-codegen", python=BASE_PYTHON)
123155
def generate_flavours(session):
124156
session.install("-r", "dev/requirements.txt")
125157
with open("upath/_flavour_sources.py", "w") as target:

0 commit comments

Comments
 (0)