Skip to content

Commit

Permalink
Merge branch 'pull/974' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
rndquu committed Jan 28, 2025
2 parents 6f3b3e0 + c95eaa0 commit 94aa536
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 13 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/core-contracts-storage-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down Expand Up @@ -67,5 +82,4 @@ jobs:
with:
workingDirectory: packages/contracts
contract: ${{ matrix.contract }}
failOnRemoval: true

failOnRemoval: true
26 changes: 20 additions & 6 deletions .github/workflows/diamond-storage-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -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 }}
Expand Down Expand Up @@ -71,5 +86,4 @@ jobs:
with:
workingDirectory: packages/contracts
contract: ${{ matrix.contract }}
failOnRemoval: true
failOnLabelDiff: true
failOnRemoval: true
64 changes: 64 additions & 0 deletions .github/workflows/generate-storage-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Generate Storage Artifacts

on:
workflow_dispatch

jobs:
provide_contracts:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly

- name: Set contracts matrix for all matching contracts
id: set-matrix
working-directory: packages/contracts
run: |
# Collect all contracts from core and libraries
CONTRACTS="$(find src/dollar/core/*.sol src/dollar/libraries/Lib*.sol -type f)"
for CONTRACT in $CONTRACTS; do
# Extract the contract name without the .sol extension
CONTRACT_NAME=$(basename "$CONTRACT" .sol)
# Write <contract path>:<contract name> to contracts.txt
echo "${CONTRACT}:${CONTRACT_NAME}" >> contracts.txt
done
# Set the matrix output
echo "matrix=$(cat contracts.txt | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

check_storage_layout:
needs: provide_contracts
runs-on: ubuntu-latest
if: ${{ needs.provide_contracts.outputs.matrix != '[]' && needs.provide_contracts.outputs.matrix != '' }}

strategy:
matrix:
contract: ${{ fromJSON(needs.provide_contracts.outputs.matrix) }}

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly

- name: Check For Core Contracts Storage Changes
uses: Rubilmax/foundry-storage-check@main
with:
workingDirectory: packages/contracts
contract: ${{ matrix.contract }}

0 comments on commit 94aa536

Please sign in to comment.