Skip to content

Commit 2133dfe

Browse files
committed
fix: prevent stderr warnings from contaminating bytecode comparison
forge inspect can emit compiler warnings to stderr even on success. With 2>&1, those warnings were mixed into the bytecode string, causing false positives when warnings differed between main and PR. Now stderr is discarded on success (2>/dev/null) and only captured on failure for the error message.
1 parent 7633721 commit 2133dfe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ci/check-upgrade-hygiene.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,16 @@ for name in $(jq -r '.[]' "$PR_DIR/upgrade-manifest.json"); do
8484
done
8585

8686
# --- Compare bytecodes (paths relative to --root, builds are cached) ---
87-
if ! main_bytecode=$(forge inspect "contracts/${name}.sol:$name" --root "$MAIN_DIR" deployedBytecode 2>&1); then
88-
echo "::error::Failed to inspect $name on main: $main_bytecode"
87+
# Capture only stdout for bytecode; stderr goes to /dev/null on success (warnings),
88+
# but on failure we re-run to capture the error message.
89+
if ! main_bytecode=$(forge inspect "contracts/${name}.sol:$name" --root "$MAIN_DIR" deployedBytecode 2>/dev/null); then
90+
echo "::error::Failed to inspect $name on main:$(forge inspect "contracts/${name}.sol:$name" --root "$MAIN_DIR" deployedBytecode 2>&1 || true)"
8991
ERRORS=$((ERRORS + 1))
9092
echo "::endgroup::"
9193
continue
9294
fi
93-
if ! pr_bytecode=$(forge inspect "contracts/${name}.sol:$name" --root "$PR_DIR" deployedBytecode 2>&1); then
94-
echo "::error::Failed to inspect $name on PR: $pr_bytecode"
95+
if ! pr_bytecode=$(forge inspect "contracts/${name}.sol:$name" --root "$PR_DIR" deployedBytecode 2>/dev/null); then
96+
echo "::error::Failed to inspect $name on PR:$(forge inspect "contracts/${name}.sol:$name" --root "$PR_DIR" deployedBytecode 2>&1 || true)"
9597
ERRORS=$((ERRORS + 1))
9698
echo "::endgroup::"
9799
continue

0 commit comments

Comments
 (0)