From c089601226e3d8972ab919755ddd1c4fb06b639a Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 18 Sep 2024 16:11:48 +0200 Subject: [PATCH] Fix prerelease CI (#85) * Fix prerelease CI * No pip cache * Simplify * ??? * !!! * YAML fun * Should be fine --- .github/workflows/ci.yml | 24 +++++++++--------------- noxfile.py | 18 ++++++++---------- pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2788151..9e07f71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,12 +23,10 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - cache: pip python-version: "3.x" + - uses: hynek/setup-cached-uv@v2 - - run: python -Im pip install --upgrade wheel nox - - - run: python -Im nox --session cog -- --check + - run: uvx nox --session cog -- --check build-package: name: Build & verify package @@ -72,15 +70,13 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true - uses: hynek/setup-cached-uv@v2 - - run: uv pip install --system nox - name: Run tests - run: | - python -Im nox \ - --python ${{ matrix.python-version }} \ - --tags tests \ - -- \ - --installpkg dist/*.whl + run: > + uvx nox + --python ${{ matrix.python-version }} + --tags tests + -- --installpkg dist/*.whl - name: Upload coverage data uses: actions/upload-artifact@v4 @@ -156,8 +152,7 @@ jobs: allow-prereleases: true - uses: hynek/setup-cached-uv@v2 - - run: uv pip install --system nox - - run: python -Im nox --session mypy + - run: uvx nox --session mypy docs: name: Build docs & run doctests @@ -183,8 +178,7 @@ jobs: # [[[end]]] - uses: hynek/setup-cached-uv@v2 - - run: uv pip install --system nox - - run: python -Im nox --session docs + - run: uvx nox --session docs install-dev: name: Verify dev env on ${{ matrix.os }} diff --git a/noxfile.py b/noxfile.py index d995722..10dd5fe 100644 --- a/noxfile.py +++ b/noxfile.py @@ -67,7 +67,7 @@ def pre_commit(session: nox.Session) -> None: session.run("pre-commit", "run", "--all-files") -def _get_pkg(posargs: list[str], cov: bool) -> tuple[str, list[str]]: +def _get_pkg(posargs: list[str]) -> tuple[str, list[str]]: """ Allow `--installpkg path/to/wheel.whl` to be passed. """ @@ -80,9 +80,7 @@ def _get_pkg(posargs: list[str], cov: bool) -> tuple[str, list[str]]: except ValueError: pkg = "." - extra = "cov" if cov else "tests" - - return f"{pkg}[{extra}]", posargs + return pkg, posargs def _cov(session: nox.Session, posargs: list[str]) -> None: @@ -94,24 +92,24 @@ def _cov(session: nox.Session, posargs: list[str]) -> None: @nox.session(python=RUN_UNDER_COVERAGE, tags=["tests"]) def tests_cov(session: nox.Session) -> None: - pkg, posargs = _get_pkg(session.posargs, cov=True) - session.install(pkg) + pkg, posargs = _get_pkg(session.posargs) + session.install(f"{pkg}[cov]") _cov(session, posargs) @nox.session(python=NOT_COVERAGE, tags=["tests"]) def tests(session: nox.Session) -> None: - pkg, posargs = _get_pkg(session.posargs, cov=False) - session.install(pkg) + pkg, posargs = _get_pkg(session.posargs) + session.install(f"{pkg}[tests]") session.run("pytest", *posargs) @nox.session(python=OLDEST_PYTHON, tags=["tests"]) def tests_oldest_attrs(session: nox.Session) -> None: - pkg, posargs = _get_pkg(session.posargs, cov=True) - session.install(pkg, f"attrs=={OLDEST_ATTRS}") + pkg, posargs = _get_pkg(session.posargs) + session.install(f"{pkg}[cov]", f"attrs=={OLDEST_ATTRS}") _cov(session, posargs) diff --git a/pyproject.toml b/pyproject.toml index 20759d8..dce37c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = ["attrs>=17.4.0", "importlib_metadata; python_version<'3.8'"] [project.optional-dependencies] tests = ["pytest", "moto"] -cov = ["environ-config[tests]", "coverage[toml]>=7.2.0"] +cov = ["environ-config[tests]", "coverage[toml]"] aws = ["boto3"] docs = [ "environ-config[aws]",