From 84615bdddb740f2eee728646d05528ed9ccdb5e6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 2 Oct 2024 15:25:34 -0400 Subject: [PATCH] ci: 3.13, attestations, and some modernization Signed-off-by: Henry Schreiner --- .github/workflows/cd.yml | 29 ++++++++++------------------- .github/workflows/ci.yml | 27 ++++++++++++++------------- .pre-commit-config.yaml | 14 +++----------- noxfile.py | 17 +++++++++-------- pyproject.toml | 11 ++++------- 5 files changed, 40 insertions(+), 58 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 4ad9bb20..a02fba13 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -9,29 +9,12 @@ on: jobs: dist: runs-on: ubuntu-latest - permissions: - id-token: write - attestations: write - contents: read steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Build SDist and wheel - run: pipx run build - - - name: Check metadata - run: pipx run twine check dist/* - - - name: Generate artifact attestation for sdist and wheel - uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3 - with: - subject-path: "dist/vector-*" - - - uses: actions/upload-artifact@v4 - with: - path: dist/* + - uses: hynek/build-and-inspect-python-package@v2 publish: needs: [dist] @@ -42,16 +25,22 @@ jobs: url: https://pypi.org/p/vector permissions: id-token: write + attestations: write steps: - uses: actions/download-artifact@v4 with: - name: artifact + name: Packages path: dist - name: List distributions to be deployed run: ls -l dist/ + - name: Generate artifact attestation for sdist and wheel + uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3 + with: + subject-path: "dist/vector-*" + - name: Verify sdist artifact attestation env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -63,3 +52,5 @@ jobs: run: gh attestation verify dist/vector-*.whl --repo ${{ github.repository }} - uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6fe21a7..62fc6970 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,7 @@ jobs: with: python-version: 3.x - name: PyLint - run: | - echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json" - pipx run nox -s pylint + run: pipx run nox -s pylint -- --format=github check-lite: runs-on: ubuntu-latest @@ -44,6 +42,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" name: Python ${{ matrix.python-version }} - Lite steps: - uses: actions/checkout@v4 @@ -51,12 +50,12 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - - name: Requirements check - run: python -m pip list + - uses: astral-sh/setup-uv@v3 - name: Test lite package - run: pipx run nox -s lite-${{ matrix.python-version.key || matrix.python-version }} --verbose + run: uvx nox -s lite-${{ matrix.python-version.key || matrix.python-version }} --verbose check-full: needs: [check-lite] @@ -70,6 +69,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" name: Python ${{ matrix.python-version }} - Full steps: - uses: actions/checkout@v4 @@ -78,15 +78,17 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Requirements check - run: python -m pip list + - uses: astral-sh/setup-uv@v3 + + - name: Install nox + run: uv tool install nox - name: Run doctests on Python 3.11 if: matrix.python-version == 3.11 - run: pipx run nox -s doctests-${{ matrix.python-version.key || matrix.python-version }} --verbose + run: nox -s doctests-${{ matrix.python-version.key || matrix.python-version }} --verbose - name: Test package and generate coverage report - run: pipx run nox -s coverage-${{ matrix.python-version.key || matrix.python-version }} --verbose + run: nox -s coverage-${{ matrix.python-version.key || matrix.python-version }} --verbose - name: Upload coverage report uses: codecov/codecov-action@v4.5.0 @@ -103,11 +105,10 @@ jobs: with: python-version: 3.8.13 - - name: Requirements check - run: python -m pip list + - uses: astral-sh/setup-uv@v3 - name: Check compute features - run: python -m pip install .[test,test-extras] + run: uv pip install --system .[test,test-extras] - name: Test package run: python -m pytest -ra -m dis --ignore tests/test_notebooks.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb4f02a2..dab0637c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,8 +42,8 @@ repos: - id: codespell exclude: ^docs/usage/intro.ipynb$ - - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v4.0.0-alpha.8" + - repo: https://github.com/rbubley/mirrors-prettier + rev: "v3.3.3" hooks: - id: prettier types_or: [yaml, markdown, html, css, scss, javascript, json] @@ -54,7 +54,7 @@ repos: hooks: - id: blacken-docs args: ["-E"] - additional_dependencies: [black==23.1.0] + additional_dependencies: [black~=24.0] - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 @@ -64,11 +64,3 @@ repos: - id: rst-backticks - id: rst-directive-colons - id: rst-inline-touching-normal - - - repo: https://github.com/nbQA-dev/nbQA - rev: 1.8.7 - hooks: - - id: nbqa-pyupgrade - args: ["--py37-plus"] - - id: nbqa-isort - args: ["--float-to-top"] diff --git a/noxfile.py b/noxfile.py index b95c18da..4024051c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,9 +5,10 @@ import nox nox.options.sessions = ["lint", "lite", "tests", "doctests"] +nox.needs_version = ">=2024.4.15" +nox.options.default_venv_backend = "uv|virtualenv" -ALL_PYTHON = ["3.8", "3.9", "3.10", "3.11", "3.12"] - +ALL_PYTHON = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] DIR = Path(__file__).parent.resolve() @@ -21,14 +22,14 @@ def lint(session: nox.Session) -> None: @nox.session(reuse_venv=True) def pylint(session: nox.Session) -> None: """Run pylint.""" - session.install("pylint~=2.14.0") + session.install("pylint") session.install("-e", ".") session.run("pylint", "src/vector/", *session.posargs) @nox.session(reuse_venv=True, python=ALL_PYTHON) def lite(session: nox.Session) -> None: - """Run the linter.""" + """Run lightweight tests.""" session.install("-e", ".[test]") session.run("pytest", "--ignore", "tests/test_notebooks.py", *session.posargs) @@ -45,7 +46,7 @@ def tests(session: nox.Session) -> None: ) -@nox.session(reuse_venv=True, python=ALL_PYTHON) +@nox.session(reuse_venv=True, python=ALL_PYTHON, default=False) def coverage(session: nox.Session) -> None: """Run tests and compute coverage.""" session.posargs.append("--cov=vector") @@ -59,7 +60,7 @@ def doctests(session: nox.Session) -> None: session.run("pytest", "--doctest-plus", "src/vector/", *session.posargs) -@nox.session(reuse_venv=True) +@nox.session(reuse_venv=True, default=False) def notebooks(session: nox.Session) -> None: """Run the notebook tests""" session.install("-e", ".[awkward,numba,test,sympy]") @@ -67,7 +68,7 @@ def notebooks(session: nox.Session) -> None: session.run("pytest", "tests/test_notebooks.py", *session.posargs) -@nox.session(reuse_venv=True) +@nox.session(reuse_venv=True, default=False) def docs(session: nox.Session) -> None: """Build the docs. Pass "serve" to serve.""" session.install("-e", ".[docs]") @@ -82,7 +83,7 @@ def docs(session: nox.Session) -> None: print("Unsupported argument to docs") -@nox.session(reuse_venv=True) +@nox.session(reuse_venv=True, default=False) def build(session: nox.Session) -> None: """Build an SDist and wheel.""" session.install("build") diff --git a/pyproject.toml b/pyproject.toml index a635003f..cfe33550 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Scientific/Engineering :: Mathematics", @@ -52,7 +53,7 @@ optional-dependencies.dev = [ "awkward>=2", "dask-awkward", "nox", - "numba>=0.57; python_version<'3.12'", + "numba>=0.57; python_version<'3.13'", "papermill>=2.4", "pytest>=6", "pytest-cov>=3", @@ -70,7 +71,7 @@ optional-dependencies.docs = [ "sphinx-math-dollar", ] optional-dependencies.numba = [ - "numba>=0.57; python_version<'3.12'", + "numba>=0.57; python_version<'3.13'", ] optional-dependencies.sympy = [ "sympy", @@ -98,11 +99,6 @@ entry-points.numba_extensions.init = "vector:register_numba" version.source = "vcs" build.hooks.vcs.version-file = "src/vector/_version.py" -[tool.ruff] -src = [ - "src", -] - [tool.ruff.lint] extend-select = [ "B", # flake8-bugbear @@ -122,6 +118,7 @@ extend-select = [ ignore = [ "PLR09", # Too many X "PLR2004", # Magic values + "ISC001", # Conflicts with formatter ] typing-modules = [ "vector._typeutils",