Files
icicle/scripts/hooks/pre-push
nonam3e b908053c0c Feat/m31 (#547)
This PR adds support of the m31 Field

---------

Co-authored-by: Jeremy Felder <jeremy.felder1@gmail.com>
2024-07-03 20:48:28 +07:00

53 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
status=0
if [[ $(codespell --skip ./**/target,./**/build,./docs/*.js,./docs/*.json -I .codespellignore 2>&1) ]];
then
echo "There are typos in some of the files you've changed. Please run the following to check what they are:"
echo "codespell --skip ./**/target,./**/build,./docs/*.js,./docs/*.json -I .codespellignore"
echo ""
status=1
fi
# Run clang-format on CUDA, C, and CPP files
# clang-format writes to stderr in dry-run mode. In order to capture the output to detect if there are changes needed we redirect stderr to stdin
if [[ $(find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune -o -path ./examples -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -ferror-limit=1 -style=file 2>&1) ]];
then
echo "🚨 There are files in Icicle Core that need formatting."
echo ""
echo "Please format all .c, .cpp, .h, .cu, .cuh files using the following command:"
echo "find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune -o -path ./examples -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format -i -style=file"
echo ""
echo "If you only want to see what formatting is required please run:"
echo "find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune -o -path ./examples -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -style=file"
echo ""
status=1
else
echo "🟩 Icicle Core format is fine"
fi
# Run go fmt across all Golang packages
if [[ $(go list ./... | xargs go fmt) ]];
then
echo "🚨 There are Golang files that need formatting."
echo "Please commit the formatted files"
echo ""
status=1
else
echo "🟩 Golang files format is fine"
fi
# Run cargo fmt on Rust files
cd wrappers/rust
if [[ $(find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --) ]];
then
echo "🚨 There are Rust files that need formatting."
echo "Please go to wrappers/rust and format the Rust files using the following command:"
echo "find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --"
status=1
else
echo "🟩 Rust files format is fine"
fi
exit $status