feat: add a new variable without colision to test storage workflow #19
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 Core Contracts Storage Changes | |
on: | |
push: | |
branches: | |
- development | |
- fix-core-contracts-storage-check | |
pull_request: | |
jobs: | |
provide_contracts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 2 # Ensure the previous commit is available for comparison | |
- name: Install Foundry | |
uses: onbjerg/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Narrow down test matrix scope to changed contracts to limit API requests | |
id: changed-contracts | |
uses: tj-actions/changed-files@v42 | |
with: | |
files_yaml: | | |
contracts: | |
- packages/contracts/src/dollar/core/*.sol | |
- name: Remove newly added contracts from the list | |
id: filter-new-contracts | |
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 | |
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 | |
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 | |
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 }} | |
failOnRemoval: true |