Skip to content

Commit

Permalink
ci: Improve bin size info (#20551)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Jan 3, 2025
1 parent 841c387 commit 58d69d6
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,26 @@ jobs:
WHEEL_SIZE=$(ls -l py-polars/polars/polars*.so | awk '{ print $5 }')
echo "WHEEL_SIZE=$WHEEL_SIZE" >> $GITHUB_ENV
- name: Wheel size txt
if: github.ref_name == 'main'
run: |
echo "$GITHUB_RUN_ID $WHEEL_SIZE" > wheel_sizes.txt
- name: Upload wheel sizes artifact (main only)
if: github.ref_name == 'main'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheel-size
path: |
echo "$GITHUB_RUN_ID $WHEEL_SIZE" > wheel_sizes.txt
wheel_sizes.txt
path: wheel_sizes.txt

- name: Download main wheel size
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wheel-size
continue-on-error: true

- name: Extract previous wheel size
if: github.ref_name != 'main'
id: load_previous_size
run: |
if [[ -f wheel_sizes.txt ]]; then
Expand All @@ -102,9 +106,11 @@ jobs:
else
echo "PREVIOUS_WHEEL_SIZE=Unknown" >> $GITHUB_ENV
fi
continue-on-error: true

- name: Comment wheel size
uses: actions/github-script@v7
if: github.ref_name != 'main'
with:
script: |
const previousSize = process.env.PREVIOUS_WHEEL_SIZE || 'Unknown';
Expand All @@ -114,21 +120,43 @@ jobs:
const previousSizeMB = previousSize !== 'Unknown' ? (previousSize / 1024 / 1024).toFixed(4) : 'Unknown';
const currentSizeMB = currentSize !== 'Unknown' ? (currentSize / 1024 / 1024).toFixed(4) : 'Unknown';
let commentBody = `The uncompressed binary size was **${previousSizeMB} MB**.\nThe uncompressed binary size after this PR is **${currentSizeMB} MB**.`;
let commentBody = `The previous uncompressed lib size was **${previousSizeMB} MB**.\nThe current uncompressed lib size after this PR is **${currentSizeMB} MB**.`;
// Calculate percentage increase if both sizes are available
if (previousSize !== 'Unknown' && currentSize !== '') {
const increase = ((currentSize - previousSize) / previousSize) * 100;
commentBody += `\nThis represents a **${increase.toFixed(2)}% increase** in size.`;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
issue_number: context.issue.number,
});
// Look for an existing comment
const existingComment = comments.find(comment =>
comment.body.includes('The previous uncompressed lib size was')
);
if (existingComment) {
// Update the existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: commentBody,
});
} else {
// Create a new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody,
});
}
continue-on-error: true

- name: Run benchmark tests
uses: CodSpeedHQ/action@v3
Expand Down

0 comments on commit 58d69d6

Please sign in to comment.