Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/check-colab-notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +36 to +37
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Multiline FILES value truncated in GITHUB_OUTPUT

When more than one .py file changes, xargs -I{} basename {} emits one filename per line. A bare echo "files=$FILES" writes those newlines verbatim into $GITHUB_OUTPUT, so GitHub Actions reads only the first line as the files value — all subsequent filenames are silently dropped. The downstream step therefore regenerates only one notebook even though several changed.

Fix by collapsing to a space-separated string before writing the output:

Suggested change
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"
FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha || 'HEAD~1' }} -- docs/notebook_source/*.py | xargs -I{} basename {} | tr '\n' ' ' | sed 's/ $//' || true)
echo "files=$FILES" >> "$GITHUB_OUTPUT"
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/check-colab-notebooks.yml
Line: 36-37

Comment:
**Multiline `FILES` value truncated in `GITHUB_OUTPUT`**

When more than one `.py` file changes, `xargs -I{} basename {}` emits one filename per line. A bare `echo "files=$FILES"` writes those newlines verbatim into `$GITHUB_OUTPUT`, so GitHub Actions reads only the first line as the `files` value — all subsequent filenames are silently dropped. The downstream step therefore regenerates only one notebook even though several changed.

Fix by collapsing to a space-separated string before writing the output:

```suggestion
          FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha || 'HEAD~1' }} -- docs/notebook_source/*.py | xargs -I{} basename {} | tr '\n' ' ' | sed 's/ $//' || true)
          echo "files=$FILES" >> "$GITHUB_OUTPUT"
```

How can I resolve this? If you propose a fix, please make it concise.


- 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 ""
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

# ==============================================================================
Expand Down
Loading