Skip to content

Commit 0d84c67

Browse files
authored
Merge pull request #1465 from o1-labs/dw/test-graphql-caoml
CI: add workflow to test GraphQL queries against OCaml node
2 parents 5ba8f5d + 63beab2 commit 0d84c67

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Wait for GraphQL endpoint to become available
3+
# Usage: ./wait-for-graphql.sh [GRAPHQL_ENDPOINT] [TIMEOUT_SECONDS] [CHECK_INTERVAL]
4+
5+
set -e
6+
7+
GRAPHQL_ENDPOINT="${1:-http://localhost:3085/graphql}"
8+
TIMEOUT_SECONDS="${2:-60}"
9+
CHECK_INTERVAL="${3:-2}"
10+
11+
echo "Waiting for GraphQL endpoint to become available..."
12+
echo "Endpoint: $GRAPHQL_ENDPOINT"
13+
echo "Timeout: ${TIMEOUT_SECONDS}s, Check interval: ${CHECK_INTERVAL}s"
14+
15+
MAX_ATTEMPTS=$(( TIMEOUT_SECONDS / CHECK_INTERVAL ))
16+
17+
for i in $(seq 1 $MAX_ATTEMPTS); do
18+
if curl -s --max-time 5 -X POST "$GRAPHQL_ENDPOINT" \
19+
-H "Content-Type: application/json" \
20+
-d '{"query":"{ networkID }"}' > /dev/null 2>&1; then
21+
echo "✓ GraphQL endpoint is ready after $((i * CHECK_INTERVAL)) seconds"
22+
exit 0
23+
fi
24+
echo "Waiting... ($i/$MAX_ATTEMPTS)"
25+
sleep "${CHECK_INTERVAL}"
26+
done
27+
28+
echo "✗ GraphQL endpoint not available after ${TIMEOUT_SECONDS} seconds"
29+
exit 1
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: GraphQL Compatibility Tests
2+
3+
# This workflow tests GraphQL queries against both OCaml and Rust Mina nodes
4+
# to ensure compatibility between implementations.
5+
#
6+
# To run locally using act (installed via gh CLI):
7+
# gh extension install https://github.com/nektos/gh-act
8+
# gh act --workflows .github/workflows/test-graphql-compatibility.yml
9+
#
10+
# Or if act is installed directly:
11+
# act -W .github/workflows/test-graphql-compatibility.yml
12+
#
13+
# To run a specific job:
14+
# gh act --workflows .github/workflows/test-graphql-compatibility.yml --job test-ocaml-node-graphql
15+
#
16+
# Prerequisites for local runs:
17+
# - Docker (for running OCaml node)
18+
# - curl and jq (for GraphQL queries)
19+
# - The website GraphQL scripts must be present
20+
21+
on:
22+
push:
23+
pull_request:
24+
workflow_dispatch:
25+
schedule:
26+
# Run daily at 02:00 UTC
27+
- cron: "0 2 * * *"
28+
29+
env:
30+
CARGO_TERM_COLOR: always
31+
RUST_BACKTRACE: full
32+
# OCaml node configuration
33+
OCAML_NODE_IMAGE: gcr.io/o1labs-192920/mina-daemon:3.3.0-alpha1-6929a7e-noble-devnet
34+
PEER_LIST_URL: https://storage.googleapis.com/o1labs-gitops-infrastructure/devnet/seed-list-devnet.txt
35+
36+
jobs:
37+
test-ocaml-node-graphql:
38+
name: Test GraphQL Queries Against OCaml Node
39+
runs-on: ubuntu-22.04
40+
timeout-minutes: 30
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v5
45+
46+
- name: Start OCaml node
47+
run: |
48+
echo "Starting OCaml node using Docker..."
49+
# Create a config directory
50+
mkdir -p ocaml-node-config
51+
# Use the specified Docker image
52+
echo "Pulling OCaml node Docker image..."
53+
docker pull $OCAML_NODE_IMAGE
54+
# Run the OCaml node in Docker with GraphQL port exposed
55+
docker run -d \
56+
--name ocaml-mina-node \
57+
-p 3085:3085 \
58+
-v $(pwd)/ocaml-node-config:/root/.mina-config \
59+
$OCAML_NODE_IMAGE \
60+
daemon \
61+
--rest-port 3085 \
62+
--insecure-rest-server \
63+
--file-log-level Debug \
64+
--log-level Info \
65+
--config-directory /root/.mina-config \
66+
--peer-list-url $PEER_LIST_URL
67+
# Wait for the node to start and sync (may take several minutes)
68+
./.github/scripts/test-graphql-remote/wait-for-graphql.sh "http://localhost:3085/graphql" 600 10
69+
echo "OCAML_GRAPHQL_ENDPOINT=http://localhost:3085/graphql" >> $GITHUB_ENV
70+
- name: Install jq for JSON processing
71+
run: |
72+
sudo apt-get update && sudo apt-get install -y jq
73+
- name: Test GraphQL command scripts against OCaml node
74+
run: |
75+
echo "Testing all GraphQL command scripts against OCaml node..."
76+
GRAPHQL_ENDPOINT="$OCAML_GRAPHQL_ENDPOINT" ./.github/scripts/test-graphql-command-scripts.sh
77+
78+
- name: Cleanup
79+
if: always()
80+
run: |
81+
echo "Stopping Docker container..."
82+
docker stop ocaml-mina-node || true
83+
docker rm ocaml-mina-node || true

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Added
1616

17+
- **CI**: add workflow to test GraphQL queries with the OCaml node
18+
([#1465](https://github.com/o1-labs/mina-rust/pull/1465))
1719
- **Website**: add o1Labs infrastructure entry, describing the nodes managed by
1820
o1Labs, including seed and plain nodes
1921
([#1430](https://github.com/o1-labs/mina-rust/pull/1430)). The infrastructure

website/docs/developers/scripts/update-ocaml-node.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ sed -i'' -e "s/config_${old_hash}/config_${new_hash}/g" "${config_files[@]}"
6161
# Check if version-hash pattern exists in the files
6262
version_files=(
6363
"${base_dir}/.github/workflows/tests.yaml"
64+
"${base_dir}/.github/workflows/test-graphql-compatibility.yml"
6465
"${base_dir}/docker-compose.archive.devnet.compare.yml"
6566
"${base_dir}/node/testing/src/node/ocaml/config.rs"
6667
)

0 commit comments

Comments
 (0)