From 88d5432f18e6686c994476f941bbbcc9412b2450 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Mon, 28 Oct 2024 12:52:07 +0100 Subject: [PATCH] feat: add ci shellcheck --- .github/workflows/shellcheck.yml | 23 +++++++++++++++++ scripts/prove_stdio.sh | 43 +++++++++++++++++++------------- 2 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 000000000..627a2b02a --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -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 diff --git a/scripts/prove_stdio.sh b/scripts/prove_stdio.sh index c3c794086..773923b56 100755 --- a/scripts/prove_stdio.sh +++ b/scripts/prove_stdio.sh @@ -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 @@ -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"