-
Notifications
You must be signed in to change notification settings - Fork 46
94 lines (77 loc) · 3.58 KB
/
binary-size-monitor.yml
File metadata and controls
94 lines (77 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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