From 1a6c7bc46957e36645a63fc3f73b93cd2aeea3f7 Mon Sep 17 00:00:00 2001 From: thias15 Date: Sun, 19 Jan 2025 16:28:26 -0800 Subject: [PATCH 1/3] Create nodejs-server.yml --- .github/workflows/nodejs-server.yml | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 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..a363bde42 --- /dev/null +++ b/.github/workflows/nodejs-server.yml @@ -0,0 +1,54 @@ +name: Build and Test Node.js Server + +# Run this workflow for every new commit and PR that changes the 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: + # Set the job key for testing the Node.js server + nodejs-server: + # Name the Job + name: Build and Test Node.js Server + # Set the type of machine to run on + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: '16' # Specify your desired Node.js version + + - run: node --version + + - name: Install dependencies + run: npm install + + - name: Start server in background + run: nohup npm start & + + - name: Wait for server to start + run: sleep 5 # Adjust this if your server takes longer to start + + - name: Test server + run: | + curl -I http://localhost:3000 # Adjust port if necessary + curl http://localhost:3000 # Perform basic server response test + + - name: Stop background server + if: always() + run: | + pkill -f "npm start" || echo "Server not running" From 597312ec35a24e2a905feb4c07d1d7799640c842 Mon Sep 17 00:00:00 2001 From: thias15 Date: Sun, 19 Jan 2025 16:34:56 -0800 Subject: [PATCH 2/3] Update nodejs-server.yml --- .github/workflows/nodejs-server.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nodejs-server.yml b/.github/workflows/nodejs-server.yml index a363bde42..73026afce 100644 --- a/.github/workflows/nodejs-server.yml +++ b/.github/workflows/nodejs-server.yml @@ -41,12 +41,12 @@ jobs: run: nohup npm start & - name: Wait for server to start - run: sleep 5 # Adjust this if your server takes longer to start + run: sleep 10 - name: Test server run: | - curl -I http://localhost:3000 # Adjust port if necessary - curl http://localhost:3000 # Perform basic server response test + curl -I http://localhost:7071 + curl http://localhost:7071 - name: Stop background server if: always() From 5c4dd90d2061568c4b0dca413808e55786263db4 Mon Sep 17 00:00:00 2001 From: thias15 Date: Sun, 19 Jan 2025 16:40:04 -0800 Subject: [PATCH 3/3] Update nodejs-server.yml --- .github/workflows/nodejs-server.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/nodejs-server.yml b/.github/workflows/nodejs-server.yml index 73026afce..2cc13c3ad 100644 --- a/.github/workflows/nodejs-server.yml +++ b/.github/workflows/nodejs-server.yml @@ -1,6 +1,5 @@ name: Build and Test Node.js Server -# Run this workflow for every new commit and PR that changes the Node.js server on: push: branches: [ master ] @@ -18,11 +17,8 @@ defaults: working-directory: ./controller/node-js jobs: - # Set the job key for testing the Node.js server nodejs-server: - # Name the Job name: Build and Test Node.js Server - # Set the type of machine to run on runs-on: ubuntu-latest steps: @@ -30,9 +26,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: '16' # Specify your desired Node.js version - - - run: node --version + node-version: '16' - name: Install dependencies run: npm install @@ -43,12 +37,19 @@ jobs: - name: Wait for server to start run: sleep 10 - - name: Test server + - name: Test HTTP server + run: curl -I http://localhost:8081 + + - name: Test WebSocket server run: | - curl -I http://localhost:7071 - curl http://localhost:7071 + 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" || echo "Server not running" + run: pkill -f "npm start"