88
99jobs :
1010 detect-changes :
11- runs-on : ubuntu-latest
11+ runs-on : ubuntu-slim
1212 outputs :
1313 integrations : ${{ steps.changed.outputs.integrations }}
1414 steps :
1515 - uses : actions/checkout@v6
1616 with :
1717 fetch-depth : 0
1818
19- - name : Set up Python 3.13
19+ - name : Set up Python
2020 uses : actions/setup-python@v6
2121 with :
2222 python-version : " 3.13"
2626 shell : python
2727 env :
2828 BASE_SHA : ${{ github.event.pull_request.base.sha }}
29- RUNNER_TEMP : ${{ runner.temp }}
3029 run : |
3130 import json
3231 import os
@@ -44,45 +43,50 @@ jobs:
4443 result = subprocess.run(["git", *args], capture_output=True, text=True)
4544 return result.stdout.strip(), result.returncode
4645
47- # Find integrations with changed .py or config files
48- diff_output, _ = git("diff", "--name-only", f"{base_sha}...HEAD",
49- "--", "integrations/**/*.py", "integrations/**/config_docusaurus.yml")
50- candidates = sorted({Path(p).parts[1] for p in diff_output.splitlines() if p.startswith("integrations/")})
46+ # Get all changed files
47+ diff_output, _ = git(
48+ "diff", "--name-only", f"{base_sha}...HEAD", "--", "integrations"
49+ )
50+ changed_files = set(diff_output.splitlines())
51+
52+ # Extract integration names
53+ candidates = sorted({
54+ Path(p).parts[1]
55+ for p in changed_files
56+ if p.startswith("integrations/") and len(Path(p).parts) > 1
57+ })
5158
52- # Create base worktree once for docstring comparison
59+ # Create base worktree for docstring comparison
5360 base_worktree = os.path.join(runner_temp, "base")
54- _, rc = git("worktree", "add", base_worktree, base_sha)
55- has_worktree = rc == 0
61+ _, return_code = git("worktree", "add", base_worktree, base_sha)
62+ has_worktree = return_code == 0
5663
57- result = []
64+ changed_integrations = []
65+
5866 for integration in candidates:
5967 # If pydoc config changed, always include
60- config_diff, _ = git("diff", "--name-only", f"{base_sha}...HEAD",
61- "--", f"integrations/{integration}/pydoc/config_docusaurus.yml")
62- if config_diff:
63- result.append(integration)
68+ if f"integrations/{integration}/pydoc/config_docusaurus.yml" in changed_files:
69+ changed_integrations.append(integration)
6470 continue
6571
6672 # Otherwise, check if docstrings changed
67- pr_checksum = docstrings_checksum(Path(".").glob(f"integrations/{integration}/**/*.py"))
73+ pr_docstrings_checksum = docstrings_checksum(Path(".").glob(f"integrations/{integration}/**/*.py"))
74+ base_docstrings_checksum = ""
6875 if has_worktree:
69- base_checksum = docstrings_checksum(Path(base_worktree).glob(f"integrations/{integration}/**/*.py"))
70- else:
71- # Integration doesn't exist on the base branch (new integration)
72- base_checksum = ""
76+ base_docstrings_checksum = docstrings_checksum(Path(base_worktree).glob(f"integrations/{integration}/**/*.py"))
7377
74- if base_checksum != pr_checksum :
75- result .append(integration)
78+ if base_docstrings_checksum != pr_docstrings_checksum :
79+ changed_integrations .append(integration)
7680
7781 if has_worktree:
7882 git("worktree", "remove", base_worktree)
7983
80- print(f"Integrations with API reference changes: {json.dumps(result )}")
84+ print(f"Integrations with API reference changes: {json.dumps(changed_integrations )}")
8185
8286 with open(os.environ["GITHUB_OUTPUT"], "a") as f:
83- f.write(f"integrations={json.dumps(result )}\n")
87+ f.write(f"integrations={json.dumps(changed_integrations )}\n")
8488
85- generate-docs :
89+ test-api-reference-build :
8690 needs : detect-changes
8791 if : needs.detect-changes.outputs.integrations != '[]'
8892 runs-on : ubuntu-latest
@@ -107,34 +111,18 @@ jobs:
107111 hatch run docs
108112 # Save the generated file before the Haystack checkout overwrites the working tree
109113 cp ${{ matrix.integration }}.md "${{ runner.temp }}/${{ matrix.integration }}.md"
114+ # Also copy the Copy script to the temp directory
115+ cp .github/utils/copy_file_to_api_reference.py "${{ runner.temp }}/copy_file_to_api_reference.py"
110116
111- - name : Checkout Haystack repo
117+ - name : Checkout Haystack Docs Website
112118 uses : actions/checkout@v6
113119 with :
114120 repository : deepset-ai/haystack
115121 ref : main
116122 sparse-checkout : docs-website
117123
118- - name : Sync API reference
119- shell : python
120- env :
121- INTEGRATION_API_REFERENCE : ${{ runner.temp }}/${{ matrix.integration }}.md
122- run : |
123- import os
124- import shutil
125-
126- api_ref_file = os.environ['INTEGRATION_API_REFERENCE']
127-
128- # Copy to main API reference
129- shutil.copy(api_ref_file, "docs-website/reference/integrations-api/")
130-
131- # Copy to versioned API reference
132- for version_dir in os.scandir("docs-website/reference_versioned_docs"):
133- if version_dir.is_dir():
134- # example: docs-website/reference_versioned_docs/version-2.17/integrations-api
135- integrations_api_ref_dir = os.path.join(version_dir.path, "integrations-api")
136- shutil.copy(api_ref_file, integrations_api_ref_dir)
137-
124+ - name : Copy file to API reference
125+ run : python ${{ runner.temp }}/copy_file_to_api_reference.py ${{ runner.temp }}/${{ matrix.integration }}.md
138126 - name : Install Node.js
139127 uses : actions/setup-node@v6
140128 with :
0 commit comments