Skip to content

Commit

Permalink
ci: use uv (#564)
Browse files Browse the repository at this point in the history
Cuts the ci time in half.

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Mar 28, 2024
1 parent 75cc393 commit f842096
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/ci.yml
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
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)

0 comments on commit f842096

Please sign in to comment.