mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-05 21:54:50 +00:00
## Summary Extract duplicated PR-number-resolution logic from `workflow_run`-triggered workflows into a shared composite action at `.github/actions/resolve-pr-from-workflow-run/`. ## Changes - **What**: New composite action that resolves PR number from `workflow_run` context using `pull_requests[0]` with `listPullRequestsAssociatedWithCommit` fallback. Updated 4 consumer workflows; removed dead artifact-stored PR metadata from 2 CI workflows. - **Files touched**: - `.github/actions/resolve-pr-from-workflow-run/action.yaml` (new) - `.github/workflows/pr-vercel-website-preview.yaml` (uses shared action) - `.github/workflows/pr-report.yaml` (uses shared action with `check-staleness: true`) - `.github/workflows/ci-tests-storybook-forks.yaml` (replaced `pulls.list` scan) - `.github/workflows/ci-tests-e2e-forks.yaml` (replaced `pulls.list` scan) - `.github/workflows/ci-size-data.yaml` (removed dead `number.txt`/`base.txt`/`head-sha.txt` writes) - `.github/workflows/ci-perf-report.yaml` (removed dead `perf-meta` artifact) ## Review Focus - The fork workflows previously used `pulls.list` (fetches all open PRs, linear scan by SHA). The shared action uses the more targeted `workflow_run.pull_requests[0]` + `listPullRequestsAssociatedWithCommit` fallback. - `coverage-slack-notify.yaml` was intentionally left unchanged — it parses merged commit messages on `main` pushes, which is a different use case. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11336-refactor-extract-shared-resolve-pr-from-workflow-run-action-3456d73d365081e5b8f5ea29c020763e) by [Unito](https://www.unito.io) --------- Co-authored-by: bymyself <cbyrne@comfy.org> Co-authored-by: Amp <amp@ampcode.com>
169 lines
6.2 KiB
YAML
169 lines
6.2 KiB
YAML
name: 'PR: Unified Report'
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ['CI: Size Data', 'CI: Performance Report', 'CI: E2E Coverage']
|
|
types:
|
|
- completed
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
issues: write
|
|
actions: read
|
|
|
|
concurrency:
|
|
group: pr-report-${{ github.event.workflow_run.head_sha }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
comment:
|
|
runs-on: ubuntu-latest
|
|
if: >
|
|
github.repository == 'Comfy-Org/ComfyUI_frontend' &&
|
|
github.event.workflow_run.event == 'pull_request'
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Setup frontend
|
|
uses: ./.github/actions/setup-frontend
|
|
|
|
- name: Resolve PR from workflow_run context
|
|
id: pr-meta
|
|
uses: ./.github/actions/resolve-pr-from-workflow-run
|
|
|
|
- name: Find size workflow run
|
|
if: steps.pr-meta.outputs.skip != 'true'
|
|
id: find-size
|
|
uses: ./.github/actions/find-workflow-run
|
|
with:
|
|
workflow-id: ci-size-data.yaml
|
|
head-sha: ${{ steps.pr-meta.outputs.head-sha }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Find perf workflow run
|
|
if: steps.pr-meta.outputs.skip != 'true'
|
|
id: find-perf
|
|
uses: ./.github/actions/find-workflow-run
|
|
with:
|
|
workflow-id: ci-perf-report.yaml
|
|
head-sha: ${{ steps.pr-meta.outputs.head-sha }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Download size data (current)
|
|
if: steps.pr-meta.outputs.skip != 'true' && steps.find-size.outputs.status == 'ready'
|
|
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
|
|
with:
|
|
name: size-data
|
|
run_id: ${{ steps.find-size.outputs.run-id }}
|
|
path: temp/size
|
|
|
|
- name: Download size baseline
|
|
if: steps.pr-meta.outputs.skip != 'true' && steps.find-size.outputs.status == 'ready'
|
|
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
|
|
with:
|
|
branch: ${{ steps.pr-meta.outputs.base }}
|
|
workflow: ci-size-data.yaml
|
|
event: push
|
|
name: size-data
|
|
path: temp/size-prev
|
|
if_no_artifact_found: warn
|
|
|
|
- name: Find coverage workflow run
|
|
if: steps.pr-meta.outputs.skip != 'true'
|
|
id: find-coverage
|
|
uses: ./.github/actions/find-workflow-run
|
|
with:
|
|
workflow-id: ci-tests-e2e-coverage.yaml
|
|
head-sha: ${{ steps.pr-meta.outputs.head-sha }}
|
|
not-found-status: skip
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Download coverage data
|
|
if: steps.pr-meta.outputs.skip != 'true' && steps.find-coverage.outputs.status == 'ready'
|
|
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
|
|
with:
|
|
name: e2e-coverage
|
|
run_id: ${{ steps.find-coverage.outputs.run-id }}
|
|
path: temp/coverage
|
|
if_no_artifact_found: warn
|
|
|
|
- name: Download perf metrics (current)
|
|
if: steps.pr-meta.outputs.skip != 'true' && steps.find-perf.outputs.status == 'ready'
|
|
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
|
|
with:
|
|
name: perf-metrics
|
|
run_id: ${{ steps.find-perf.outputs.run-id }}
|
|
path: test-results/
|
|
|
|
- name: Download perf baseline
|
|
if: steps.pr-meta.outputs.skip != 'true' && steps.find-perf.outputs.status == 'ready'
|
|
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
|
|
with:
|
|
branch: ${{ steps.pr-meta.outputs.base }}
|
|
workflow: ci-perf-report.yaml
|
|
event: push
|
|
name: perf-metrics
|
|
path: temp/perf-baseline/
|
|
if_no_artifact_found: warn
|
|
|
|
- name: Download perf history from perf-data branch
|
|
if: steps.pr-meta.outputs.skip != 'true' && steps.find-perf.outputs.status == 'ready'
|
|
continue-on-error: true
|
|
run: |
|
|
if git ls-remote --exit-code origin perf-data >/dev/null 2>&1; then
|
|
git fetch origin perf-data --depth=1
|
|
mkdir -p temp/perf-history
|
|
for file in $(git ls-tree --name-only origin/perf-data baselines/ 2>/dev/null | sort -r | head -15); do
|
|
git show "origin/perf-data:${file}" > "temp/perf-history/$(basename "$file")" 2>/dev/null || true
|
|
done
|
|
echo "Loaded $(ls temp/perf-history/*.json 2>/dev/null | wc -l) historical baselines"
|
|
fi
|
|
|
|
- name: Generate unified report
|
|
if: steps.pr-meta.outputs.skip != 'true'
|
|
run: >
|
|
pnpm exec tsx scripts/unified-report.ts
|
|
--size-status=${{ steps.find-size.outputs.status }}
|
|
--perf-status=${{ steps.find-perf.outputs.status }}
|
|
--coverage-status=${{ steps.find-coverage.outputs.status }}
|
|
> pr-report.md
|
|
|
|
- name: Remove legacy separate comments
|
|
if: steps.pr-meta.outputs.skip != 'true'
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
const prNumber = Number('${{ steps.pr-meta.outputs.number }}');
|
|
const legacyMarkers = [
|
|
'<!-- COMFYUI_FRONTEND_SIZE -->',
|
|
'<!-- COMFYUI_FRONTEND_PERF -->',
|
|
];
|
|
|
|
const comments = await github.paginate(github.rest.issues.listComments, {
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: prNumber,
|
|
per_page: 100,
|
|
});
|
|
|
|
for (const comment of comments) {
|
|
if (legacyMarkers.some(m => comment.body?.includes(m))) {
|
|
await github.rest.issues.deleteComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: comment.id,
|
|
});
|
|
core.info(`Deleted legacy comment ${comment.id}`);
|
|
}
|
|
}
|
|
|
|
- name: Post PR comment
|
|
if: steps.pr-meta.outputs.skip != 'true'
|
|
uses: ./.github/actions/post-pr-report-comment
|
|
with:
|
|
pr-number: ${{ steps.pr-meta.outputs.number }}
|
|
report-file: ./pr-report.md
|
|
comment-marker: '<!-- COMFYUI_FRONTEND_PR_REPORT -->'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|