Skip to content

Commit afae923

Browse files
committed
fix: Add cleanup and wait logic for Anvil processes in deployment workflow
1 parent 9b53432 commit afae923

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,34 @@ jobs:
7676
ANVIL_SEPOLIA_RPC_URL: http://localhost:8545
7777
ANVIL_ARBITRUM_SEPOLIA_RPC_URL: http://localhost:8546
7878
run: |
79+
# Clean up any existing anvil processes
80+
make cleanup-anvil
81+
82+
# Start anvil forks in background
7983
make fork-sepolia &
84+
ANVIL_SEPOLIA_PID=$!
8085
make fork-arbitrum-sepolia &
86+
ANVIL_ARBITRUM_PID=$!
8187
8288
# Wait for anvil instances to be ready
89+
echo "Waiting for anvil instances to start..."
8390
sleep 5
8491
92+
# Check if anvil processes are running
93+
if ! kill -0 $ANVIL_SEPOLIA_PID 2>/dev/null; then
94+
echo "Error: Anvil Sepolia fork failed to start"
95+
exit 1
96+
fi
97+
if ! kill -0 $ANVIL_ARBITRUM_PID 2>/dev/null; then
98+
echo "Error: Anvil Arbitrum fork failed to start"
99+
exit 1
100+
fi
101+
85102
# Deploy all contracts using the Makefile target
86103
make deploy-on-anvil
104+
105+
# Clean up anvil processes
106+
make cleanup-anvil
87107
88108
- name: Deploy contracts on Ethereum Mainnet or Sepolia
89109
if: inputs.network == 'sepolia' || inputs.network == 'ethereum'

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ generate-coverage:
4444
clean:
4545
forge clean
4646

47+
cleanup-anvil:
48+
@echo "Stopping all anvil processes..."
49+
@pkill -f "anvil.*port" || true
50+
@sleep 2
51+
@echo "Anvil cleanup completed."
52+
4753
#
4854
# High-level deployment targets
4955
#

0 commit comments

Comments
 (0)