@@ -29,6 +29,137 @@ jobs:
2929 - name : Tests
3030 run : cargo test --workspace --all-targets --locked
3131
32+ db-startup :
33+ runs-on : ubuntu-latest
34+
35+ services :
36+ postgres :
37+ image : postgres:15
38+ env :
39+ POSTGRES_USER : postgres
40+ POSTGRES_PASSWORD : postgres
41+ POSTGRES_DB : postgres
42+ ports :
43+ - 5432:5432
44+ options : >-
45+ --health-cmd="pg_isready -U postgres"
46+ --health-interval=5s
47+ --health-timeout=5s
48+ --health-retries=10
49+
50+ steps :
51+ - name : Checkout
52+ uses : actions/checkout@v4
53+
54+ - name : Set up Rust
55+ uses : dtolnay/rust-toolchain@stable
56+ with :
57+ toolchain : " 1.88.0"
58+
59+ - name : Rust cache
60+ uses : Swatinem/rust-cache@v2
61+
62+ - name : Build hulykvs server (release)
63+ run : cargo build --bin hulykvs --release --locked
64+ working-directory : hulykvs_server
65+
66+ - name : Wait for databases to be ready
67+ run : |
68+ set -euo pipefail
69+
70+ echo "Starting CockroachDB container (v24.x, insecure single node)..."
71+ docker run -d --name crdb \
72+ -p 26257:26257 -p 8089:8080 \
73+ cockroachdb/cockroach:latest-v24.3 \
74+ start-single-node --insecure
75+
76+ echo "Waiting for PostgreSQL..."
77+ pg_ok=0
78+ for i in {1..30}; do
79+ if PGPASSWORD=postgres psql -h localhost -U postgres -d postgres -c "SELECT 1" >/dev/null 2>&1; then
80+ echo "PostgreSQL is up."
81+ pg_ok=1
82+ break
83+ fi
84+ sleep 2
85+ done
86+ if [ "$pg_ok" -ne 1 ]; then
87+ echo "PostgreSQL did not become ready in time."
88+ exit 1
89+ fi
90+
91+ echo "Waiting for CockroachDB..."
92+ crdb_ok=0
93+ for i in {1..30}; do
94+ if docker exec crdb cockroach sql --host=localhost:26257 --insecure -e "SELECT 1" >/dev/null 2>&1; then
95+ echo "CockroachDB is up."
96+ crdb_ok=1
97+ break
98+ fi
99+ sleep 2
100+ done
101+ if [ "$crdb_ok" -ne 1 ]; then
102+ echo "CockroachDB did not become ready in time. Container logs:"
103+ docker logs crdb || true
104+ exit 1
105+ fi
106+
107+ - name : Smoke test startup with PostgreSQL
108+ run : |
109+ set -euo pipefail
110+
111+ export HULY_DB_CONNECTION="postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable"
112+ export HULY_TOKEN_SECRET="secret"
113+
114+ ../target/release/hulykvs &
115+ SERVER_PID=$!
116+
117+ ok=0
118+ for i in {1..30}; do
119+ if curl -fsS http://localhost:8094/status >/dev/null 2>&1; then
120+ echo "hulykvs started successfully with PostgreSQL."
121+ ok=1
122+ break
123+ fi
124+ sleep 2
125+ done
126+ if [ "$ok" -ne 1 ]; then
127+ echo "hulykvs did not start successfully with PostgreSQL (no /status response)."
128+ exit 1
129+ fi
130+
131+ kill "$SERVER_PID" || true
132+ wait "$SERVER_PID" || true
133+ working-directory : hulykvs_server
134+
135+ - name : Smoke test startup with CockroachDB
136+ run : |
137+ set -euo pipefail
138+
139+ export HULY_DB_CONNECTION="postgresql://root@127.0.0.1:26257/defaultdb?sslmode=disable"
140+ export HULY_TOKEN_SECRET="secret"
141+
142+ ../target/release/hulykvs &
143+ SERVER_PID=$!
144+
145+ ok=0
146+ for i in {1..30}; do
147+ if curl -fsS http://localhost:8094/status >/dev/null 2>&1; then
148+ echo "hulykvs started successfully with CockroachDB."
149+ ok=1
150+ break
151+ fi
152+ sleep 2
153+ done
154+ if [ "$ok" -ne 1 ]; then
155+ echo "hulykvs did not start successfully with CockroachDB (no /status response)."
156+ exit 1
157+ fi
158+
159+ kill "$SERVER_PID" || true
160+ wait "$SERVER_PID" || true
161+ working-directory : hulykvs_server
162+
32163 docker-build-verify :
33164 runs-on : ubuntu-latest
34165
0 commit comments