Skip to content

Commit 4d49cb3

Browse files
committed
ci: Add workflow for embed binary test
this patch adds a CI for testing the embedded binary. It checks if the embedded binary serves valid response code and the response is a valid html response. Signed-off-by: yolossn <sannagaraj@microsoft.com>
1 parent ae84dbe commit 4d49cb3

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Backend Embed Test
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'backend/**'
7+
- 'Makefile'
8+
- '.github/workflows/backend-embed-test.yml'
9+
push:
10+
branches:
11+
- main
12+
- rc-*
13+
- testing-rc-*
14+
paths:
15+
- 'backend/**'
16+
- 'Makefile'
17+
- '.github/workflows/backend-embed-test.yml'
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
test-embedded-binary:
24+
runs-on: ubuntu-22.04
25+
strategy:
26+
matrix:
27+
node-version: [20.x]
28+
steps:
29+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
30+
31+
- name: Use Node.js ${{ matrix.node-version }}
32+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
33+
with:
34+
node-version: ${{ matrix.node-version }}
35+
36+
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
37+
with:
38+
go-version: '1.24.*'
39+
40+
- name: Install frontend dependencies
41+
run: |
42+
cd frontend && npm ci
43+
44+
- name: Build embeded backend binary
45+
run: |
46+
make backend-embed
47+
48+
- name: Test embedded binary
49+
run: |
50+
cd backend
51+
# Start the server in background
52+
./headlamp-server --base-url /headlamp --port 4466 --listen-addr 127.0.0.1 &
53+
SERVER_PID=$!
54+
55+
# Wait for server to start
56+
sleep 10
57+
58+
# Test if server is responding with 200 and the response has headlampBaseUrl set to /headlamp
59+
response_code=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:4466/headlamp/index.html || echo "000")
60+
if [ "$response_code" = "200" ]; then
61+
echo "✅ Server is responding correctly with HTTP 200"
62+
echo "Response: $response_code"
63+
else
64+
echo "❌ Server not responding correctly. HTTP status: $response_code"
65+
exit 1
66+
fi
67+
68+
# Test if the response is a valid HTML file
69+
response_body=$(curl -s http://127.0.0.1:4466/headlamp/)
70+
if echo "$response_body" | grep -q "DOCTYPE html" || echo "$response_body" | grep -q "<html"; then
71+
echo "✅ Response is a valid HTML file"
72+
else
73+
echo "❌ Response is not a valid HTML file"
74+
exit 1
75+
fi
76+
77+
# Clean up
78+
kill $SERVER_PID || true
79+
wait $SERVER_PID 2>/dev/null || true
80+
81+
echo "✅ Embedded binary test completed successfully"

0 commit comments

Comments
 (0)