@@ -2,7 +2,8 @@ name: Check Storage Layout Changes
22
33on :
44 pull_request :
5- branches : [main]
5+ branches :
6+ - ' *'
67 paths :
78 - ' solidity/**'
89 workflow_dispatch :
@@ -53,13 +54,30 @@ jobs:
5354 env :
5455 BASE_REF : ${{ github.event.inputs.base || github.event.pull_request.base.sha }}
5556 run : |
57+ # Fetch the base reference
5658 git fetch origin $BASE_REF
57- git checkout $BASE_REF -- solidity/contracts
59+ # Check if BASE_REF is a commit SHA (40 hex characters) or a branch name
60+ if [[ "$BASE_REF" =~ ^[0-9a-f]{40}$ ]]; then
61+ # For commit SHAs, checkout directly without origin/ prefix
62+ git checkout $BASE_REF -- solidity/contracts
63+ else
64+ # For branch names, use origin/ prefix
65+ git checkout origin/$BASE_REF -- solidity/contracts
66+ fi
5867
5968 # Run the command on the target branch
6069 - name : Run command on target branch
6170 run : yarn workspace @hyperlane-xyz/core storage base-storage
6271
6372 # Compare outputs
64- - name : Compare outputs
65- run : diff --unified solidity/base-storage solidity/HEAD-storage
73+ - name : Compare outputs (fail on removals only)
74+ run : |
75+ DIFF_OUTPUT=$(diff --unified solidity/base-storage solidity/HEAD-storage || true)
76+ echo "$DIFF_OUTPUT"
77+ # Fail only if there are removal lines in diff hunks (lines starting with '-' but not '---')
78+ if echo "$DIFF_OUTPUT" | grep -E '^-([^-])' >/dev/null; then
79+ echo "Detected storage removals in diff. Failing job."
80+ exit 1
81+ else
82+ echo "No storage removals detected."
83+ fi
0 commit comments