Skip to content

Commit

Permalink
feat: fix storage check workflow to check against development branch
Browse files Browse the repository at this point in the history
  • Loading branch information
zugdev committed Oct 4, 2024
1 parent 9ed317f commit 18623bb
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions .github/workflows/core-contracts-storage-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 2
fetch-depth: 2 # Ensure we can access the previous commit

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
Expand All @@ -29,33 +29,32 @@ jobs:
contracts:
- packages/contracts/src/dollar/core/*.sol
- name: Remove newly added contracts from the list
id: filter-new-contracts
- name: Set contracts matrix
id: set-matrix
working-directory: packages/contracts
if: steps.changed-contracts.outputs.contracts_any_changed == 'true'
env:
CHANGED_CONTRACTS: ${{ steps.changed-contracts.outputs.contracts_all_changed_files }}
run: |
touch contracts.txt
CHANGED_CONTRACTS="${{ steps.changed-contracts.outputs.contracts_all_changed_files }}"
# Iterate through changed contracts and check if they existed in the previous commit
# 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 HEAD~1:$CONTRACT > /dev/null 2>&1; then
# If the contract existed in the previous commit, add it to the list
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
- name: Set contracts matrix
id: set-matrix
working-directory: packages/contracts
if: steps.changed-contracts.outputs.contracts_any_changed == 'true'
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
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

0 comments on commit 18623bb

Please sign in to comment.