Skip to content

Commit

Permalink
Fix prerelease CI (#85)
Browse files Browse the repository at this point in the history
* Fix prerelease CI

* No pip cache

* Simplify

* ???

* !!!

* YAML fun

* Should be fine
  • Loading branch information
hynek authored Sep 18, 2024
1 parent c99e121 commit c089601
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
18 changes: 8 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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:
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down

0 comments on commit c089601

Please sign in to comment.