## Summary - Extract shared bootstrap functions into `scripts/bootstrap-common.sh` (eliminates ~120 lines of duplicated forge/cast commands from e2e.yml) - Create reusable `scripts/wait-for-service.sh` for health checks (replaces 60-line inline wait-for-stack) - Merge dev and CI entrypoints into unified scripts branching on `CI` env var (delete `docker/ci-entrypoints/`) - Replace 4 per-service CI Dockerfiles with parameterized `docker/Dockerfile.service-ci` - Add `sync-tax-rates.mjs` to CI image builder stage - Fix: CI now grants txnBot recenter access (was missing) - Fix: txnBot funding parameterized (CI=10eth, local=1eth) - Delete 5 obsolete migration docs and 4 DinD integration files Net: -1540 lines removed Closes #107 ## Test plan - [ ] E2E pipeline passes (bootstrap sources shared script, services use old images with commands override) - [ ] build-ci-images pipeline builds all 4 services with unified Dockerfile - [ ] Local dev stack boots via `./scripts/dev.sh start` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: openhands <openhands@all-hands.dev> Reviewed-on: https://codeberg.org/johba/harb/pulls/108
74 lines
2.1 KiB
Bash
Executable file
74 lines
2.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# CI bootstrap script — runs under bash to support 'source' and bash-isms.
|
|
# Env vars ANVIL_RPC, CONTRACT_ENV, LOG_FILE, ONCHAIN_DIR, TXNBOT_FUND_VALUE,
|
|
# TXNBOT_ADDRESS, TXNBOT_PRIVATE_KEY must be set before calling this script.
|
|
set -euo pipefail
|
|
|
|
echo "=== Foundry version ==="
|
|
forge --version
|
|
cast --version
|
|
|
|
# Source shared bootstrap functions
|
|
source scripts/bootstrap-common.sh
|
|
|
|
echo "=== Waiting for Anvil ==="
|
|
wait_for_rpc
|
|
|
|
echo "=== Deploying contracts ==="
|
|
run_forge_script
|
|
extract_addresses
|
|
|
|
echo "=== Contract Deployment Complete ==="
|
|
echo "KRAIKEN: $KRAIKEN"
|
|
echo "STAKE: $STAKE"
|
|
echo "LIQUIDITY_MANAGER: $LIQUIDITY_MANAGER"
|
|
echo "DEPLOY_BLOCK: $DEPLOY_BLOCK"
|
|
|
|
# Build kraiken-lib BEFORE writing contracts.env
|
|
# (services wait for contracts.env, so kraiken-lib must be ready first)
|
|
echo "=== Building kraiken-lib (shared dependency) ==="
|
|
cd kraiken-lib
|
|
npm ci --ignore-scripts
|
|
if [[ -f ../scripts/sync-tax-rates.mjs ]]; then
|
|
node ../scripts/sync-tax-rates.mjs
|
|
fi
|
|
./node_modules/.bin/tsc
|
|
cd ..
|
|
|
|
# Get current block number as start block
|
|
START_BLOCK=$(cast block-number --rpc-url "$ANVIL_RPC")
|
|
|
|
# Write contracts.env with CI-specific extra vars
|
|
{
|
|
echo "KRAIKEN=$KRAIKEN"
|
|
echo "STAKE=$STAKE"
|
|
echo "LIQUIDITY_MANAGER=$LIQUIDITY_MANAGER"
|
|
echo "START_BLOCK=$START_BLOCK"
|
|
echo "PONDER_RPC_URL_1=http://anvil:8545"
|
|
echo "DATABASE_URL=postgres://ponder:ponder_local@postgres:5432/ponder_local"
|
|
echo "RPC_URL=http://anvil:8545"
|
|
} > "$CONTRACT_ENV"
|
|
|
|
# Write deployments-local.json for E2E tests
|
|
write_deployments_json "$ONCHAIN_DIR/deployments-local.json"
|
|
echo "=== deployments-local.json written ==="
|
|
cat "$ONCHAIN_DIR/deployments-local.json"
|
|
|
|
echo "=== Funding LiquidityManager ==="
|
|
fund_liquidity_manager
|
|
|
|
echo "=== Granting recenter access ==="
|
|
grant_recenter_access
|
|
|
|
echo "=== Calling recenter() to seed liquidity ==="
|
|
call_recenter
|
|
|
|
echo "=== Seeding application state (initial swap) ==="
|
|
seed_application_state
|
|
|
|
echo "=== Funding txnBot ==="
|
|
fund_txn_bot_wallet
|
|
|
|
echo "TXNBOT_PRIVATE_KEY=$TXNBOT_PRIVATE_KEY" >> "$CONTRACT_ENV"
|
|
|
|
echo "=== Bootstrap complete ==="
|