From 8f525c1d2906c9dc604fabdd56dd052f61a16504 Mon Sep 17 00:00:00 2001 From: thias15 Date: Sun, 19 Jan 2025 16:42:10 -0800 Subject: [PATCH] Create nodejs-server.yml (#477) * Create nodejs-server.yml --- .github/workflows/nodejs-server.yml | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/nodejs-server.yml diff --git a/.github/workflows/nodejs-server.yml b/.github/workflows/nodejs-server.yml new file mode 100644 index 000000000..2cc13c3ad --- /dev/null +++ b/.github/workflows/nodejs-server.yml @@ -0,0 +1,55 @@ +name: Build and Test Node.js Server + +on: + push: + branches: [ master ] + paths: + - 'controller/node-js/**' + - '.github/workflows/nodejs-server.yml' + pull_request: + branches: [ master ] + paths: + - 'controller/node-js/**' + - '.github/workflows/nodejs-server.yml' + +defaults: + run: + working-directory: ./controller/node-js + +jobs: + nodejs-server: + name: Build and Test Node.js Server + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install dependencies + run: npm install + + - name: Start server in background + run: nohup npm start & + + - name: Wait for server to start + run: sleep 10 + + - name: Test HTTP server + run: curl -I http://localhost:8081 + + - name: Test WebSocket server + run: | + npm install -g wscat + wscat -c ws://localhost:7071 -x '{"test": "message"}' + + - name: Simulate browser commands + run: | + curl -X POST http://localhost:8081/keypress -d '{"key": "ArrowUp"}' \ + -H "Content-Type: application/json" + + - name: Stop background server + if: always() + run: pkill -f "npm start"