Skip to content

Commit c38c0c6

Browse files
authored
feat: add ci shellcheck (#753)
* feat: add ci shellcheck * fix: run on scripts change * test: if ci shellcheck would run * chore: pin the shellcheck version * test: shellckeck * fix: add manual workflow execution * fix: runner * pin: 22.04 * chore: run always in PR if some script is changed * fix: review * fix: shellcheck
1 parent a3f9a8d commit c38c0c6

File tree

3 files changed

+53
-23
lines changed

3 files changed

+53
-23
lines changed

.github/workflows/pr_checking.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,3 @@ jobs:
5858
run: gh pr close ${{ github.event.pull_request.number }} --comment "Spam detected"
5959
env:
6060
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61-

.github/workflows/shellcheck.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--- # Workflow to run shellckeck on all shell scripts
2+
3+
name: Shellcheck
4+
on:
5+
pull_request:
6+
paths:
7+
- '**/*.sh'
8+
- 'scripts/**'
9+
workflow_dispatch:
10+
branches:
11+
- "**"
12+
13+
jobs:
14+
shellcheck_scripts:
15+
runs-on: ubuntu-22.04
16+
timeout-minutes: 10
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install shellcheck
21+
run: sudo apt-get install shellcheck=0.8.0-2
22+
23+
- name: Run shellcheck
24+
run: |
25+
cd scripts
26+
shellcheck ./*.sh

scripts/prove_stdio.sh

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,22 @@ fi
9595
# proof. This is useful for quickly testing decoding and all of the
9696
# other non-proving code.
9797
if [[ $TEST_ONLY == "test_only" ]]; then
98-
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
99-
if grep -q 'All proof witnesses have been generated successfully.' $TEST_OUT_PATH; then
98+
cargo run --quiet --release --package zero --bin leader -- \
99+
--test-only \
100+
--runtime in-memory \
101+
--load-strategy on-demand \
102+
--block-batch-size "$BLOCK_BATCH_SIZE" \
103+
--proof-output-dir "$PROOF_OUTPUT_DIR" \
104+
stdio < "$INPUT_FILE" &> "$TEST_OUT_PATH"
105+
106+
if grep -q 'All proof witnesses have been generated successfully.' "$TEST_OUT_PATH"; then
100107
echo -e "\n\nSuccess - Note this was just a test, not a proof"
101-
rm $TEST_OUT_PATH
108+
rm "$TEST_OUT_PATH"
102109
exit
103110
else
104111
# Some error occurred, display the logs and exit.
105-
cat $OUT_LOG_PATH
106-
echo "Failed to create proof witnesses. See $OUT_LOG_PATH for more details."
112+
cat "$TEST_OUT_PATH"
113+
echo "Failed to create proof witnesses. See $TEST_OUT_PATH for more details."
107114
exit 1
108115
fi
109116
fi
@@ -112,45 +119,43 @@ cargo build --release --jobs "$num_procs"
112119

113120

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

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

127-
cat $PROOFS_FILE_LIST | while read proof_file;
136+
while read -r proof_file;
128137
do
129138
echo "Verifying proof file $proof_file"
130-
verify_file=$PROOF_OUTPUT_DIR/verify_$(basename $proof_file).out
131-
"${REPO_ROOT}/target/release/verifier" -f $proof_file | tee $verify_file
132-
if grep -q 'All proofs verified successfully!' $verify_file; then
139+
verify_file=$PROOF_OUTPUT_DIR/verify_$(basename "$proof_file").out
140+
"${REPO_ROOT}/target/release/verifier" -f "$proof_file" | tee "$verify_file"
141+
if grep -q 'All proofs verified successfully!' "$verify_file"; then
133142
echo "Proof verification for file $proof_file successful";
134-
rm $verify_file # we keep the generated proof for potential reuse
143+
rm "$verify_file" # we keep the generated proof for potential reuse
135144
else
136145
# Some error occurred with verification, display the logs and exit.
137-
cat $verify_file
146+
cat "$verify_file"
138147
echo "There was an issue with proof verification. See $verify_file for more details.";
139148
exit 1
140149
fi
141-
done
150+
done < "$PROOFS_FILE_LIST"
142151

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

146155
echo "Success!"
147-
echo "Proving duration:" $duration_sec " seconds"
156+
echo "Proving duration: $duration_sec seconds"
148157
echo "Note, this duration is inclusive of circuit handling and overall process initialization";
149158

150159
# Clean up in case of success
151-
rm $OUTPUT_LOG
152-
153-
154-
155-
160+
rm "$OUTPUT_LOG"
156161

0 commit comments

Comments
 (0)