@@ -18,68 +18,18 @@ jobs:
1818 uses : actions/setup-python@v6
1919 with :
2020 python-version : " 3.10"
21-
22- - name : Detect changes in API reference
23- id : changed
24- shell : python
25- run : |
26- import os
27- import subprocess
28- import sys
29- from pathlib import Path
30-
31- sys.path.insert(0, ".github/utils")
32- from docstrings_checksum import docstrings_checksum
33-
34- def git(*args):
35- result = subprocess.run(["git", *args], capture_output=True, text=True)
36- return result.stdout.strip(), result.returncode
37-
38- runner_temp = os.environ["RUNNER_TEMP"]
39- base_sha, _ = git("rev-parse", "HEAD^1")
40-
41- # Check if pydoc config changed
42- _, exit_code = git("diff", "--quiet", f"{base_sha}...HEAD", "--", "pydoc/")
43- changed_api_ref = (exit_code != 0)
44-
45- if not changed_api_ref:
46- # Create base worktree for docstring comparison
47- base_worktree = os.path.join(runner_temp, "base")
48- _, return_code = git("worktree", "add", base_worktree, base_sha)
49- has_worktree = return_code == 0
50-
51-
52- # Check if docstrings changed
53- pr_docstrings_checksum = docstrings_checksum(Path(".").glob("haystack_experimental/**/*.py"))
54- base_docstrings_checksum = ""
55- if has_worktree:
56- base_docstrings_checksum = docstrings_checksum(Path(base_worktree).glob("haystack_experimental/**/*.py"))
57-
58- if base_docstrings_checksum != pr_docstrings_checksum:
59- changed_api_ref = True
60-
61- print(f"API reference changes: {changed_api_ref}")
62-
63- with open(os.environ["GITHUB_OUTPUT"], "a") as f:
64- f.write(f"changed_api_ref={changed_api_ref}\n")
65-
6621 - name : Install Hatch
67- if : steps.changed.outputs.changed_api_ref == 'true'
6822 run : pip install --upgrade hatch
6923
7024 - name : Generate API references
71- if : steps.changed.outputs.changed_api_ref == 'true'
72-
7325 run : hatch run docs
7426
7527 - name : Set up Node.js
76- if : steps.changed.outputs.changed_api_ref == 'true'
7728 uses : actions/setup-node@v6
7829 with :
7930 node-version : " 22"
8031
8132 - name : Run Docusaurus md/mdx checker
82- if : steps.changed.outputs.changed_api_ref == 'true'
8333 working-directory : pydoc/temp
8434 run : |
8535 npx docusaurus-mdx-checker -v || {
0 commit comments