File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change
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"
You can’t perform that action at this time.
0 commit comments