Skip to content

Commit 4dbcb66

Browse files
committed
Added a test to make sure the documentation requirements file is up to date
1 parent 1ebe689 commit 4dbcb66

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

noxfile.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import platform
1010
import re
11+
from difflib import unified_diff
1112
from pathlib import Path
1213

1314
import nox
@@ -95,6 +96,19 @@ def check_development_environment(session: Session) -> None:
9596
Update with 'poetry install --sync', using '--with' and '-E' for optional dependencies, extras respectively.
9697
Note: {removals} packages are not in the specification (i.e. installed manually) and may be removed.
9798
To preview changes, run 'poetry install --sync --dry-run' (with optional dependencies and extras).""")
99+
100+
@session # to only run on the current python interpreter
101+
def check_requirements_files(session: Session) -> None:
102+
"""Check whether the requirement files are not outdated."""
103+
doc_requirements_path = Path("doc/requirements.txt")
104+
doc_temp_requirements_path = Path("doc/test_requirements.txt")
105+
if doc_temp_requirements_path.exists():
106+
doc_temp_requirements_path.unlink()
107+
session.run("poetry", "export", "--with", "docs", "--without-hashes", "--format=requirements.txt", "--output", str(doc_temp_requirements_path), external=True)
108+
diff = list(unified_diff(doc_requirements_path.read_text(), doc_temp_requirements_path.read_text()))
109+
if doc_temp_requirements_path.exists():
110+
doc_temp_requirements_path.unlink()
111+
assert len(diff) == 0, f"Documentation requirements file not up to date with poetry.lock, please update it.\nDiff: {diff}"
98112

99113
@session(python=python_versions_to_test) # missing versions can be installed with `pyenv install ...`
100114
# do not forget check / set the versions with `pyenv global`, or `pyenv local` in case of virtual environment

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ cuda_opencl = ["pycuda", "pyopencl"]
9191
hip = ["pyhip-interface"]
9292
tutorial = ["jupyter", "matplotlib", "nvidia-ml-py"]
9393

94-
# ATTENTION: if anything is changed here, run `poetry update` and `poetry export --with docs --without-hashes --format=requirements.txt > doc/requirements.txt`
94+
# ATTENTION: if anything is changed here, run `poetry update` and `poetry export --with docs --without-hashes --format=requirements.txt --output doc/requirements.txt`
9595
# Please note that there is overlap with the `dev` group
9696
[tool.poetry.group.docs]
9797
optional = true

0 commit comments

Comments
 (0)