Skip to content

Commit

Permalink
Merge branch 'feat/storage-layout-check'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Nov 27, 2024
2 parents ee19085 + dd628db commit 0dd8655
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 43 deletions.
64 changes: 29 additions & 35 deletions .github/workflows/compare-layouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@ jobs:
# trigger is no matter what, because the status should be updated
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# this step would have been better located in forge-ci.yml, but since it needs the secret
# it is placed here. first, it is updated to pending here and failure/success is updated later.
run: |
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-d '{
"state": "pending",
"context": "Compare Storage Layouts",
"description": "In progress...",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}' \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }}
gh api \
--method POST \
/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
-f state=pending \
-f context='${{ github.workflow.name }}' \
-f description='In progress...' \
-f target_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Get PR number
id: pr-context
if: ${{ github.event.workflow_run.event == 'pull_request' }}
Expand Down Expand Up @@ -94,7 +91,6 @@ jobs:
env:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
# Log the workflow trigger details for debugging.
Expand Down Expand Up @@ -143,11 +139,12 @@ jobs:
["ExoCapsule"]="$capsule"
)
# Iterate over the array and run `cast storage` for each contract
RPC_URL="https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY"
for contract in "${!contracts[@]}"; do
address=${contracts[$contract]}
if [[ -n $address ]]; then
echo "Processing $contract at address $address"
cast storage --json "$address" --rpc-url "https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY" \
cast storage --json "$address" --rpc-url "$RPC_URL" \
--etherscan-api-key "$ETHERSCAN_API_KEY" > "$contract.deployed.json"
mv "$contract.deployed.json" "$pwd"
else
Expand Down Expand Up @@ -185,30 +182,27 @@ jobs:
continue-on-error: true
- name: Update parent commit status
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if the outcome is not set, it will post failure
run: |
outcome=$(
[[ "${{ steps.compare-layouts.outcome }}" == "success" ]] &&
echo "success" ||
echo "failure"
)
description=$(
[[ "${{ steps.compare-layouts.outcome }}" == "success" ]] &&
echo "Storage layouts match" ||
([[ "${{ steps.compare-layouts.outcome }}" == "failure" ]] &&
echo "Storage layouts do not match" ||
echo "Job skipped since ${{ github.event.workflow_run.name }} failed.")
)
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-d "{
\"state\": \"${outcome}\",
\"context\": \"Compare Storage Layouts\",
\"description\": \"${description}\",
\"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"
}" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }}
if [[ "${{ steps.compare-layouts.outcome }}" == "success" ]]; then
outcome="success"
description="Storage layouts match"
elif [[ "${{ steps.compare-layouts.outcome }}" == "failure" ]]; then
outcome="failure"
description="Storage layouts do not match"
else
outcome="failure"
description="Job skipped since ${{ github.event.workflow_run.name }} failed."
fi
gh api \
--method POST \
/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
-f state="$outcome" \
-f context='${{ github.workflow.name }}' \
-f description="$description" \
-f target_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Set message again
id: set-message-again
env:
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/forge-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ jobs:
./cache
./broadcast
key: build-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}
# This step restores the base branch layout file, while the next step generates the PR
# branch layout files.
- name: Restore base branch layout file
uses: actions/cache/restore@v3
with:
path: ExocoreGateway.base.json
key: ExocoreGateway-base-layout-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}
- name: Generate storage layout files for the PR
run: |
for file in Bootstrap ClientChainGateway RewardVault Vault ExocoreGateway ExoCapsule; do
Expand All @@ -163,7 +156,7 @@ jobs:
- name: Copy back base branch layout file
run: cp /tmp/ExocoreGateway.base.json ./ExocoreGateway.base.json
- name: Zip storage layout files
run: zip "storage-layouts.zip" "./*.compiled.json" "./ExocoreGateway.base.json"
run: zip storage-layouts.zip ./*.compiled.json ./ExocoreGateway.base.json
- name: Upload storage layout files as an artifact
uses: actions/upload-artifact@v4
with:
Expand Down

0 comments on commit 0dd8655

Please sign in to comment.