Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .github/workflows/test_size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
Loading