diff --git a/.github/workflows/core-contracts-storage-check.yml b/.github/workflows/core-contracts-storage-check.yml index 085e4d3bb..917e14e95 100644 --- a/.github/workflows/core-contracts-storage-check.yml +++ b/.github/workflows/core-contracts-storage-check.yml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive - + - name: Install Foundry uses: onbjerg/foundry-toolchain@v1 with: @@ -35,10 +35,25 @@ jobs: env: CHANGED_CONTRACTS: ${{ steps.changed-contracts.outputs.contracts_all_changed_files }} run: | - for CONTRACT in "$CHANGED_CONTRACTS"; do - echo ${CONTRACT} | xargs basename -a | cut -d'.' -f1 | xargs -I{} echo src/dollar/core/{}.sol:{} >> contracts.txt + touch contracts.txt + + # Fetch the latest state of the development branch to compare + git fetch origin development + + # Iterate through changed contracts and check if they existed in the development branch + for CONTRACT in $CHANGED_CONTRACTS; do + if git show origin/development:$CONTRACT > /dev/null 2>&1; then + # If the contract existed in the development branch, add it to the list for storage check + echo ${CONTRACT} | xargs basename -a | cut -d'.' -f1 | xargs -I{} echo src/dollar/core/{}.sol:{} >> contracts.txt + else + echo "$CONTRACT is a new contract, skipping storage check." + fi done - echo "matrix=$(cat contracts.txt | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + + # Set the matrix only if there are contracts to check + if [ -s contracts.txt ]; then + echo "matrix=$(cat contracts.txt | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + fi outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -67,5 +82,4 @@ jobs: with: workingDirectory: packages/contracts contract: ${{ matrix.contract }} - failOnRemoval: true - + failOnRemoval: true \ No newline at end of file diff --git a/.github/workflows/diamond-storage-check.yml b/.github/workflows/diamond-storage-check.yml index d4f869098..4322b1114 100644 --- a/.github/workflows/diamond-storage-check.yml +++ b/.github/workflows/diamond-storage-check.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -39,10 +39,25 @@ jobs: env: CHANGED_LIBS: ${{ steps.changed-libraries.outputs.libraries_all_changed_files }} run: | - for DIAMOND_LIB in "$CHANGED_LIBS"; do - echo ${DIAMOND_LIB} | xargs basename -a | cut -d'.' -f1 | xargs -I{} echo src/dollar/libraries/{}.sol:{} >> contracts.txt + touch contracts.txt + + # Fetch the latest state of the development branch to compare + git fetch origin development + + # Iterate through changed libraries and check if they existed in the development branch + for DIAMOND_LIB in $CHANGED_LIBS; do + if git show origin/development:$DIAMOND_LIB > /dev/null 2>&1; then + # If the library existed in the development branch, add it to the list for storage check + echo ${DIAMOND_LIB} | xargs basename -a | cut -d'.' -f1 | xargs -I{} echo src/dollar/libraries/{}.sol:{} >> contracts.txt + else + echo "$DIAMOND_LIB is a new library, skipping storage check." + fi done - echo "matrix=$(cat contracts.txt | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + + # Set the matrix only if there are libraries to check + if [ -s contracts.txt ]; then + echo "matrix=$(cat contracts.txt | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + fi outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -65,11 +80,10 @@ jobs: uses: onbjerg/foundry-toolchain@v1 with: version: nightly - + - name: Check For Diamond Storage Changes uses: ubiquity/foundry-storage-check@main with: workingDirectory: packages/contracts contract: ${{ matrix.contract }} - failOnRemoval: true - failOnLabelDiff: true + failOnRemoval: true \ No newline at end of file