Skip to content

Commit f235328

Browse files
Fix minimum requirements test
The test using minimum-requirements-ci.txt was broken. The minimum-requirements-ci.txt file was not being used in isolation because initially`all the dependencies were installed from the pyproject.toml file. So dependencies that were present in pyproject.toml but not in minimum-requirements-ci.txt won't have triggered an error when testing the minimum requirements. This patch generated a minimum dependencies list out of the dependencies defined in pyproject.toml file and uses it instead of minimum-requirements-ci.txt to avoid having differences between two different sources of minimum requirements/dependencies. Signed-off-by: Daniel Zullo <[email protected]>
1 parent 5bab9c0 commit f235328

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install required Python packages
3636
run: |
3737
python -m pip install --upgrade pip
38-
python -m pip install nox
38+
python -m pip install nox toml
3939
4040
- name: run nox
4141
run: nox -e ci_checks_max pytest_min

minimum-requirements-ci.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

noxfile.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@
1010
from typing import List
1111

1212
import nox
13+
import toml
14+
15+
16+
def min_dependencies() -> List[str]:
17+
"""Extract the minimum dependencies from pyproject.toml.
18+
19+
Raises:
20+
Exception: If minimun dependencies are not properly
21+
set in pyproject.toml.
22+
23+
Returns:
24+
the minimun dependencies defined in pyproject.toml.
25+
26+
"""
27+
with open("pyproject.toml", "r", encoding="utf-8") as toml_file:
28+
data = toml.load(toml_file)
29+
30+
dependencies = data.get("project", {}).get("dependencies", {})
31+
if not dependencies:
32+
raise Exception(f"No dependencies found in file: {toml_file.name}")
33+
34+
min_deps: List[str] = []
35+
for dep in dependencies:
36+
min_dep = dep.split(",")[0]
37+
if any(op in min_dep for op in (">=", "==")):
38+
min_deps.append(min_dep.replace(">=", "=="))
39+
else:
40+
raise Exception(f"Minimum requirement is not set: {dep}")
41+
return min_deps
42+
1343

1444
FMT_DEPS = ["black", "isort"]
1545
DOCSTRING_DEPS = ["pydocstyle", "darglint"]
@@ -22,6 +52,7 @@
2252
"async-solipsism",
2353
]
2454
MYPY_DEPS = ["mypy", "pandas-stubs", "grpc-stubs"]
55+
MIN_DEPS = min_dependencies()
2556

2657

2758
def _source_file_paths(session: nox.Session) -> List[str]:
@@ -220,7 +251,7 @@ def pytest_min(session: nox.Session, install_deps: bool = True) -> None:
220251
if install_deps:
221252
# install the package itself as editable, so that it is possible to do
222253
# fast local tests with `nox -R -e pytest_min`.
223-
session.install("-e", ".", *PYTEST_DEPS, "-r", "minimum-requirements-ci.txt")
254+
session.install("-e", ".", *PYTEST_DEPS, *MIN_DEPS)
224255

225256
_pytest_impl(session, "min")
226257

0 commit comments

Comments
 (0)