Skip to content

Commit

Permalink
Fix CI/CD to only check size of contracts we will deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSparksCode committed Nov 22, 2023
1 parent 922e378 commit 0da0ab6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ jobs:

- name: Check contract sizes
run: |
forge build --sizes && \
forge build && \
for file in out/*.sol/*.json; do
# Skip test files and script files
if [[ "$file" == *".t.sol"* || "$file" == *".s.sol"* ]]; then
continue
fi
# Extract contract name from the file path
contract_name=$(basename $(dirname $file))
# Check if the source file for the contract exists anywhere within src/contracts/
if ! find src/contracts/ -type f -name "${contract_name}.sol" | grep -q .; then
continue
fi
# Calculate the size of the deployed bytecode
size=$(cat "$file" | jq '.deployedBytecode.object' | wc -c | awk '{print int(($1-2)/2)}')
# Check if size exceeds the limit
if [ $size -gt 24576 ]; then
echo "Contract in $file exceeds max size of 24576 bytes (Size: $size bytes)"
exit 1
Expand Down

0 comments on commit 0da0ab6

Please sign in to comment.