• Will Chen's avatar
    Fix playwright comment & Claude PR workflows (#2043) · 76685435
    Will Chen 提交于
    <!-- CURSOR_SUMMARY -->
    > [!NOTE]
    > **Workflows**
    > 
    > - Updates `playwright-comment.yml` to reliably find the associated PR,
    including forks: extracts `head_branch`/`head_repository`, logs context,
    and falls back to `pulls.list` with `head: "owner:branch"` when commit
    association lookup returns no PR.
    > - Revises `claude-pr-review.yml` to use `pull_request_target`,
    restricts execution via `author_association` (`OWNER`/`MEMBER`), and
    checks out the PR head repo/ref explicitly for fork safety.
    > - Configures the Claude action with `github_token` (OIDC bypass),
    `allowed_non_write_users`, and disables `track_progress`;
    trims/clarifies review prompt guidelines.
    > 
    > <sup>Written by [Cursor
    Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
    8267093820bd968db57167a37b2d2570e94fe010. This will update automatically
    on new commits. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Fixes the Playwright comment workflow so it reliably finds the
    associated PR, including PRs from forks. Updates the Claude PR Review
    workflow to run safely on forked PRs and only for org members.
    
    - **Bug Fixes**
    - Playwright: add fallback search by head owner:branch; better logging
    (SHA, branch, owner) to post to the right PR.
    - Claude PR Review: switch to pull_request_target with OWNER/MEMBER
    filter; checkout fork head; disable progress; drop id-token.
    
    <sup>Written for commit 8267093820bd968db57167a37b2d2570e94fe010.
    Summary will update automatically on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    
    
    
    <!-- greptile_comment -->
    
    <h3>Greptile Summary</h3>
    
    
    This PR restores the fallback mechanism for finding PR numbers from
    forked repositories. The previous commit (41a46a9b) inadvertently removed
    the fork PR detection logic, breaking Playwright comment posting for
    external contributors. This fix re-introduces a two-method approach:
    
    - **Method 1**: Uses `listPullRequestsAssociatedWithCommit` (works for
    same-repo PRs)
    - **Method 2**: Falls back to `pulls.list` with `head: "owner:branch"`
    when Method 1 fails (handles fork PRs)
    
    The change extracts additional context (`head_branch`,
    `head_repository.owner.login`) from the workflow run payload and adds
    improved logging for debugging PR lookups.
    
    <h3>Confidence Score: 5/5</h3>
    
    
    - This PR is safe to merge with no risk
    - The change restores critical functionality that was accidentally
    removed in the previous commit. The implementation is correct,
    well-commented, and follows GitHub Actions best practices. No logic
    errors, security issues, or breaking changes detected.
    - No files require special attention
    
    <h3>Important Files Changed</h3>
    
    
    
    
    | Filename | Overview |
    |----------|----------|
    | .github/workflows/playwright-comment.yml | Added fallback logic for
    fork PRs by searching head branch when commit lookup fails |
    
    </details>
    
    
    
    <h3>Sequence Diagram</h3>
    
    ```mermaid
    sequenceDiagram
        participant CI as CI Workflow
        participant WR as Workflow Run Event
        participant GH as GitHub API
        participant Script as PR Lookup Script
        
        CI->>WR: Completes (triggers workflow_run)
        WR->>Script: Provides head_sha, head_branch, head_repository
        Script->>Script: Extract sha, headBranch, headRepoOwner
        
        Script->>GH: listPullRequestsAssociatedWithCommit(sha)
        alt Commit found (same-repo PRs)
            GH-->>Script: Returns PR data
            Script->>Script: Set PR number output
        else No PR found
            Script->>Script: Check if headRepoOwner & headBranch exist
            alt Fork PR fallback
                Script->>GH: pulls.list(head: "owner:branch")
                GH-->>Script: Returns PR from fork
                Script->>Script: Set PR number output
            else Still no PR
                Script->>Script: Set empty output (skip commenting)
            end
        end
        
        Script->>WR: Output PR number or empty
        
        alt PR found
            WR->>Script: Download artifacts & generate comment
            Script->>GH: Post/update PR comment
        else No PR
            WR->>WR: Skip remaining steps
        end
    ```
    
    <!-- greptile_other_comments_section -->
    
    <!-- /greptile_comment -->
    76685435
名称
最后提交
最后更新
.cursor/rules 正在载入提交数据...
.devcontainer 正在载入提交数据...
.github 正在载入提交数据...
.husky 正在载入提交数据...
assets 正在载入提交数据...
docs 正在载入提交数据...
drizzle 正在载入提交数据...
e2e-tests 正在载入提交数据...
packages/@dyad-sh 正在载入提交数据...
scaffold 正在载入提交数据...
scripts 正在载入提交数据...
shared 正在载入提交数据...
src 正在载入提交数据...
testing 正在载入提交数据...
tools 正在载入提交数据...
worker 正在载入提交数据...
workers/tsc 正在载入提交数据...
.cursorignore 正在载入提交数据...
.env.example 正在载入提交数据...
.eslintrc.json 正在载入提交数据...
.gitattributes 正在载入提交数据...
.gitignore 正在载入提交数据...
.oxlintrc.json 正在载入提交数据...
.prettierignore 正在载入提交数据...
.prettierrc 正在载入提交数据...
AGENTS.md 正在载入提交数据...
CONTRIBUTING.md 正在载入提交数据...
LICENSE 正在载入提交数据...
README.md 正在载入提交数据...
SECURITY.md 正在载入提交数据...
biome.json 正在载入提交数据...
components.json 正在载入提交数据...
drizzle.config.ts 正在载入提交数据...
forge.config.ts 正在载入提交数据...
forge.env.d.ts 正在载入提交数据...
index.html 正在载入提交数据...
merge.config.ts 正在载入提交数据...
package-lock.json 正在载入提交数据...
package.json 正在载入提交数据...
playwright.config.ts 正在载入提交数据...
tsconfig.app.json 正在载入提交数据...
tsconfig.json 正在载入提交数据...
tsconfig.node.json 正在载入提交数据...
vite.main.config.mts 正在载入提交数据...
vite.preload.config.mts 正在载入提交数据...
vite.renderer.config.mts 正在载入提交数据...
vite.worker.config.mts 正在载入提交数据...
vitest.config.ts 正在载入提交数据...