Skip to content

Commit 09e525e

Browse files
committed
ci: docker test-ci parity harness
1 parent 0d7e105 commit 09e525e

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Local CI parity. Runs the suite in containers matching the CI matrix legs
2+
# (same Julia + pinned SurrealDB image), so a green local run means a green CI
3+
# run. Requires docker (OrbStack/Desktop). Pins mirror .github/workflows/test.yml.
4+
5+
JULIA ?= 1.10
6+
SURREAL ?= v3.1.2
7+
WIRE ?= cbor
8+
9+
.PHONY: test-ci test-ci-unit test-ci-all conformance
10+
11+
# Single server-gated leg. Override: make test-ci JULIA=1 SURREAL=v2.6.5 WIRE=json
12+
test-ci:
13+
JULIA=$(JULIA) SURREAL=$(SURREAL) WIRE=$(WIRE) bash scripts/test-ci.sh remote
14+
15+
# Unit-only leg (no server); the version axis is what catches dep-resolve skew.
16+
test-ci-unit:
17+
JULIA=$(JULIA) bash scripts/test-ci.sh unit
18+
19+
# Full server matrix, mirroring test.yml test-remote: {v2.6.5,v3.1.2} x {cbor,json}.
20+
test-ci-all:
21+
JULIA=$(JULIA) SURREAL=v2.6.5 WIRE=cbor bash scripts/test-ci.sh remote
22+
JULIA=$(JULIA) SURREAL=v2.6.5 WIRE=json bash scripts/test-ci.sh remote
23+
JULIA=$(JULIA) SURREAL=v3.1.2 WIRE=cbor bash scripts/test-ci.sh remote
24+
JULIA=$(JULIA) SURREAL=v3.1.2 WIRE=json bash scripts/test-ci.sh remote
25+
26+
# Cross-SDK conformance against the pinned server (uses scripts/setup-server.sh).
27+
conformance:
28+
bash scripts/run-conformance.sh

scripts/test-ci.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
# test-ci.sh — run the suite inside containers, mirroring a CI matrix leg 1:1:
3+
# same Julia image, same pinned SurrealDB image, same command, same topology.
4+
# The Julia container shares the surreal container's network namespace
5+
# (--network container:), so it reaches surreal at localhost:8000 exactly as CI
6+
# does (Julia on the runner host, surreal in docker with a published port).
7+
#
8+
# MODE remote (default) — start surreal, run server-gated suite
9+
# unit — no server, unit-only run (server tests self-skip)
10+
# JULIA official julia image tag (default 1.10)
11+
# SURREAL surrealdb/surrealdb image tag (default v3.1.2)
12+
# WIRE cbor | json (default cbor)
13+
#
14+
# Pins MUST match .github/workflows/test.yml — that workflow is canonical.
15+
set -euo pipefail
16+
17+
MODE="${1:-remote}"
18+
JULIA="${JULIA:-1.10}"
19+
SURREAL="${SURREAL:-v3.1.2}"
20+
WIRE="${WIRE:-cbor}"
21+
HOST_PORT="${HOST_PORT:-8000}"
22+
23+
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
24+
SURREAL_NAME="surreal-ci-$$"
25+
DEPOT_VOL="surrealdb-jl-depot-${JULIA}" # persistent depot per julia version → fast reruns
26+
27+
cleanup() { docker rm -f "$SURREAL_NAME" >/dev/null 2>&1 || true; }
28+
trap cleanup EXIT
29+
30+
NET_ARGS=()
31+
URL=""
32+
if [ "$MODE" = "remote" ]; then
33+
echo "[test-ci] surrealdb/surrealdb:$SURREAL on :$HOST_PORT (wire=$WIRE)"
34+
docker run -d --rm --name "$SURREAL_NAME" -p "$HOST_PORT:8000" \
35+
"surrealdb/surrealdb:$SURREAL" \
36+
start --user root --pass root --bind 0.0.0.0:8000 memory >/dev/null
37+
echo "[test-ci] waiting for surreal..."
38+
for _ in $(seq 1 30); do
39+
curl -s -X POST "http://localhost:$HOST_PORT/rpc" \
40+
-H 'Content-Type: application/json' \
41+
-d '{"id":1,"method":"version","params":[]}' >/dev/null 2>&1 && break
42+
sleep 1
43+
done
44+
# Share surreal's network namespace → Julia reaches it at localhost:8000.
45+
NET_ARGS=(--network "container:$SURREAL_NAME")
46+
URL="ws://localhost:8000"
47+
fi
48+
49+
echo "[test-ci] julia:$JULIA mode=$MODE"
50+
docker run --rm "${NET_ARGS[@]}" \
51+
-v "$REPO:/work" -w /work \
52+
-v "$DEPOT_VOL:/depot" -e JULIA_DEPOT_PATH=/depot \
53+
-e SURREALDB_URL="$URL" -e SURREALDB_WIRE="$WIRE" \
54+
"julia:$JULIA" \
55+
julia --project=test -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); include("test/runtests.jl")'

0 commit comments

Comments
 (0)