-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script for testing bundle hash consistency
- Loading branch information
1 parent
e7f99e6
commit 6547c37
Showing
2 changed files
with
57 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,54 @@ | ||
#!/bin/sh | ||
|
||
# This script is used to test whether the built bundles are having the same hash over several builds | ||
|
||
N=5 | ||
MANIFEST_LOCATION=../resources/authgear/generated/manifest.json | ||
TEMP_DIR=$(mktemp -d) | ||
|
||
if [ $N -lt 2 ]; then | ||
echo "[ERROR] The build number must be greater than 1" | ||
exit 1 | ||
fi | ||
|
||
build_bundles() | ||
{ | ||
for i in $(seq 1 $N) | ||
do | ||
echo "[INFO] Build no.$i" | ||
|
||
# Clear vite cache before building bundles | ||
rm -rf node_modules/.vite > /dev/null 2>&1 | ||
npm run build > /dev/null 2>&1 | ||
|
||
python3 -m json.tool --sort-keys --no-ensure-ascii --indent 2 <$MANIFEST_LOCATION >$TEMP_DIR/$i.json | ||
done | ||
} | ||
|
||
compare_bundles() | ||
{ | ||
echo "[INFO] Comparing $i builds..." | ||
|
||
for j in $(seq 2 $N) | ||
do | ||
diff $TEMP_DIR/1.json $TEMP_DIR/$j.json | ||
# Used to check the error code | ||
V=$? | ||
if [ $V -eq 1 ];then | ||
echo "[ERROR] Build hashes are not identical" | ||
exit $V | ||
fi | ||
done | ||
|
||
echo "[INFO] Everything works fine, Bye!" | ||
} | ||
|
||
main() | ||
{ | ||
build_bundles | ||
compare_bundles | ||
} | ||
|
||
echo "[INFO] Start of script" | ||
main | ||
echo "[INFO] End of script" |