feat: skip new contracts on check_storage_layout
#357
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check For Diamond Storage Changes | |
on: | |
push: | |
branches: | |
- development | |
- fix-core-contracts-storage-check | |
paths: | |
- '**.sol' | |
pull_request: | |
paths: | |
- '**.sol' | |
jobs: | |
provide_contracts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 2 | |
- name: Install Foundry | |
uses: onbjerg/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Narrow down test matrix scope to changed Dollar libraries to limit API requests | |
id: changed-libraries | |
uses: tj-actions/changed-files@v42 | |
with: | |
files_yaml: | | |
libraries: | |
- packages/contracts/src/dollar/libraries/Lib*.sol | |
- name: Set contracts matrix | |
id: set-matrix | |
working-directory: packages/contracts | |
if: steps.changed-libraries.outputs.libraries_any_changed == 'true' | |
env: | |
CHANGED_LIBS: ${{ steps.changed-libraries.outputs.libraries_all_changed_files }} | |
run: | | |
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 | |
# 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 }} | |
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 Diamond Storage Changes | |
uses: ubiquity/foundry-storage-check@main | |
with: | |
workingDirectory: packages/contracts | |
contract: ${{ matrix.contract }} | |
failOnRemoval: true |