Skip to content

Commit

Permalink
Merge pull request #62 from snprajwal/check-bin-size
Browse files Browse the repository at this point in the history
fix(ci): set git credentials for rebase
  • Loading branch information
adrianreber committed Jun 8, 2023
2 parents bea694f + 75ce9c1 commit da69a6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/check-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
# Use HEAD from the PR instead of the merge commit
ref: ${{ github.event.pull_request.head.sha }}
# Needed to rebase against the base branch
fetch-depth: 0
- name: Configure git user details
run: |
git config --global user.email "bloatchecker@example.com"
git config --global user.name "Bloat Checker"
- name: Configure base branch without switching current branch
run: git fetch origin ${GITHUB_BASE_REF}:${GITHUB_BASE_REF}
- name: Compare binary size change across each commit
run: git rebase ${GITHUB_BASE_REF}^ -x test/check-size.sh
run: git rebase -v ${GITHUB_BASE_REF}^ -x test/check-size.sh
10 changes: 8 additions & 2 deletions test/check-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ MAX_DIFF=51200
make
# Store the binary size
BIN_SIZE=$(stat -c%s "$BIN_NAME")
# Print the size along with the commit hash
echo "BINARY SIZE ($(git rev-parse --short HEAD)): $BIN_SIZE"

if [[ -f "$PREV_SIZE_FILE" ]]; then
# Read the previous size from the file
PREV_SIZE=$(cat "$PREV_SIZE_FILE")
# Calculate the difference between current and previous size
DIFF=$((BIN_SIZE - PREV_SIZE))
if [[ $DIFF -gt $MAX_DIFF ]]; then
echo "FAIL: size difference of \"$DIFF\" B exceeds limit \"$MAX_DIFF\" B"
echo "FAIL: size difference of $DIFF B exceeds limit $MAX_DIFF B"
exit 1
else
echo "PASS: size difference of \"$DIFF\" B within limit \"$MAX_DIFF\" B"
echo "PASS: size difference of $DIFF B within limit $MAX_DIFF B"
fi
else
# This means this is the first run of the script.
Expand All @@ -38,3 +40,7 @@ else
echo "No previous size present, storing current size"
echo "$BIN_SIZE" > "$PREV_SIZE_FILE"
fi

# Remove the binary to ensure it is
# built again with the next commit
rm -f $BIN_NAME

0 comments on commit da69a6b

Please sign in to comment.