Skip to content

Commit

Permalink
feat: add ci shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko committed Oct 28, 2024
1 parent 0aad2a7 commit 88d5432
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 17 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Shellcheck
on:
push:
paths:
- 'scripts/**'
pull_request:
branches:
- "**"

jobs:
shellcheck_scripts:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- name: Install shellcheck
run: sudo apt-get install shellcheck

- name: Run shellcheck
run: |
cd scripts
shellcheck ./*.sh
43 changes: 26 additions & 17 deletions scripts/prove_stdio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,21 @@ fi
# proof. This is useful for quickly testing decoding and all of the
# other non-proving code.
if [[ $TEST_ONLY == "test_only" ]]; then
cargo run --quiet --release --package zero --bin leader -- --test-only --runtime in-memory --load-strategy on-demand --block-batch-size $BLOCK_BATCH_SIZE --proof-output-dir $PROOF_OUTPUT_DIR stdio < $INPUT_FILE &> $TEST_OUT_PATH
if grep -q 'All proof witnesses have been generated successfully.' $TEST_OUT_PATH; then
cargo run --quiet --release --package zero --bin leader -- \
--test-only \
--runtime in-memory \
--load-strategy on-demand \
--block-batch-size "$BLOCK_BATCH_SIZE" \
--proof-output-dir "$PROOF_OUTPUT_DIR" \
stdio < "$INPUT_FILE" &> "$TEST_OUT_PATH"

if grep -q 'All proof witnesses have been generated successfully.' "$TEST_OUT_PATH"; then
echo -e "\n\nSuccess - Note this was just a test, not a proof"
rm $TEST_OUT_PATH
rm "$TEST_OUT_PATH"
exit
else
# Some error occurred, display the logs and exit.
cat $OUT_LOG_PATH
cat "$OUT_LOG_PATH"
echo "Failed to create proof witnesses. See $OUT_LOG_PATH for more details."
exit 1
fi
Expand All @@ -112,43 +119,45 @@ cargo build --release --jobs "$num_procs"


start_time=$(date +%s%N)
"${REPO_ROOT}/target/release/leader" --runtime in-memory --load-strategy on-demand -n 1 --block-batch-size $BLOCK_BATCH_SIZE \
--proof-output-dir $PROOF_OUTPUT_DIR stdio < $INPUT_FILE &> $OUTPUT_LOG
"${REPO_ROOT}/target/release/leader" --runtime in-memory \
--load-strategy on-demand -n 1 \
--block-batch-size "$BLOCK_BATCH_SIZE" \
--proof-output-dir "$PROOF_OUTPUT_DIR" stdio < "$INPUT_FILE" &> "$OUTPUT_LOG"
end_time=$(date +%s%N)

cat $OUTPUT_LOG | grep "Successfully wrote to disk proof file " | awk '{print $NF}' | tee $PROOFS_FILE_LIST
grep "Successfully wrote to disk proof file " "$OUTPUT_LOG" | awk '{print $NF}' | tee "$PROOFS_FILE_LIST"
if [ ! -s "$PROOFS_FILE_LIST" ]; then
# Some error occurred, display the logs and exit.
cat $OUTPUT_LOG
cat "$OUTPUT_LOG"
echo "Proof list not generated, some error happened. For more details check the log file $OUTPUT_LOG"
exit 1
fi

cat $PROOFS_FILE_LIST | while read proof_file;
while read -r proof_file;
do
echo "Verifying proof file $proof_file"
verify_file=$PROOF_OUTPUT_DIR/verify_$(basename $proof_file).out
"${REPO_ROOT}/target/release/verifier" -f $proof_file | tee $verify_file
if grep -q 'All proofs verified successfully!' $verify_file; then
verify_file=$PROOF_OUTPUT_DIR/verify_$(basename "$proof_file").out
"${REPO_ROOT}/target/release/verifier" -f "$proof_file" | tee "$verify_file"
if grep -q 'All proofs verified successfully!' "$verify_file"; then
echo "Proof verification for file $proof_file successful";
rm $verify_file # we keep the generated proof for potential reuse
rm "$verify_file" # we keep the generated proof for potential reuse
else
# Some error occurred with verification, display the logs and exit.
cat $verify_file
cat "$verify_file"
echo "There was an issue with proof verification. See $verify_file for more details.";
exit 1
fi
done
done < "$PROOFS_FILE_LIST"

duration_ns=$((end_time - start_time))
duration_sec=$(echo "$duration_ns / 1000000000" | bc -l)

echo "Success!"
echo "Proving duration:" $duration_sec " seconds"
echo "Proving duration: $duration_sec seconds"
echo "Note, this duration is inclusive of circuit handling and overall process initialization";

# Clean up in case of success
rm $OUTPUT_LOG
rm "$OUTPUT_LOG"



Expand Down

0 comments on commit 88d5432

Please sign in to comment.