diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42d3f8176..cef41d0f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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