diff --git a/.github/workflows/compare-layouts.yml b/.github/workflows/compare-layouts.yml index 3f2f5d02..b23dd223 100644 --- a/.github/workflows/compare-layouts.yml +++ b/.github/workflows/compare-layouts.yml @@ -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' }} @@ -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. @@ -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 @@ -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: diff --git a/.github/workflows/forge-ci.yml b/.github/workflows/forge-ci.yml index cd5c4930..26486116 100644 --- a/.github/workflows/forge-ci.yml +++ b/.github/workflows/forge-ci.yml @@ -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 @@ -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: