-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: ci storage diff - Credit where credit is due, modified from Stevens personal implementation. https://github.com/stevennevins/ci-workflows/blob/main/.github/workflows/storage-checker.yml * fix: ci * nit: ci name * fix: ci * fix: ci * chore: remove generated report * fix: debug ci
- Loading branch information
1 parent
4e9b422
commit fdd8ea8
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: lint and check format | ||
name: Lint and Check Format | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Check Storage Layout | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- "dev" | ||
jobs: | ||
check_storage: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: "Generate and prepare the storage reports for current branch" | ||
run: | | ||
bash bin/storage-report.sh pr | ||
- name: Checkout dev | ||
env: | ||
TARGET: ${{ github.event.pull_request.base.sha }} | ||
run: | | ||
git fetch origin $TARGET | ||
git checkout $TARGET | ||
- name: "Generate and prepare the storage reports for target branch" | ||
run: | | ||
bash bin/storage-report.sh target | ||
- name: Compare outputs | ||
run: | | ||
if ! diff --unified pr target; then | ||
echo "::warning::Differences found between PR and target branch storage layouts" | ||
fi |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
# Default output directory | ||
OUTPUT_DIR=${1:-docs/storage-report} | ||
|
||
# Function to print messages | ||
log() { | ||
echo "$(date '+%Y-%m-%d %H:%M:%S') [INFO] $1" | ||
} | ||
|
||
# Function to print error messages | ||
error() { | ||
echo "$(date '+%Y-%m-%d %H:%M:%S') [ERROR] $1" >&2 | ||
} | ||
|
||
log "Starting the storage report generation." | ||
|
||
# Create the output directory if it doesn't exist | ||
if ! mkdir -p "$OUTPUT_DIR"; then | ||
error "Failed to create output directory: $OUTPUT_DIR" | ||
exit 1 | ||
fi | ||
|
||
log "Output directory is set to: $OUTPUT_DIR" | ||
|
||
# Loop through Solidity files and generate storage report | ||
# NOTE: Ignores `src/contracts/interfaces` & `src/contracts/libraries` since they "should" not contain storage logic. | ||
for file in $(find src/contracts -name "*.sol" ! -path "src/contracts/interfaces/*" ! -path "src/contracts/libraries/*"); do | ||
contract_name=$(basename "$file" .sol) | ||
|
||
# Check if the file exists and is readable | ||
if [ ! -r "$file" ]; then | ||
error "Cannot read file: $file" | ||
continue | ||
fi | ||
|
||
log "Processing contract: $contract_name" | ||
|
||
# Run forge inspect and capture errors | ||
if ! forge inspect "$contract_name" storage --pretty > "$OUTPUT_DIR/$contract_name.md"; then | ||
error "Failed to generate storage report for contract: $contract_name" | ||
else | ||
log "Storage report generated for contract: $contract_name" | ||
fi | ||
done |