mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-20 14:54:12 +00:00
## Summary Fixes the Playwright update workflow broken by #5960. When triggered by adding the "New Browser Test Expectations" label, the workflow was left in a detached HEAD state, causing `git push` to fail. ## Changes - **Restores branch checkout for label triggers**: Uses `github.head_ref` to fetch and checkout the branch when triggered by `pull_request` events - **Preserves comment trigger functionality**: Keeps `gh pr checkout` for `issue_comment` events using `github.event.issue.number` - **Event-specific push logic**: Uses explicit `git push origin HEAD:${{ github.head_ref }}` for label triggers, plain `git push` for comment triggers ## Root Cause PR #5960 removed the original branch checkout logic: ```yaml git fetch origin ${{ github.head_ref }} git checkout -B ${{ github.head_ref }} origin/${{ github.head_ref }} git push origin HEAD:${{ github.head_ref }} ``` This left the label-triggered workflow in detached HEAD after `actions/checkout@v5`, breaking the push step. ## Testing This fix properly uses `github.head_ref` only when it's available (`pull_request` events) and `github.event.issue.number` only for `issue_comment` events where `head_ref` isn't available. Fixes #5960 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5985-ci-Fix-detached-HEAD-state-in-Playwright-update-workflow-2866d73d36508183b63bca03a40da4a8) by [Unito](https://www.unito.io)
74 lines
2.6 KiB
YAML
74 lines
2.6 KiB
YAML
# Setting test expectation screenshots for Playwright
|
|
name: Update Playwright Expectations
|
|
|
|
on:
|
|
pull_request:
|
|
types: [labeled]
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
if: >
|
|
( github.event_name == 'pull_request' && github.event.label.name == 'New Browser Test Expectations' ) ||
|
|
( github.event.issue.pull_request &&
|
|
github.event_name == 'issue_comment' &&
|
|
(
|
|
github.event.comment.author_association == 'OWNER' ||
|
|
github.event.comment.author_association == 'MEMBER' ||
|
|
github.event.comment.author_association == 'COLLABORATOR'
|
|
) &&
|
|
startsWith(github.event.comment.body, '/update-playwright') )
|
|
steps:
|
|
- name: Initial Checkout
|
|
uses: actions/checkout@v5
|
|
- name: Pull Request Checkout (from comment)
|
|
run: gh pr checkout ${{ github.event.issue.number }}
|
|
if: github.event_name == 'issue_comment'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Pull Request Checkout (from label)
|
|
run: |
|
|
git fetch origin ${{ github.head_ref }}
|
|
git checkout ${{ github.head_ref }}
|
|
if: github.event_name == 'pull_request'
|
|
- name: Setup Frontend
|
|
uses: ./.github/actions/setup-frontend
|
|
- name: Setup Playwright
|
|
uses: ./.github/actions/setup-playwright
|
|
- name: Run Playwright tests and update snapshots
|
|
id: playwright-tests
|
|
run: pnpm exec playwright test --update-snapshots
|
|
continue-on-error: true
|
|
working-directory: ComfyUI_frontend
|
|
- uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: playwright-report
|
|
path: ComfyUI_frontend/playwright-report/
|
|
retention-days: 30
|
|
- name: Debugging info
|
|
run: |
|
|
echo "PR: ${{ github.event.issue.number }}"
|
|
git status
|
|
working-directory: ComfyUI_frontend
|
|
- name: Commit updated expectations
|
|
run: |
|
|
git config --global user.name 'github-actions'
|
|
git config --global user.email 'github-actions@github.com'
|
|
git add browser_tests
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit"
|
|
else
|
|
git commit -m "[automated] Update test expectations"
|
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
git push origin HEAD:${{ github.head_ref }}
|
|
else
|
|
git push
|
|
fi
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
working-directory: ComfyUI_frontend
|