From 0da0ab6656c32952f738f2cc00c4852f0af3abbe Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Wed, 22 Nov 2023 17:41:01 +0200 Subject: [PATCH] Fix CI/CD to only check size of contracts we will deploy --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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