Skip to content

Commit 0bdec8c

Browse files
authored
Test SDK against different templates (runtimes/bundler/...) (#602)
1 parent 647c59d commit 0bdec8c

39 files changed

+12615
-4884
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Test Bun Template
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
10+
services:
11+
restate:
12+
image: docker.restate.dev/restatedev/restate:latest
13+
ports:
14+
- 8080:8080
15+
- 9070:9070
16+
options: >-
17+
--health-cmd "curl -f http://localhost:9070/health || exit 1"
18+
--health-interval 10s
19+
--health-timeout 5s
20+
--health-retries 5
21+
--add-host=host.docker.internal:host-gateway
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "22"
30+
31+
- name: Setup Bun
32+
uses: oven-sh/setup-bun@v2
33+
with:
34+
bun-version: latest
35+
36+
- name: Install dependencies
37+
run: npm install
38+
39+
- name: Build packages
40+
run: npm run build
41+
42+
- name: Start Bun service
43+
working-directory: templates/bun
44+
run: |
45+
bun start &
46+
echo $! > service.pid
47+
sleep 5
48+
49+
- name: Register with Restate
50+
run: |
51+
curl -X POST http://localhost:9070/deployments \
52+
-H 'content-type: application/json' \
53+
-d '{"uri": "http://host.docker.internal:9080", "use_http_11": true}'
54+
55+
- name: Test Bun template
56+
run: |
57+
echo "Testing Greeter service..."
58+
RESPONSE=$(curl -s localhost:8080/Greeter/greet --json '{"name": "Bun"}')
59+
echo "Response: $RESPONSE"
60+
61+
# Check if response contains expected message
62+
if echo "$RESPONSE" | grep -q "You said hi to Bun!"; then
63+
echo "✅ Test passed!"
64+
else
65+
echo "❌ Test failed! Expected: { result: You said hi to Bun! }"
66+
exit 1
67+
fi
68+
69+
- name: Show logs on failure
70+
if: failure()
71+
run: |
72+
echo "=== Restate logs ==="
73+
docker logs $(docker ps -q --filter ancestor=docker.restate.dev/restatedev/restate:latest)
74+
75+
echo "=== Service logs ==="
76+
if [ -f templates/bun/service.pid ]; then
77+
ps aux | grep bun || true
78+
fi
79+
80+
- name: Cleanup
81+
if: always()
82+
working-directory: templates/bun
83+
run: |
84+
if [ -f service.pid ]; then
85+
kill $(cat service.pid) || true
86+
fi
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Test Cloudflare Worker Template
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
10+
services:
11+
restate:
12+
image: docker.restate.dev/restatedev/restate:latest
13+
ports:
14+
- 8080:8080
15+
- 9070:9070
16+
options: >-
17+
--health-cmd "curl -f http://localhost:9070/health || exit 1"
18+
--health-interval 10s
19+
--health-timeout 5s
20+
--health-retries 5
21+
--add-host=host.docker.internal:host-gateway
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "22"
30+
31+
- name: Install dependencies
32+
run: npm install
33+
34+
- name: Build packages
35+
run: npm run build
36+
37+
- name: Start Cloudflare Worker (wrangler dev)
38+
working-directory: templates/cloudflare
39+
run: |
40+
npm run start &
41+
echo $! > service.pid
42+
sleep 10
43+
44+
- name: Register with Restate
45+
run: |
46+
curl -X POST http://localhost:9070/deployments \
47+
-H 'content-type: application/json' \
48+
-d '{"uri": "http://host.docker.internal:9080", "use_http_11": true}'
49+
50+
- name: Test Cloudflare Worker template
51+
run: |
52+
echo "Testing Greeter service..."
53+
RESPONSE=$(curl -s localhost:8080/Greeter/greet --json '{"name": "Cloudflare"}')
54+
echo "Response: $RESPONSE"
55+
56+
# Check if response contains expected message
57+
if echo "$RESPONSE" | grep -q "You said hi to Cloudflare!"; then
58+
echo "✅ Test passed!"
59+
else
60+
echo "❌ Test failed! Expected: { result: You said hi to Cloudflare! }"
61+
exit 1
62+
fi
63+
64+
- name: Show logs on failure
65+
if: failure()
66+
run: |
67+
echo "=== Restate logs ==="
68+
docker logs $(docker ps -q --filter ancestor=docker.restate.dev/restatedev/restate:latest)
69+
70+
echo "=== Wrangler logs ==="
71+
if [ -f templates/cloudflare/service.pid ]; then
72+
ps aux | grep wrangler || true
73+
fi
74+
75+
- name: Cleanup
76+
if: always()
77+
working-directory: templates/cloudflare
78+
run: |
79+
if [ -f service.pid ]; then
80+
kill $(cat service.pid) || true
81+
fi
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Test Deno Template
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
10+
services:
11+
restate:
12+
image: docker.restate.dev/restatedev/restate:latest
13+
ports:
14+
- 8080:8080
15+
- 9070:9070
16+
options: >-
17+
--health-cmd "curl -f http://localhost:9070/health || exit 1"
18+
--health-interval 10s
19+
--health-timeout 5s
20+
--health-retries 5
21+
--add-host=host.docker.internal:host-gateway
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "22"
30+
31+
- name: Setup Deno
32+
uses: denoland/setup-deno@v1
33+
with:
34+
deno-version: v2.x
35+
36+
- name: Install dependencies
37+
run: npm install
38+
39+
- name: Build packages
40+
run: npm run build
41+
42+
- name: Start Deno service
43+
working-directory: templates/deno
44+
run: |
45+
deno task start &
46+
echo $! > service.pid
47+
sleep 5
48+
49+
- name: Register with Restate
50+
run: |
51+
curl -X POST http://localhost:9070/deployments \
52+
-H 'content-type: application/json' \
53+
-d '{"uri": "http://host.docker.internal:9080"}'
54+
55+
- name: Test Deno template
56+
run: |
57+
echo "Testing Greeter service..."
58+
RESPONSE=$(curl -s localhost:8080/Greeter/greet --json '{"name": "Deno"}')
59+
echo "Response: $RESPONSE"
60+
61+
# Check if response contains expected message
62+
if echo "$RESPONSE" | grep -q "You said hi to Deno!"; then
63+
echo "✅ Test passed!"
64+
else
65+
echo "❌ Test failed! Expected: { result: You said hi to Deno! }"
66+
exit 1
67+
fi
68+
69+
- name: Show logs on failure
70+
if: failure()
71+
run: |
72+
echo "=== Restate logs ==="
73+
docker logs $(docker ps -q --filter ancestor=docker.restate.dev/restatedev/restate:latest)
74+
75+
echo "=== Service logs ==="
76+
if [ -f templates/deno/service.pid ]; then
77+
ps aux | grep deno || true
78+
fi
79+
80+
- name: Cleanup
81+
if: always()
82+
working-directory: templates/deno
83+
run: |
84+
if [ -f service.pid ]; then
85+
kill $(cat service.pid) || true
86+
fi

0 commit comments

Comments
 (0)