Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use uv #564

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ concurrency:
cancel-in-progress: true

jobs:
pre-commit:
pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Setup uv
uses: yezz123/setup-uv@v4
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.1
uv-venv: ".venv"
- name: Install nox
run: uv pip install nox
- name: PyLint
run: |
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
pipx run nox -s pylint
nox -s pylint

checks:
runs-on: ubuntu-latest
Expand All @@ -38,6 +40,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"

name: Check Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
Expand All @@ -47,19 +50,22 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Setup uv
uses: yezz123/setup-uv@v4
with:
uv-venv: ".venv"

- name: Requirements check
run: python -m pip list
run: uv pip list

- name: Install package
run: python -m pip install -e ".[test]"
run: uv pip install -e ".[test]"

- name: Test package
run: python -m pytest

- name: Install plotting requirements too
if: matrix.python-version != '3.12'
run: python -m pip install -e ".[test,plot]"
run: uv pip install -e ".[test,plot]"

- name: Test plotting too
if: matrix.python-version != '3.12'
run: python -m pytest --mpl
18 changes: 7 additions & 11 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import nox

ALL_PYTHONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "tests"]

nox.options.default_venv_backend = "uv|virtualenv"

DIR = Path(__file__).parent.resolve()

Expand All @@ -35,7 +34,7 @@ def pylint(session: nox.Session) -> None:
session.run("pylint", "hist", *session.posargs)


@nox.session(python=ALL_PYTHONS, reuse_venv=True)
@nox.session(reuse_venv=True)
def tests(session):
"""
Run the unit and regular tests.
Expand Down Expand Up @@ -102,12 +101,9 @@ def build(session):
Build an SDist and wheel.
"""

build_p = DIR.joinpath("build")
if build_p.exists():
shutil.rmtree(build_p)

session.install("build")
session.run("python", "-m", "build")
args = [] if shutil.which("uv") else ["uv"]
session.install("build==1.2.0", *args)
session.run("python", "-m", "build", "--installer=uv")


@nox.session()
Expand All @@ -130,6 +126,6 @@ def boost(session):
session.chdir("boost-histogram")
session.install(".")
session.chdir(DIR)
session.install("-e.[test,plot]")
session.install("-e.[test,plot]", "pip")
session.run("pip", "list")
session.run("pytest", *session.posargs)
Loading