Skip to content

Commit

Permalink
ci: 3.13, attestations, and some modernization
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Oct 2, 2024
1 parent 219f9ec commit 84615bd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 58 deletions.
29 changes: 10 additions & 19 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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 }}
Expand All @@ -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
27 changes: 14 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,19 +42,20 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
name: Python ${{ matrix.python-version }} - Lite
steps:
- uses: actions/checkout@v4

- 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]
Expand All @@ -70,6 +69,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
name: Python ${{ matrix.python-version }} - Full
steps:
- uses: actions/checkout@v4
Expand All @@ -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
Expand All @@ -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
Expand Down
14 changes: 3 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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"]
17 changes: 9 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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)

Expand All @@ -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")
Expand All @@ -59,15 +60,15 @@ 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]")
session.install("jupyter")
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]")
Expand All @@ -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")
Expand Down
11 changes: 4 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -122,6 +118,7 @@ extend-select = [
ignore = [
"PLR09", # Too many X
"PLR2004", # Magic values
"ISC001", # Conflicts with formatter
]
typing-modules = [
"vector._typeutils",
Expand Down

0 comments on commit 84615bd

Please sign in to comment.