-
Notifications
You must be signed in to change notification settings - Fork 210
ci: check that API references do not cause Docusaurus build failures #2829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+119
−2
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
3630d5a
draft
anakin87 2dfdeef
Merge branch 'main' into check-docusaurus-build
anakin87 c0d9981
trigger run
anakin87 aa2f391
evolve
anakin87 cca5390
improvs
anakin87 8ce0ff4
fix
anakin87 a945701
clean up
anakin87 69e33c8
save file
anakin87 a8901da
build step + trigger
anakin87 d1921d3
retry
anakin87 4d7c492
use python
anakin87 d136e51
improve
anakin87 9d2129d
script + simplify
anakin87 ff901e7
fix
anakin87 514dfb9
simulate new integration
anakin87 d282123
fix
anakin87 749d11a
refix
anakin87 773bc15
revert temp changes
anakin87 4fbbf2f
skip worktree removal
anakin87 02c8ac6
lighter setup + trigger
anakin87 708a09f
legit change
anakin87 1000947
rm temp change
anakin87 50ab9fa
try simplifying more
anakin87 7a52cfb
fail
anakin87 0b1a6c4
verbose
anakin87 ac82bd4
cat
anakin87 295150a
rm change
anakin87 cc71fbd
helpful err msg
anakin87 65d50da
revert Qdrant change
anakin87 1e565d1
small refinement
anakin87 2603db8
simplifications
anakin87 86509bb
triggers
anakin87 15e40d8
retry
anakin87 d887b82
fix workflow
anakin87 d0fcc79
rm triggers
anakin87 10a4da5
unify and test
anakin87 8609e44
use righ base_sha
anakin87 3eea31a
rm triggers
anakin87 3fd9c54
try new integr
anakin87 082881b
rm new int
anakin87 322abda
Merge branch 'main' into check-docusaurus-build
anakin87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import argparse | ||
| import sys | ||
| from pathlib import Path | ||
| import toml | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| name: Core / Check API reference changes | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "integrations/**/*.py" | ||
| - "integrations/**/config_docusaurus.yml" | ||
|
|
||
| jobs: | ||
| test-api-reference-build: | ||
| runs-on: ubuntu-slim | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.13" | ||
|
|
||
| - name: Detect integrations with API reference changes | ||
| id: changed | ||
| shell: python | ||
| run: | | ||
| import json | ||
| import os | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| sys.path.insert(0, ".github/utils") | ||
| from docstrings_checksum import docstrings_checksum | ||
|
|
||
| def git(*args): | ||
| result = subprocess.run(["git", *args], capture_output=True, text=True) | ||
| return result.stdout.strip(), result.returncode | ||
|
|
||
| runner_temp = os.environ["RUNNER_TEMP"] | ||
| base_sha, _ = git("rev-parse", "HEAD^1") | ||
|
|
||
| # Get all changed files | ||
| diff_output, _ = git( | ||
| "diff", "--name-only", f"{base_sha}...HEAD", "--", "integrations" | ||
| ) | ||
| changed_files = set(diff_output.splitlines()) | ||
|
|
||
| # Extract integration names | ||
| candidates = sorted({ | ||
| Path(p).parts[1] | ||
| for p in changed_files | ||
| if p.startswith("integrations/") and len(Path(p).parts) > 1 | ||
| }) | ||
|
|
||
| # Create base worktree for docstring comparison | ||
| base_worktree = os.path.join(runner_temp, "base") | ||
| _, return_code = git("worktree", "add", base_worktree, base_sha) | ||
| has_worktree = return_code == 0 | ||
|
|
||
| changed_integrations = [] | ||
|
|
||
| for integration in candidates: | ||
| # If pydoc config changed, always include | ||
| if f"integrations/{integration}/pydoc/config_docusaurus.yml" in changed_files: | ||
| changed_integrations.append(integration) | ||
| continue | ||
|
|
||
| # Otherwise, check if docstrings changed | ||
| pr_docstrings_checksum = docstrings_checksum(Path(".").glob(f"integrations/{integration}/**/*.py")) | ||
| base_docstrings_checksum = "" | ||
| if has_worktree: | ||
| base_docstrings_checksum = docstrings_checksum(Path(base_worktree).glob(f"integrations/{integration}/**/*.py")) | ||
|
|
||
| if base_docstrings_checksum != pr_docstrings_checksum: | ||
| changed_integrations.append(integration) | ||
|
|
||
| print(f"Integrations with API reference changes: {json.dumps(changed_integrations)}") | ||
|
|
||
| with open(os.environ["GITHUB_OUTPUT"], "a") as f: | ||
| f.write(f"integrations={json.dumps(changed_integrations)}\n") | ||
|
|
||
| - name: Install Hatch | ||
| if: steps.changed.outputs.integrations != '[]' | ||
| run: pip install --upgrade hatch | ||
|
|
||
| - name: Generate API references | ||
| if: steps.changed.outputs.integrations != '[]' | ||
| env: | ||
| INTEGRATIONS: ${{ steps.changed.outputs.integrations }} | ||
| run: | | ||
| mkdir -p website | ||
| for integration in $(echo "$INTEGRATIONS" | jq -r '.[]'); do | ||
| echo "" | ||
| echo "--- Generating API reference for $integration ---" | ||
| cd "integrations/$integration" | ||
| hatch run docs | ||
| # Move the generated file to a 'website' folder for testing | ||
| mv "$integration.md" ../../website/ | ||
| cd ../.. | ||
| done | ||
|
|
||
| - name: Set up Node.js | ||
| if: steps.changed.outputs.integrations != '[]' | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "22" | ||
|
|
||
| - name: Run Docusaurus md/mdx checker | ||
| if: steps.changed.outputs.integrations != '[]' | ||
| working-directory: website | ||
| run: | | ||
| npx docusaurus-mdx-checker -v || { | ||
| echo "" | ||
| echo "For common MDX problems, see https://docusaurus.io/blog/preparing-your-site-for-docusaurus-v3#common-mdx-problems" | ||
| exit 1 | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.