Skip to content

Commit 8f525c1

Browse files
authored
Create nodejs-server.yml (#477)
* Create nodejs-server.yml
1 parent e662ca3 commit 8f525c1

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/nodejs-server.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and Test Node.js Server
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- 'controller/node-js/**'
8+
- '.github/workflows/nodejs-server.yml'
9+
pull_request:
10+
branches: [ master ]
11+
paths:
12+
- 'controller/node-js/**'
13+
- '.github/workflows/nodejs-server.yml'
14+
15+
defaults:
16+
run:
17+
working-directory: ./controller/node-js
18+
19+
jobs:
20+
nodejs-server:
21+
name: Build and Test Node.js Server
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
- uses: actions/setup-node@v3
28+
with:
29+
node-version: '16'
30+
31+
- name: Install dependencies
32+
run: npm install
33+
34+
- name: Start server in background
35+
run: nohup npm start &
36+
37+
- name: Wait for server to start
38+
run: sleep 10
39+
40+
- name: Test HTTP server
41+
run: curl -I http://localhost:8081
42+
43+
- name: Test WebSocket server
44+
run: |
45+
npm install -g wscat
46+
wscat -c ws://localhost:7071 -x '{"test": "message"}'
47+
48+
- name: Simulate browser commands
49+
run: |
50+
curl -X POST http://localhost:8081/keypress -d '{"key": "ArrowUp"}' \
51+
-H "Content-Type: application/json"
52+
53+
- name: Stop background server
54+
if: always()
55+
run: pkill -f "npm start"

0 commit comments

Comments
 (0)