-
Notifications
You must be signed in to change notification settings - Fork 33
74 lines (66 loc) · 2.33 KB
/
check-size.yml
File metadata and controls
74 lines (66 loc) · 2.33 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
name: Check binary size
on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled, ready_for_review]
permissions:
contents: read
jobs:
check_size:
runs-on: ubuntu-latest
# Check if pull request does not have label "bloat-ok".
if: "!contains(github.event.pull_request.labels.*.name, 'bloat-ok')"
steps:
- uses: actions/checkout@v4
with:
# Needed to rebase against the base branch
fetch-depth: 0
# Checkout pull request HEAD commit instead of merge commit
ref: ${{ github.event.pull_request.head.sha }}
- name: Configure git user details
run: |
git config --global user.email "checkpoint-restore@users.noreply.github.com"
git config --global user.name "checkpoint-restore"
- name: Configure base branch without switching current branch
run: git fetch origin ${GITHUB_BASE_REF}:${GITHUB_BASE_REF}
- name: Save PR context
env:
EVENT_JSON: ${{ toJSON(github.event) }}
run: |
mkdir -p artifacts
printenv EVENT_JSON > artifacts/event.json
- name: Compare binary size change across each commit
id: size-check
# Use the last non-merge commit from the base branch as the baseline
run: |
set +e
OUTPUT=$(git rebase -v $(git rev-list --no-merges -n 1 ${GITHUB_BASE_REF})^ -x test/check-size.sh 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
echo "$OUTPUT" > artifacts/output.txt
echo "exit_code=${EXIT_CODE}" >> $GITHUB_OUTPUT
exit $EXIT_CODE
- name: Generate size check comment
if: failure()
run: |
cat > artifacts/comment.md << 'EOF'
## Binary Size Check Failed
The binary size increase exceeds the allowed threshold.
### Size Check Output
```
EOF
cat artifacts/output.txt >> artifacts/comment.md
cat >> artifacts/comment.md << 'EOF'
```
### How to resolve
If this size increase is expected and acceptable, a maintainer can add
the `bloat-ok` label to this PR to bypass the size check.
---
*Binary size check performed by CI*
EOF
- name: Upload size check results
if: always()
uses: actions/upload-artifact@v4
with:
name: size-check-results
retention-days: 5
path: artifacts/