Merge pull request 'Add Jenkins CI pipeline and WebSocket test' (#8) from issue-5-jenkins-ci into main
seat-back-trivia/pipeline/head This commit looks good
seat-back-trivia/pipeline/head This commit looks good
Reviewed-on: #8 Reviewed-by: cedric <cpollefe@stevens.edu>
This commit was merged in pull request #8.
This commit is contained in:
Vendored
+30
@@ -0,0 +1,30 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Verify Node.js') {
|
||||||
|
steps {
|
||||||
|
sh 'node --version'
|
||||||
|
sh 'npm --version'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Install Dependencies') {
|
||||||
|
steps {
|
||||||
|
sh 'npm ci'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Test') {
|
||||||
|
steps {
|
||||||
|
sh 'npm test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+36
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "seat-back-trivia",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "seat-back-trivia",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"ws": "8.18.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ws": {
|
||||||
|
"version": "8.18.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
|
||||||
|
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"bufferutil": "^4.0.1",
|
||||||
|
"utf-8-validate": ">=5.0.2"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"bufferutil": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"utf-8-validate": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "seat-back-trivia",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"description": "Minimal WebSocket quiz server for SeatBack Trivia",
|
||||||
|
"scripts": {
|
||||||
|
"test": "node --test"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ws": "8.18.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
const WebSocket = require('ws');
|
||||||
|
|
||||||
|
const PORT = process.env.PORT || 8080;
|
||||||
|
const wss = new WebSocket.Server({ port: PORT });
|
||||||
|
|
||||||
|
const question = {
|
||||||
|
question: 'What is the capital of France?',
|
||||||
|
answer: 'Paris'
|
||||||
|
};
|
||||||
|
|
||||||
|
wss.on('connection', (ws) => {
|
||||||
|
ws.send(JSON.stringify(question));
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`SeatBack Trivia WebSocket server listening on port ${PORT}`);
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
|
||||||
|
test('sample trivia question has the expected answer', () => {
|
||||||
|
const question = {
|
||||||
|
question: 'What is the capital of France?',
|
||||||
|
answer: 'Paris'
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.equal(question.answer, 'Paris');
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user