Add Jenkins CI pipeline and Node.js automated tests
startup-product-gitea-ci/pipeline/head This commit looks good

This commit is contained in:
2026-10-22 20:48:38 -04:00
parent 7a23812277
commit 0b5c0a8ab1
4 changed files with 83 additions and 0 deletions
Vendored
+49
View File
@@ -0,0 +1,49 @@
pipeline {
agent any
options {
disableConcurrentBuilds()
timeout(time: 5, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '5'))
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Verify Node.js') {
steps {
sh 'node --version'
sh 'npm --version'
}
}
stage('Syntax Check') {
steps {
dir('app') {
sh 'npm run check'
}
}
}
stage('Automated Tests') {
steps {
dir('app') {
sh 'npm test'
}
}
}
}
post {
success {
echo 'CI PASSED: All checks completed successfully.'
}
failure {
echo 'CI FAILED: Review the Jenkins console output.'
}
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"name": "startup-product",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "node --test",
"check": "node --check src/health.js"
}
}
+8
View File
@@ -0,0 +1,8 @@
function getHealthStatus(databaseConnected) {
return {
status: databaseConnected ? "healthy" : "unhealthy",
database: databaseConnected ? "connected" : "disconnected"
};
}
module.exports = { getHealthStatus };
+17
View File
@@ -0,0 +1,17 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const { getHealthStatus } = require("../src/health");
test("reports healthy when database is connected", () => {
assert.deepEqual(getHealthStatus(true), {
status: "healthy",
database: "connected"
});
});
test("reports unhealthy when database is disconnected", () => {
assert.deepEqual(getHealthStatus(false), {
status: "unhealthy",
database: "disconnected"
});
});