|
| 1 | +name: CI |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + push: |
| 10 | + branches: [dev] |
| 11 | + |
| 12 | +permissions: {} |
| 13 | + |
| 14 | +jobs: |
| 15 | + smoke-test: |
| 16 | + name: Service smoke tests |
| 17 | + runs-on: ubuntu-latest |
| 18 | + env: |
| 19 | + COMPOSE_PROJECT_NAME: z3-smoke |
| 20 | + COMPOSE_FILE: docker-compose.yml:docker-compose.regtest.yml |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 23 | + with: |
| 24 | + persist-credentials: false |
| 25 | + |
| 26 | + - name: Generate TLS certs and regtest configs |
| 27 | + run: | |
| 28 | + mkdir -p config/tls config/regtest |
| 29 | + openssl req -x509 -newkey rsa:2048 \ |
| 30 | + -keyout config/tls/zaino.key -out config/tls/zaino.crt \ |
| 31 | + -sha256 -days 1 -nodes -subj "/CN=localhost" 2>/dev/null |
| 32 | + chmod 644 config/tls/zaino.key config/tls/zaino.crt |
| 33 | + echo "# dummy identity for CI" > config/regtest/zallet_identity.txt |
| 34 | + SALT=$(openssl rand -hex 16) |
| 35 | + HASH=$(printf 'zebra' | openssl dgst -sha256 -mac HMAC -macopt "key:$SALT" | awk '{print $NF}') |
| 36 | + sed -i "s|__GENERATED_BY_INIT_SH__|${SALT}\$${HASH}|" config/regtest/zallet.toml |
| 37 | +
|
| 38 | + - name: Validate compose configs |
| 39 | + run: | |
| 40 | + docker compose config --quiet |
| 41 | + docker compose --env-file .env.regtest config --quiet |
| 42 | +
|
| 43 | + - name: Start Zebra (regtest) |
| 44 | + run: | |
| 45 | + docker compose --env-file .env.regtest up -d zebra |
| 46 | + echo "Waiting for Zebra RPC..." |
| 47 | + for i in $(seq 1 60); do |
| 48 | + if curl -sf -X POST -H "Content-Type: application/json" \ |
| 49 | + -d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}' \ |
| 50 | + http://127.0.0.1:18232 > /dev/null 2>&1; then |
| 51 | + echo "Zebra is ready" |
| 52 | + break |
| 53 | + fi |
| 54 | + if [ "$i" -eq 60 ]; then echo "Zebra failed to start" && exit 1; fi |
| 55 | + sleep 2 |
| 56 | + done |
| 57 | +
|
| 58 | + - name: Verify Zebra is serving RPC |
| 59 | + run: | |
| 60 | + curl -sf -X POST -H "Content-Type: application/json" \ |
| 61 | + -d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}' \ |
| 62 | + http://127.0.0.1:18232 | jq . |
| 63 | +
|
| 64 | + - name: Mine block 1 (required for Zaino sync) |
| 65 | + run: | |
| 66 | + curl -sf -u zebra:zebra -X POST -H "Content-Type: application/json" \ |
| 67 | + -d '{"jsonrpc":"2.0","method":"generate","params":[1],"id":1}' \ |
| 68 | + http://127.0.0.1:18232 | jq . |
| 69 | +
|
| 70 | + - name: Start Zaino and verify JSON-RPC proxy |
| 71 | + run: | |
| 72 | + docker compose --env-file .env.regtest up -d zaino |
| 73 | + echo "Waiting for Zaino JSON-RPC..." |
| 74 | + for i in $(seq 1 30); do |
| 75 | + if RESULT=$(curl -sf -X POST -H "Content-Type: application/json" \ |
| 76 | + -d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}' \ |
| 77 | + http://127.0.0.1:8237 2>/dev/null); then |
| 78 | + echo "Zaino is ready" |
| 79 | + echo "$RESULT" | jq . |
| 80 | + break |
| 81 | + fi |
| 82 | + if [ "$i" -eq 30 ]; then |
| 83 | + echo "Zaino failed to start" |
| 84 | + docker compose --env-file .env.regtest logs zaino --tail 20 |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | + sleep 2 |
| 88 | + done |
| 89 | +
|
| 90 | + - name: Verify Zallet accepts compose command |
| 91 | + run: docker compose --env-file .env.regtest run --rm --no-deps zallet --help |
| 92 | + |
| 93 | + - name: Collect logs on failure |
| 94 | + if: failure() |
| 95 | + run: | |
| 96 | + echo "=== Zebra logs ===" |
| 97 | + docker compose --env-file .env.regtest logs zebra --tail 50 2>&1 || true |
| 98 | + echo "=== Zaino logs ===" |
| 99 | + docker compose --env-file .env.regtest logs zaino --tail 50 2>&1 || true |
| 100 | + echo "=== Container status ===" |
| 101 | + docker compose --env-file .env.regtest ps 2>&1 || true |
0 commit comments