name: 'PR: Performance Report' on: workflow_run: workflows: ['CI: Performance Report'] types: - completed permissions: contents: read pull-requests: write issues: write jobs: comment: runs-on: ubuntu-latest if: > github.repository == 'Comfy-Org/ComfyUI_frontend' && github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' steps: - name: Checkout repository uses: actions/checkout@v6 - name: Setup Node uses: actions/setup-node@v6 with: node-version: 22 - name: Download PR metadata uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12 with: name: perf-meta run_id: ${{ github.event.workflow_run.id }} path: temp/perf-meta/ - name: Resolve and validate PR metadata id: pr-meta uses: actions/github-script@v8 with: script: | const fs = require('fs'); const artifactPr = Number(fs.readFileSync('temp/perf-meta/number.txt', 'utf8').trim()); const artifactBase = fs.readFileSync('temp/perf-meta/base.txt', 'utf8').trim(); // Resolve PR from trusted workflow context let pr = context.payload.workflow_run.pull_requests?.[0]; if (!pr) { const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.payload.workflow_run.head_sha, }); pr = prs.find(p => p.state === 'open'); } if (!pr) { core.setFailed('Unable to resolve PR from workflow_run context.'); return; } if (Number(pr.number) !== artifactPr) { core.setFailed(`Artifact PR number (${artifactPr}) does not match trusted context (${pr.number}).`); return; } const trustedBase = pr.base?.ref; if (!trustedBase || artifactBase !== trustedBase) { core.setFailed(`Artifact base (${artifactBase}) does not match trusted context (${trustedBase}).`); return; } core.setOutput('number', String(pr.number)); core.setOutput('base', trustedBase); - name: Download PR perf metrics uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12 with: name: perf-metrics run_id: ${{ github.event.workflow_run.id }} path: test-results/ - name: Download baseline perf metrics 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: Generate perf report run: npx --yes tsx scripts/perf-report.ts > perf-report.md - name: Post PR comment uses: ./.github/actions/post-pr-report-comment with: pr-number: ${{ steps.pr-meta.outputs.number }} report-file: ./perf-report.md comment-marker: '' token: ${{ secrets.GITHUB_TOKEN }}