Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Improve bin size info #20551

Merged
merged 7 commits into from
Jan 3, 2025
Merged
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
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
Loading