diff --git a/.github/workflows/check-colab-notebooks.yml b/.github/workflows/check-colab-notebooks.yml index 5d3a06af..dcda2ce2 100644 --- a/.github/workflows/check-colab-notebooks.yml +++ b/.github/workflows/check-colab-notebooks.yml @@ -30,18 +30,26 @@ jobs: - name: Install dependencies run: uv sync --all-packages --group notebooks --group docs + - name: Get changed notebook sources + id: changed + run: | + FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha || 'HEAD~1' }} -- docs/notebook_source/*.py | xargs -I{} basename {} || true) + echo "files=$FILES" >> "$GITHUB_OUTPUT" + - name: Generate Colab notebooks run: | - make generate-colab-notebooks + if [ -n "${{ steps.changed.outputs.files }}" ]; then + make generate-colab-notebooks FILES="${{ steps.changed.outputs.files }}" + else + make generate-colab-notebooks + fi - name: Check for differences run: | - # Get the diff, filtering out cell ID changes (which are randomly generated) - # Filter out: file markers (--- and +++), and "id" lines - MEANINGFUL_DIFF=$(git diff docs/colab_notebooks/ | grep -E '^[+-]' | grep -v '^---' | grep -v '^+++' | grep -vE '^[+-]\s*"id": "[0-9a-fA-F]+",?$' || true) + MEANINGFUL_DIFF=$(git diff docs/colab_notebooks/ || true) if [ -z "$MEANINGFUL_DIFF" ]; then - echo "✅ Colab notebooks are up-to-date (ignoring cell ID changes)" + echo "✅ Colab notebooks are up-to-date" else echo "❌ Colab notebooks are out of sync with source files" echo "" diff --git a/Makefile b/Makefile index c4b86798..062ecfc9 100644 --- a/Makefile +++ b/Makefile @@ -478,7 +478,11 @@ endif generate-colab-notebooks: @echo "📓 Generating Colab-compatible notebooks..." +ifdef FILES + uv run --group docs python docs/scripts/generate_colab_notebooks.py --files $(FILES) +else uv run --group docs python docs/scripts/generate_colab_notebooks.py +endif @echo "✅ Colab notebooks created in docs/colab_notebooks/" # ==============================================================================