@@ -98,36 +98,24 @@ function compile-solidity {
9898
9999 # Compile using the local foundry.toml with proper remappings.
100100 # forge fetches solc from binaries.soliditylang.org on first use; transient
101- # DNS/TLS failures there have caused silent partial builds (the loop kept going
102- # and compile-solidity returned success while an example's artifacts were never
103- # written). Track per-subdir failures and surface them so run_step retries.
104- local failed_subdirs=()
101+ # DNS/TLS failures there have silently produced partial builds in CI (the loop
102+ # kept going and compile-solidity returned success while an example's artifacts
103+ # were never written). Wrap each forge build in ci3/retry and propagate any
104+ # per-subdir failure so run_step retries the whole step.
105105 (
106106 cd " $SOLIDITY_DIR "
107107 for subdir in * /; do
108108 if [ -d " $subdir " ] && ls " $subdir " /* .sol > /dev/null 2>&1 ; then
109109 local subdir_name=$( basename " $subdir " )
110110 echo_stderr " Compiling $subdir_name ..."
111- local attempt
112- for attempt in 1 2 3; do
113- if forge build \
114- --contracts " $subdir " \
115- --out " $OUTPUT_DIR /$subdir_name " \
116- --no-cache; then
117- break
118- fi
119- if [ " $attempt " -lt 3 ]; then
120- echo_stderr " forge build for $subdir_name failed (attempt $attempt /3), retrying in $(( attempt * 5 )) s..."
121- sleep $(( attempt * 5 ))
122- else
123- echo_stderr " ERROR: forge build for $subdir_name failed after 3 attempts"
124- echo " $subdir_name " >> " $OUTPUT_DIR /.failed"
125- fi
126- done
111+ if ! retry " forge build --contracts $subdir --out $OUTPUT_DIR /$subdir_name --no-cache" ; then
112+ echo " $subdir_name " >> " $OUTPUT_DIR /.failed"
113+ fi
127114 fi
128115 done
129116 )
130117 if [ -f " $OUTPUT_DIR /.failed" ]; then
118+ local failed_subdirs=()
131119 while IFS= read -r name; do failed_subdirs+=(" $name " ); done < " $OUTPUT_DIR /.failed"
132120 rm -f " $OUTPUT_DIR /.failed"
133121 echo_stderr " ERROR: Solidity compilation failed for: ${failed_subdirs[*]} "
0 commit comments