From 612a0bcf551d28fb109db66908abb6f6f259cf85 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sun, 14 Dec 2025 12:48:25 +1100 Subject: [PATCH] CI: add PR comment job to size test workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a comment job to test_size.yml that runs after all build matrix jobs complete and posts or updates a PR comment with the build status. If all builds succeed: - Lists all successful build configurations - Links to workflow run for detailed size comparisons - Posts comment with success status If any build fails: - Reports failure without attempting to provide size information - Links to workflow logs for debugging - Posts comment with failure status The job uses 'needs: build' and 'if: always()' to run regardless of build outcomes, and checks individual job results to determine the appropriate message. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .github/workflows/test_size.yml | 124 ++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/.github/workflows/test_size.yml b/.github/workflows/test_size.yml index 3e2e30b7124b5..4439b5225ad7e 100644 --- a/.github/workflows/test_size.yml +++ b/.github/workflows/test_size.yml @@ -327,3 +327,127 @@ jobs: else echo "No differences found." >> $GITHUB_STEP_SUMMARY fi + comment: + runs-on: ubuntu-latest + needs: build + if: always() && github.event_name == 'pull_request' + permissions: + pull-requests: write + + steps: + - name: Check build results + id: check_results + uses: actions/github-script@v7 + with: + script: | + // Get the build job results + const jobs = await github.rest.actions.listJobsForWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId, + }); + + // Check if all build matrix jobs succeeded + const build_jobs = jobs.data.jobs.filter(job => job.name.startsWith('build')); + const all_succeeded = build_jobs.every(job => job.conclusion === 'success'); + + core.setOutput('all_succeeded', all_succeeded ? 'true' : 'false'); + core.setOutput('job_count', build_jobs.length); + + const job_summary = build_jobs.map(job => ({ + name: job.name, + conclusion: job.conclusion + })); + core.setOutput('jobs', JSON.stringify(job_summary)); + + - name: Comment on PR - Success + if: steps.check_results.outputs.all_succeeded == 'true' + uses: actions/github-script@v7 + with: + script: | + const jobs = JSON.parse('${{ steps.check_results.outputs.jobs }}'); + const pr_number = context.issue.number; + + const comment_body = `## :white_check_mark: Size Test Completed + +All size comparison builds completed successfully. + +**Build Results:** +${jobs.map(job => `- ✅ ${job.name}`).join('\n')} + +Size comparisons have been generated for all configurations. Please review the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for detailed size differences and feature comparisons. + +--- +*This comment is automatically updated by the size test workflow*`; + + // Find existing comment + const comments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + }); + + const bot_comment = comments.data.find(comment => + comment.user.type === 'Bot' && + comment.body.includes('automatically updated by the size test workflow') + ); + + if (bot_comment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: bot_comment.id, + body: comment_body + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + body: comment_body + }); + } + + - name: Comment on PR - Failure + if: steps.check_results.outputs.all_succeeded == 'false' + uses: actions/github-script@v7 + with: + script: | + const pr_number = context.issue.number; + + const comment_body = `## :x: Size Test Build Failed + +The size comparison test did not complete successfully. + +No size information is available. Please check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. + +--- +*This comment is automatically updated by the size test workflow*`; + + // Find existing comment + const comments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + }); + + const bot_comment = comments.data.find(comment => + comment.user.type === 'Bot' && + comment.body.includes('automatically updated by the size test workflow') + ); + + if (bot_comment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: bot_comment.id, + body: comment_body + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr_number, + body: comment_body + }); + }