|
7 | 7 | branches: [main] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - contracts: |
| 10 | + solidity-tests: |
| 11 | + name: Solidity Tests |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 | steps: |
13 | 14 | - uses: actions/checkout@v4 |
14 | 15 | with: |
15 | 16 | submodules: recursive |
16 | 17 | - uses: foundry-rs/foundry-toolchain@v1 |
17 | | - - run: cd contracts && forge test |
18 | | - - run: cd contracts && forge build |
| 18 | + - name: Run forge test |
| 19 | + working-directory: contracts |
| 20 | + run: forge test |
19 | 21 |
|
20 | | - sdk: |
| 22 | + typescript-build: |
| 23 | + name: TypeScript Build |
21 | 24 | runs-on: ubuntu-latest |
22 | 25 | steps: |
23 | 26 | - uses: actions/checkout@v4 |
24 | 27 | - uses: actions/setup-node@v4 |
25 | 28 | with: |
26 | 29 | node-version: 22 |
27 | | - - run: npm ci |
28 | | - - run: cd sdk && npm run build |
29 | | - - run: cd sdk && npx tsc --noEmit |
| 30 | + - name: Build SDK |
| 31 | + working-directory: sdk |
| 32 | + run: | |
| 33 | + npm install |
| 34 | + npm run build |
| 35 | + - name: Build CLI |
| 36 | + working-directory: cli |
| 37 | + run: | |
| 38 | + npm install |
| 39 | + npm run build |
30 | 40 |
|
31 | | - cli: |
| 41 | + happy-path-integration: |
| 42 | + name: Happy-Path Integration |
32 | 43 | runs-on: ubuntu-latest |
| 44 | + needs: |
| 45 | + - solidity-tests |
| 46 | + - typescript-build |
33 | 47 | steps: |
34 | 48 | - uses: actions/checkout@v4 |
35 | | - - uses: actions/setup-node@v4 |
36 | 49 | with: |
37 | | - node-version: 22 |
38 | | - - run: npm ci |
39 | | - - run: cd cli && npm run build |
40 | | - - run: cd cli && npm test |
41 | | - |
42 | | - adapters: |
43 | | - runs-on: ubuntu-latest |
44 | | - steps: |
45 | | - - uses: actions/checkout@v4 |
| 50 | + submodules: recursive |
| 51 | + - uses: foundry-rs/foundry-toolchain@v1 |
46 | 52 | - uses: actions/setup-node@v4 |
47 | 53 | with: |
48 | 54 | node-version: 22 |
49 | | - - run: npm ci |
50 | | - - run: cd adapters/eliza && npm run build |
51 | | - - run: cd adapters/game && npm run build |
| 55 | + - name: Install workspace dependencies |
| 56 | + run: npm install |
| 57 | + - name: Build SDK |
| 58 | + working-directory: sdk |
| 59 | + run: npm run build |
| 60 | + - name: Start anvil |
| 61 | + run: | |
| 62 | + anvil --host 0.0.0.0 --port 8545 --chain-id 31337 > /tmp/anvil.log 2>&1 & |
| 63 | + echo "Waiting for anvil..." |
| 64 | + for i in $(seq 1 30); do |
| 65 | + if curl -s -X POST -H "Content-Type: application/json" \ |
| 66 | + -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' \ |
| 67 | + http://localhost:8545 > /dev/null 2>&1; then |
| 68 | + echo "Anvil is ready" |
| 69 | + exit 0 |
| 70 | + fi |
| 71 | + sleep 1 |
| 72 | + done |
| 73 | + echo "Anvil failed to start" |
| 74 | + cat /tmp/anvil.log |
| 75 | + exit 1 |
| 76 | + - name: Deploy contracts |
| 77 | + working-directory: contracts |
| 78 | + run: | |
| 79 | + mkdir -p deployments |
| 80 | + forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast 2>&1 | tee /tmp/forge-output.txt |
| 81 | + - name: Parse deployed addresses |
| 82 | + run: | |
| 83 | + MOCK_USDC=$(grep -oP 'MOCK_USDC=\s*\K0x[a-fA-F0-9]+' /tmp/forge-output.txt) |
| 84 | + PAYMENT_CHANNEL=$(grep -oP 'PAYMENT_CHANNEL=\s*\K0x[a-fA-F0-9]+' /tmp/forge-output.txt) |
| 85 | + SERVICE_REGISTRY=$(grep -oP 'SERVICE_REGISTRY=\s*\K0x[a-fA-F0-9]+' /tmp/forge-output.txt) |
| 86 | + SPENDING_POLICY=$(grep -oP 'SPENDING_POLICY=\s*\K0x[a-fA-F0-9]+' /tmp/forge-output.txt) |
| 87 | + CHAIN_ID=$(grep -oP 'CHAIN_ID=\s*\K[0-9]+' /tmp/forge-output.txt) |
| 88 | +
|
| 89 | + cat > contracts/deployments/local.json <<JSONEOF |
| 90 | + { |
| 91 | + "chainId": $CHAIN_ID, |
| 92 | + "mockUSDC": "$MOCK_USDC", |
| 93 | + "paymentChannel": "$PAYMENT_CHANNEL", |
| 94 | + "serviceRegistry": "$SERVICE_REGISTRY", |
| 95 | + "spendingPolicy": "$SPENDING_POLICY" |
| 96 | + } |
| 97 | + JSONEOF |
| 98 | +
|
| 99 | + echo "USDC_ADDRESS=$MOCK_USDC" >> "$GITHUB_ENV" |
| 100 | + echo "PAYMENT_CHANNEL_ADDRESS=$PAYMENT_CHANNEL" >> "$GITHUB_ENV" |
| 101 | +
|
| 102 | + echo "=== deployments/local.json ===" |
| 103 | + cat contracts/deployments/local.json |
| 104 | + - name: Start price-feed server |
| 105 | + working-directory: services/price-feed |
| 106 | + env: |
| 107 | + CHAIN: local |
| 108 | + RPC_URL: http://localhost:8545 |
| 109 | + run: | |
| 110 | + npx tsx src/server.ts > /tmp/price-feed.log 2>&1 & |
| 111 | + echo "Waiting for price-feed server..." |
| 112 | + for i in $(seq 1 30); do |
| 113 | + if curl -s http://localhost:3000/health 2>/dev/null | grep -q '"ok"'; then |
| 114 | + echo "Price-feed server is ready" |
| 115 | + exit 0 |
| 116 | + fi |
| 117 | + sleep 1 |
| 118 | + done |
| 119 | + echo "Price-feed server failed to start" |
| 120 | + echo "=== server log ===" |
| 121 | + cat /tmp/price-feed.log |
| 122 | + exit 1 |
| 123 | + - name: Run happy-path harness |
| 124 | + working-directory: services/price-feed |
| 125 | + env: |
| 126 | + PRIVATE_KEY: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 |
| 127 | + PAYEE_PRIVATE_KEY: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d |
| 128 | + RPC_URL: http://localhost:8545 |
| 129 | + BASE_URL: http://localhost:3000 |
| 130 | + run: node scripts/happy-path.mjs |
0 commit comments