diff --git a/.github/actions/pr-comment-on-failure/action.yaml b/.github/actions/pr-comment-on-failure/action.yaml new file mode 100644 index 00000000000..bbdc73bd16d --- /dev/null +++ b/.github/actions/pr-comment-on-failure/action.yaml @@ -0,0 +1,63 @@ +name: "PR Comment on Failure" +description: "Comments on PRs from forks when checks fail" +inputs: + check-name: + description: "The name of the check that failed" + required: true + command: + description: "The command that contributors should run" + required: true + github-token: + description: "GitHub token for commenting" + required: true + +runs: + using: "composite" + steps: + - name: Comment on PR + if: github.event.pull_request.head.repo.fork == true + uses: actions/github-script@v7 + with: + github-token: ${{ inputs.github-token }} + script: | + const checkName = '${{ inputs.check-name }}'; + const command = '${{ inputs.command }}'; + + const body = `๐Ÿ‘‹ It looks like the **${checkName}** check failed. + + To fix this locally, please run: + + \`\`\`bash + ${command} + \`\`\` + `; + + // Check if we already commented + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const botComment = comments.find(comment => + comment.user.type === 'Bot' && + comment.body.includes(checkName) + ); + + if (botComment) { + // Update existing comment + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: body + }); + } else { + // Create new comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: body + }); + } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f04fc58ccd0..6bb252997d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -132,6 +132,34 @@ jobs: - name: โฌ‡๏ธ Checkout repo uses: actions/checkout@v4 + - name: โณ Wait for PyPI package availability + run: | + VERSION="${{ needs.publish_release.outputs.marimo_version }}" + echo "Waiting for marimo version $VERSION to be available on PyPI..." + + MAX_ATTEMPTS=30 + ATTEMPT=0 + SLEEP_TIME=10 + + while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do + ATTEMPT=$((ATTEMPT + 1)) + echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Checking PyPI for version $VERSION..." + + # Check if the version exists on PyPI + HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/marimo/$VERSION/json") + + if [ "$HTTP_CODE" = "200" ]; then + echo "โœ… Version $VERSION is available on PyPI!" + exit 0 + else + echo "Version $VERSION not yet available (HTTP $HTTP_CODE). Waiting ${SLEEP_TIME}s..." + sleep $SLEEP_TIME + fi + done + + echo "โŒ Timed out waiting for version $VERSION on PyPI after $((MAX_ATTEMPTS * SLEEP_TIME)) seconds" + exit 1 + - name: ๐Ÿ‹ Log in to the Container registry uses: docker/login-action@v3 with: diff --git a/.github/workflows/test_be.yaml b/.github/workflows/test_be.yaml index 9347aa5e1de..bafbb2bfbc4 100644 --- a/.github/workflows/test_be.yaml +++ b/.github/workflows/test_be.yaml @@ -7,6 +7,7 @@ on: permissions: contents: read + pull-requests: write env: MARIMO_SKIP_UPDATE_CHECK: 1 @@ -46,8 +47,17 @@ jobs: uses: pypa/hatch@install - name: ๐Ÿ“š Build docs + id: docs run: hatch run docs:build --strict + - name: Comment on docs failure + if: failure() && steps.docs.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "docs build" + command: "hatch run docs:build --strict" + github-token: ${{ secrets.GITHUB_TOKEN }} + test_check: needs: changes if: ${{ needs.changes.outputs.backend == 'true' }} @@ -64,11 +74,29 @@ jobs: uses: pypa/hatch@install - name: ๐Ÿงน Lint + id: lint run: hatch run lint - name: ๐Ÿ” Typecheck + id: typecheck run: hatch run typecheck:check + - name: Comment on lint failure + if: failure() && steps.lint.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "lint" + command: "hatch run lint" + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on typecheck failure + if: failure() && steps.typecheck.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "typecheck" + command: "hatch run typecheck:check" + github-token: ${{ secrets.GITHUB_TOKEN }} + # For PRs, we only run the tests for the changed files. # If there is a `test-all` label, we run the tests across unchanged files as well. test_python: diff --git a/.github/workflows/test_fe.yaml b/.github/workflows/test_fe.yaml index 8570f7fa12a..2906b15cfd2 100644 --- a/.github/workflows/test_fe.yaml +++ b/.github/workflows/test_fe.yaml @@ -1,6 +1,7 @@ name: Test FE permissions: contents: read + pull-requests: write on: push: @@ -51,11 +52,29 @@ jobs: - name: ๐Ÿ“ฆ pnpm dedupe if: github.event_name == 'pull_request' + id: dedupe run: pnpm dedupe --check - name: ๐Ÿงน Lint + id: lint run: pnpm turbo lint + - name: Comment on lint failure + if: failure() && steps.lint.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "lint" + command: "pnpm turbo lint" + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on dedupe failure + if: failure() && steps.dedupe.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "dedupe" + command: "pnpm dedupe" + github-token: ${{ secrets.GITHUB_TOKEN }} + test_frontend: needs: changes if: ${{ needs.changes.outputs.frontend == 'true' }} @@ -80,11 +99,29 @@ jobs: uses: ./.github/actions/install - name: ๐Ÿ”Ž Type check + id: typecheck run: pnpm turbo typecheck - name: ๐Ÿงช Test + id: test run: pnpm turbo test + - name: Comment on typecheck failure + if: failure() && steps.typecheck.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "typecheck" + command: "pnpm turbo typecheck" + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on test failure + if: failure() && steps.test.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "test" + command: "pnpm turbo test" + github-token: ${{ secrets.GITHUB_TOKEN }} + build_frontend: needs: changes if: ${{ needs.changes.outputs.frontend == 'true' }} @@ -120,6 +157,7 @@ jobs: fi - name: ๐Ÿ“ฆ Build + id: build run: pnpm turbo build env: NODE_ENV: production @@ -133,3 +171,11 @@ jobs: npm version 0.0.0 --no-git-tag-version pnpm turbo build:islands ./islands/validate.sh + + - name: Comment on build failure + if: failure() && steps.build.outcome == 'failure' + uses: ./.github/actions/pr-comment-on-failure + with: + check-name: "build" + command: "pnpm turbo build" + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/guides/debugging.md b/docs/guides/debugging.md index 810a9e938df..7baed9a37db 100644 --- a/docs/guides/debugging.md +++ b/docs/guides/debugging.md @@ -1,39 +1,16 @@ -# Debugging marimo notebooks +# Debugging -## Debugging in marimo +## In the marimo editor -### Using pdb in marimo notebooks +### Setting breakpoints with pdb -marimo has direct support for pdb, the Python debugger. You can set breakpoints -in your code using the built-in `breakpoint()` function. When the code -execution reaches a breakpoint, it will pause, and you can inspect variables, -step through the code, and evaluate expressions. +marimo supports pdb, the Python debugger. Set breakpoints in your code using +the built-in `breakpoint()` function. When the code execution reaches a +breakpoint, it will pause, and you can inspect variables, step through the +code, and evaluate expressions. -Here's an example of how to use `breakpoint()` in a marimo notebook cell. - -![PDB in marimo](../_static/docs-pdb-demo.png) - -Type `help` in the debugger for a list of commands: - -```txt -Documented commands (type help ): -======================================== -EOF cl disable ignore n return u where -a clear display interact next retval unalias -alias commands down j p run undisplay -args condition enable jump pp rv unt -b cont exceptions l q s until -break continue exit list quit source up -bt d h ll r step w -c debug help longlist restart tbreak whatis - -Miscellaneous help topics: -========================== -exec pdb -``` - -!!! note - Since this block is runnable, you can test the debugger directly +Here's a live example of how to use `breakpoint()` in a marimo notebook cell. Type +`help` in the debugger for a list of commands. /// marimo-embed @@ -52,11 +29,18 @@ def _(): return ``` + /// -!!! tip +!!! warning "The debugger blocks execution" + + When the debugger is active, you cannot execute cells. Remember to continue + or quit the debugger to avoid hanging the notebook! + +??? note "Adding breakpoints in the stack trace" Click the little bug icon in the stack trace to add breakpoints. -