Skip to content

Commit 5741212

Browse files
chore: more modernizing (#33)
* chore: more modernizing Signed-off-by: Henry Schreiner <[email protected]> * style: pre-commit fixes --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f8022a3 commit 5741212

File tree

4 files changed

+69
-44
lines changed

4 files changed

+69
-44
lines changed

.github/workflows/cd.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ concurrency:
1313
env:
1414
FORCE_COLOR: 3
1515

16+
permissions: {}
17+
1618
jobs:
1719
dist:
1820
name: Distribution build
@@ -22,9 +24,9 @@ jobs:
2224
- uses: actions/checkout@v4
2325
with:
2426
fetch-depth: 0
27+
persist-credentials: false
2528

26-
- name: Build sdist and wheel
27-
uses: hynek/build-and-inspect-python-package@v2
29+
- uses: hynek/build-and-inspect-python-package@v2
2830

2931
publish:
3032
needs: [dist]
@@ -34,6 +36,7 @@ jobs:
3436
url: https://pypi.org/p/dynamic-metadata
3537
permissions:
3638
id-token: write
39+
attestations: write
3740
runs-on: ubuntu-latest
3841
if: github.event_name == 'release' && github.event.action == 'published'
3942

@@ -43,4 +46,9 @@ jobs:
4346
name: Packages
4447
path: dist
4548

49+
- name: Generate artifact attestation for sdist and wheel
50+
uses: actions/attest-build-provenance@v2
51+
with:
52+
subject-path: "dist/*"
53+
4654
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/ci.yml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,69 @@ concurrency:
1414
env:
1515
FORCE_COLOR: 3
1616

17+
permissions: {}
18+
1719
jobs:
1820
pre-commit:
1921
name: Format
2022
runs-on: ubuntu-latest
23+
timeout-minutes: 8
2124
steps:
2225
- uses: actions/checkout@v4
2326
with:
2427
fetch-depth: 0
28+
persist-credentials: false
2529
- uses: actions/setup-python@v5
2630
with:
27-
python-version: "3.x"
28-
- uses: pre-commit/[email protected]
31+
python-version: "3.13"
32+
- uses: astral-sh/setup-uv@v5
33+
- uses: actions/cache@v4
2934
with:
30-
extra_args: --hook-stage manual --all-files
35+
path: ~/.cache/pre-commit
36+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
37+
- name: Run pre-commit
38+
run:
39+
uvx --with pre-commit-uv pre-commit run --all-files
40+
--show-diff-on-failure
3141
- name: Run PyLint
32-
run: |
33-
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
34-
pipx run nox -s pylint
42+
run: uvx nox -s pylint -- --output-format=github
3543

3644
checks:
3745
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
3846
runs-on: ${{ matrix.runs-on }}
39-
needs: [pre-commit]
4047
strategy:
4148
fail-fast: false
4249
matrix:
43-
python-version: ["3.8", "3.11", "3.12"]
50+
python-version: ["3.13"]
4451
runs-on: [ubuntu-latest, macos-latest, windows-latest]
4552

4653
include:
47-
- python-version: pypy-3.9
54+
- python-version: pypy-3.10
55+
runs-on: ubuntu-latest
56+
- python-version: "3.11"
57+
runs-on: ubuntu-latest
58+
- python-version: "3.8"
4859
runs-on: ubuntu-latest
4960

5061
steps:
5162
- uses: actions/checkout@v4
5263
with:
5364
fetch-depth: 0
65+
persist-credentials: false
5466

5567
- uses: actions/setup-python@v5
5668
with:
5769
python-version: ${{ matrix.python-version }}
5870
allow-prereleases: true
5971

72+
- uses: astral-sh/setup-uv@v5
73+
6074
- name: Install package
61-
run: python -m pip install .[test]
75+
run: uv sync
6276

6377
- name: Test package
6478
run: >-
65-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
79+
uv run pytest -ra --cov --cov-report=xml --cov-report=term
6680
--durations=20
6781
6882
- name: Upload coverage report

noxfile.py

100644100755
Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
#!/usr/bin/env -S uv run -q
2+
3+
# /// script
4+
# dependencies = ["nox>=2025.2.9"]
5+
# ///
6+
17
from __future__ import annotations
28

39
import argparse
4-
import shutil
510
from pathlib import Path
611

712
import nox
813

9-
DIR = Path(__file__).parent.resolve()
14+
nox.needs_version = ">=2025.2.9"
15+
nox.options.default_venv_backend = "uv|virtualenv"
1016

11-
nox.options.sessions = ["lint", "pylint", "tests"]
17+
DIR = Path(__file__).parent.resolve()
18+
PYPROJECT = nox.project.load_toml("pyproject.toml")
19+
TEST_DEPS = nox.project.dependency_groups(PYPROJECT, "test")
20+
DOCS_DEPS = nox.project.dependency_groups(PYPROJECT, "docs")
1221

1322

1423
@nox.session
@@ -36,11 +45,11 @@ def tests(session: nox.Session) -> None:
3645
"""
3746
Run the unit and regular tests. Use --cov to activate coverage.
3847
"""
39-
session.install(".[test]")
48+
session.install("-e.", *TEST_DEPS)
4049
session.run("pytest", *session.posargs)
4150

4251

43-
@nox.session
52+
@nox.session(default=False)
4453
def docs(session: nox.Session) -> None:
4554
"""
4655
Build the docs. Pass "--serve" to serve.
@@ -56,7 +65,7 @@ def docs(session: nox.Session) -> None:
5665
if args.builder != "html" and args.serve:
5766
session.error("Must not specify non-HTML builder with --serve")
5867

59-
session.install(".[docs]")
68+
session.install("-e.", *DOCS_DEPS)
6069
session.chdir("docs")
6170

6271
if args.builder == "linkcheck":
@@ -83,7 +92,7 @@ def docs(session: nox.Session) -> None:
8392
session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
8493

8594

86-
@nox.session
95+
@nox.session(default=False)
8796
def build_api_docs(session: nox.Session) -> None:
8897
"""
8998
Build (regenerate) API docs.
@@ -102,15 +111,15 @@ def build_api_docs(session: nox.Session) -> None:
102111
)
103112

