Skip to content

Commit

Permalink
✨ Adopt uv in CI (#444)
Browse files Browse the repository at this point in the history
## Description

This PR updates the CI configuration to use uv by Astral (the creators
of ruff), which is an extremely fast Python package installer and
resolver, written in Rust. It is sesigned as a drop-in replacement for
common pip and pip-tools workflows.
See https://github.com/astral-sh/uv

Similar to ruff, it is extremely fast and in very active development.
This should speed up any of the Python-based CI runs without much
confirguration overhead.

This PR refactors the `minimums` check to make use of `uv`'s
`--resolution=lowest-direct" feature. This allows us to completely get
rid of the `constraints.txt` file.
Furthermore, it makes use of the new versions of `mqt-core`'s reusable
workflows.

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.

---------

Signed-off-by: burgholzer <[email protected]>
  • Loading branch information
burgholzer authored Apr 12, 2024
1 parent e9eee05 commit ce706d2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ flag_management:
- name: python
paths:
- "src/mqt/**/*.py"
after_n_builds: 3
after_n_builds: 12
statuses:
- type: project
threshold: 0.5%
Expand Down
27 changes: 17 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import argparse
import os
import shutil
import sys
from typing import TYPE_CHECKING

Expand All @@ -12,6 +13,9 @@
if TYPE_CHECKING:
from collections.abc import Sequence

nox.needs_version = ">=2024.3.2"
nox.options.default_venv_backend = "uv|virtualenv"

nox.options.sessions = ["lint", "tests"]

PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]
Expand Down Expand Up @@ -46,6 +50,11 @@ def _run_tests(
if os.environ.get("CI", None) and sys.platform == "win32":
env["SKBUILD_CMAKE_ARGS"] = "-T ClangCL"

if shutil.which("cmake") is None and shutil.which("cmake3") is None:
session.install("cmake")
if shutil.which("ninja") is None:
session.install("ninja")

_extras = ["test", *extras]
if "--cov" in posargs:
_extras.append("coverage")
Expand All @@ -63,29 +72,27 @@ def tests(session: nox.Session) -> None:
_run_tests(session)


@nox.session()
@nox.session(reuse_venv=True, venv_backend="uv")
def minimums(session: nox.Session) -> None:
"""Test the minimum versions of dependencies."""
_run_tests(
session,
install_args=["--constraint=test/python/constraints.txt"],
install_args=["--resolution=lowest-direct"],
run_args=["-Wdefault"],
extras=["qiskit", "evaluation"],
)
session.run("pip", "list")
session.run("uv", "pip", "list")


@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
"""Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links."""
"""Build the docs. Use "--non-interactive" to avoid serving. Pass "-b linkcheck" to check links."""
parser = argparse.ArgumentParser()
parser.add_argument("--serve", action="store_true", help="Serve after building")
parser.add_argument("-b", dest="builder", default="html", help="Build target (default: html)")
args, posargs = parser.parse_known_args(session.posargs)

if args.builder != "html" and args.serve:
session.error("Must not specify non-HTML builder with --serve")

extra_installs = ["sphinx-autobuild"] if args.serve else []
serve = args.builder == "html" and session.interactive
extra_installs = ["sphinx-autobuild"] if serve else []
session.install(*BUILD_REQUIREMENTS, *extra_installs)
session.install("--no-build-isolation", "-ve.[docs]")
session.chdir("docs")
Expand All @@ -103,7 +110,7 @@ def docs(session: nox.Session) -> None:
*posargs,
)

if args.serve:
if serve:
session.run("sphinx-autobuild", *shared_args)
else:
session.run("sphinx-build", "--keep-going", *shared_args)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dynamic = ["version"]

[project.optional-dependencies]
test = ["pytest>=7", "mqt.qcec>=2.4.5", "mqt.qmap[visualization]"]
coverage = ["mqt.qmap[test]", "pytest-cov"]
coverage = ["mqt.qmap[test]", "pytest-cov>=4"]
docs = [
"furo>=2023.08.17",
"sphinx",
Expand Down
14 changes: 0 additions & 14 deletions test/python/constraints.txt

This file was deleted.

0 comments on commit ce706d2

Please sign in to comment.