-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: binary size regression job (#211)
Signed-off-by: Jose Nino jnino@lyft.com Description: this PR adds a CI job to test for relative size increases as well as absolute size of the test_binary_size target as a check on size for mobile platform constraints. Risk Level: low - added new CI jobs. Testing: CI. Also tested locally for failure messages. Signed-off-by: JP Simard <jp@jpsim.com>
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# Checks the absolute size, and the relative increase of a file. | ||
MAX_SIZE=4000000 | ||
MAX_PERC=1 | ||
|
||
if [ `uname` == "Darwin" ] | ||
then | ||
SIZE1=$(stat -f "%z" "$1") | ||
SIZE2=$(stat -f "%z" "$2") | ||
else | ||
SIZE1=$(stat -c "%s" "$1") | ||
SIZE2=$(stat -c "%s" "$2") | ||
fi | ||
PERC=$(bc <<< "scale=2; ($SIZE2 - $SIZE1)/$SIZE1 * 100") | ||
|
||
echo "The new binary is $PERC % different in size compared to master." | ||
echo "The new binary is $SIZE2 bytes." | ||
|
||
if [ $SIZE2 -gt $MAX_SIZE ] | ||
then | ||
echo "The current size ($SIZE2) is larger than the maximum size ($MAX_SIZE)." | ||
exit 1 | ||
fi | ||
|
||
if [ $(bc <<< "scale=2; $PERC >= $MAX_PERC") -eq 1 ] | ||
then | ||
echo "The percentage increase ($PERC) is larger then the maximum percentage increase ($MAX_PERC)." | ||
exit 1 | ||
fi |