104113

105-
@nox.session
114+
@nox.session(default=False)
106115
def build(session: nox.Session) -> None:
107116
"""
108117
Build an SDist and wheel.
109118
"""
110119

111-
build_p = DIR.joinpath("build")
112-
if build_p.exists():
113-
shutil.rmtree(build_p)
114-
115120
session.install("build")
116121
session.run("python", "-m", "build")
122+
123+
124+
if __name__ == "__main__":
125+
nox.main()

pyproject.toml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@ dependencies = [
3333
"typing_extensions >=4.6; python_version<'3.11'",
3434
]
3535

36-
[project.optional-dependencies]
36+
[project.urls]
37+
Homepage = "https://github.com/scikit-build/dynamic-metadata"
38+
"Bug Tracker" = "https://github.com/scikit-build/dynamic-metadata/issues"
39+
Discussions = "https://github.com/scikit-build/dynamic-metadata/discussions"
40+
Changelog = "https://github.com/scikit-build/dynamic-metadata/releases"
41+
42+
[project.entry-points."validate_pyproject.tool_schema"]
43+
dynamic-metadata = "dynamic_metadata.schema:get_schema"
44+
45+
[dependency-groups]
3746
test = [
38-
"pytest >=6",
39-
"pytest-cov >=3",
40-
]
41-
dev = [
42-
"pytest >=6",
47+
"pytest >=7",
4348
"pytest-cov >=3",
4449
]
50+
dev = [{ include-group = "test" }]
4551
docs = [
4652
"sphinx>=4.0",
4753
"myst_parser>=0.13",
@@ -51,24 +57,12 @@ docs = [
5157
"furo",
5258
]
5359

54-
[project.urls]
55-
Homepage = "https://github.com/scikit-build/dynamic-metadata"
56-
"Bug Tracker" = "https://github.com/scikit-build/dynamic-metadata/issues"
57-
Discussions = "https://github.com/scikit-build/dynamic-metadata/discussions"
58-
Changelog = "https://github.com/scikit-build/dynamic-metadata/releases"
59-
6060
[tool.hatch]
6161
version.path = "src/dynamic_metadata/__init__.py"
62-
envs.default.dependencies = [
63-
"pytest",
64-
"pytest-cov",
65-
]
6662

67-
[project.entry-points."validate_pyproject.tool_schema"]
68-
dynamic-metadata = "dynamic_metadata.schema:get_schema"
6963

7064
[tool.pytest.ini_options]
71-
minversion = "6.0"
65+
minversion = "7.0"
7266
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
7367
xfail_strict = true
7468
filterwarnings = [

0 commit comments

Comments
 (0)