Skip to content

Commit

Permalink
Added a test to make sure the documentation requirements file is up t…
Browse files Browse the repository at this point in the history
…o date
  • Loading branch information
fjwillemsen committed Feb 8, 2024
1 parent 1ebe689 commit 4dbcb66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import platform
import re
from difflib import unified_diff
from pathlib import Path

import nox
Expand Down Expand Up @@ -95,6 +96,19 @@ def check_development_environment(session: Session) -> None:
Update with 'poetry install --sync', using '--with' and '-E' for optional dependencies, extras respectively.
Note: {removals} packages are not in the specification (i.e. installed manually) and may be removed.
To preview changes, run 'poetry install --sync --dry-run' (with optional dependencies and extras).""")

@session # to only run on the current python interpreter
def check_requirements_files(session: Session) -> None:
"""Check whether the requirement files are not outdated."""
doc_requirements_path = Path("doc/requirements.txt")
doc_temp_requirements_path = Path("doc/test_requirements.txt")
if doc_temp_requirements_path.exists():
doc_temp_requirements_path.unlink()
session.run("poetry", "export", "--with", "docs", "--without-hashes", "--format=requirements.txt", "--output", str(doc_temp_requirements_path), external=True)
diff = list(unified_diff(doc_requirements_path.read_text(), doc_temp_requirements_path.read_text()))
if doc_temp_requirements_path.exists():
doc_temp_requirements_path.unlink()
assert len(diff) == 0, f"Documentation requirements file not up to date with poetry.lock, please update it.\nDiff: {diff}"

@session(python=python_versions_to_test) # missing versions can be installed with `pyenv install ...`
# do not forget check / set the versions with `pyenv global`, or `pyenv local` in case of virtual environment
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cuda_opencl = ["pycuda", "pyopencl"]
hip = ["pyhip-interface"]
tutorial = ["jupyter", "matplotlib", "nvidia-ml-py"]

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

0 comments on commit 4dbcb66

Please sign in to comment.