Skip to content

Commit 4e66528

Browse files
committed
fix(docs/examples): propagate forge build failures in compile-solidity
1 parent 6874e44 commit 4e66528

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

docs/examples/bootstrap.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,43 @@ function compile-solidity {
9696

9797
mkdir -p "$OUTPUT_DIR"
9898

99-
# Compile using the local foundry.toml with proper remappings
99+
# Compile using the local foundry.toml with proper remappings.
100+
# 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=()
100105
(
101106
cd "$SOLIDITY_DIR"
102107
for subdir in */; do
103108
if [ -d "$subdir" ] && ls "$subdir"/*.sol >/dev/null 2>&1; then
104109
local subdir_name=$(basename "$subdir")
105110
echo_stderr "Compiling $subdir_name..."
106-
forge build \
107-
--contracts "$subdir" \
108-
--out "$OUTPUT_DIR/$subdir_name" \
109-
--no-cache
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
110127
fi
111128
done
112129
)
130+
if [ -f "$OUTPUT_DIR/.failed" ]; then
131+
while IFS= read -r name; do failed_subdirs+=("$name"); done < "$OUTPUT_DIR/.failed"
132+
rm -f "$OUTPUT_DIR/.failed"
133+
echo_stderr "ERROR: Solidity compilation failed for: ${failed_subdirs[*]}"
134+
return 1
135+
fi
113136

114137
echo_stderr "Solidity artifacts written to $OUTPUT_DIR"
115138
}

0 commit comments

Comments
 (0)