diff --git a/src/sp_repo_review/checks/readthedocs.py b/src/sp_repo_review/checks/readthedocs.py index 4f69c56d..420449a6 100644 --- a/src/sp_repo_review/checks/readthedocs.py +++ b/src/sp_repo_review/checks/readthedocs.py @@ -98,6 +98,8 @@ def check(readthedocs: dict[str, Any]) -> bool: match readthedocs: case {"build": {"tools": {"python": object()}}}: return True + case {"build": {"jobs": object()}}: + return True case {"build": {"commands": object()}}: return True case _: @@ -112,8 +114,10 @@ class RTD104(ReadTheDocs): @staticmethod def check(readthedocs: dict[str, Any]) -> bool: """ - You must set `sphinx: configuration:`, `mkdocs: configuration:` or - `build: commands:`. Skipping it is no longer allowed. Example: + You must set `sphinx: configuration:`, `mkdocs: configuration:`, + `build: commands:`, or `build: jobs:`. Skipping it is no longer allowed. + Note: `build: jobs:` is preferred over `build: commands:`. + Example: ```yaml sphinx: @@ -122,6 +126,8 @@ def check(readthedocs: dict[str, Any]) -> bool: """ match readthedocs: + case {"build": {"jobs": dict()}}: + return True case {"build": {"commands": list()}}: return True case {"sphinx": {"configuration": str()}}: diff --git a/tests/test_readthedocs.py b/tests/test_readthedocs.py index 7b6a11e2..118e014e 100644 --- a/tests/test_readthedocs.py +++ b/tests/test_readthedocs.py @@ -61,9 +61,62 @@ def test_rtd103_commands() -> None: assert compute_check("RTD103", readthedocs=readthedocs).result +def test_rtd103_jobs() -> None: + readthedocs = yaml.safe_load(""" + build: + jobs: + pre_build: + - echo "pre build" + """) + assert compute_check("RTD103", readthedocs=readthedocs).result + + def test_rtd103_false() -> None: readthedocs = yaml.safe_load(""" build: os: ubuntu-22.04 """) assert not compute_check("RTD103", readthedocs=readthedocs).result + + +def test_rtd104_sphinx() -> None: + readthedocs = yaml.safe_load(""" + sphinx: + configuration: docs/conf.py + """) + assert compute_check("RTD104", readthedocs=readthedocs).result + + +def test_rtd104_mkdocs() -> None: + readthedocs = yaml.safe_load(""" + mkdocs: + configuration: mkdocs.yml + """) + assert compute_check("RTD104", readthedocs=readthedocs).result + + +def test_rtd104_commands() -> None: + readthedocs = yaml.safe_load(""" + build: + commands: + - echo "build" + """) + assert compute_check("RTD104", readthedocs=readthedocs).result + + +def test_rtd104_jobs() -> None: + readthedocs = yaml.safe_load(""" + build: + jobs: + pre_build: + - echo "pre build" + """) + assert compute_check("RTD104", readthedocs=readthedocs).result + + +def test_rtd104_false() -> None: + readthedocs = yaml.safe_load(""" + build: + os: ubuntu-22.04 + """) + assert not compute_check("RTD104", readthedocs=readthedocs).result