Skip to content

Add retry logic for Hermit initialization #640

Add retry logic for Hermit initialization

Add retry logic for Hermit initialization #640

name: Binary Size Monitor
on:
pull_request:
branches:
- main
- "[0-9]+.[0-9]+"
types: [opened, synchronize, reopened]
env:
# Binary size threshold in MiB
SIZE_THRESHOLD_MIB: 5
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
binary-size-monitor:
name: Monitor Binary Size
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
pull-requests: write
steps:
- name: Check out PR
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Hermit Environment
uses: ./.github/actions/hermit
with:
init-tools: "true"
free-disk: "true"
- name: Build PR branch binary
run: |
mage build
mv cloudbeat /tmp/cloudbeat-pr
- name: Check out target branch
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
ref: ${{ github.base_ref }}
clean: true
- name: Build target branch binary
run: |
echo "Building target branch binary..."
mage build
mv cloudbeat /tmp/cloudbeat-target
# Checkout PR branch to get latest script
- name: Check out PR (again)
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Get binary sizes and compare
id: size-check
run: |
./.ci/scripts/binary-size-compare.sh /tmp/cloudbeat-pr /tmp/cloudbeat-target ${{ env.SIZE_THRESHOLD_MIB }}
- name: Comment on PR with size information
if: steps.size-check.outputs.threshold_exceeded == '1'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
header: Binary Size Monitor
message: |
## 📊 Binary Size Monitor Report
| Branch | Size (MiB) | Size (bytes) |
|--------|-------------|-------------|
| **PR Branch** | ${{ steps.size-check.outputs.pr_size_mib }} MiB | ${{ steps.size-check.outputs.pr_size }} bytes |
| **Target Branch** | ${{ steps.size-check.outputs.target_size_mib }} MiB | ${{ steps.size-check.outputs.target_size }} bytes |
| **Difference** | ${{ steps.size-check.outputs.size_diff_mib }} MiB | ${{ steps.size-check.outputs.size_diff }} bytes |
**Size Change:** ${{ steps.size-check.outputs.percentage }}% | **Absolute Change:** ${{ steps.size-check.outputs.size_diff_mib }} MiB
${{ steps.size-check.outputs.threshold_exceeded == '1' && format('⚠️ **WARNING:** Binary size increased by {0} MiB, which exceeds the {1} MiB threshold!', steps.size-check.outputs.size_diff_mib, env.SIZE_THRESHOLD_MIB) || '✅ Binary size change is within acceptable limits.' }}
- name: Delete previous comment if it exists
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
if: steps.size-check.outputs.threshold_exceeded == '0'
with:
header: Binary Size Monitor
delete: true
- name: Fail job if size threshold exceeded
if: steps.size-check.outputs.threshold_exceeded == '1'
run: |
echo "❌ Binary size increased by ${{ steps.size-check.outputs.size_diff_mib }} MiB (${{ steps.size-check.outputs.percentage }}%), exceeding the ${{ env.SIZE_THRESHOLD_MIB }} MiB threshold"
echo "This indicates a significant increase in the cloudbeat binary size."
echo "Please review your changes to understand the size impact."
exit 1