From f1a8d4939ff7633bfa3613be180dee518f4dd878 Mon Sep 17 00:00:00 2001 From: Lorenc Dedaj Date: Wed, 5 Nov 2025 21:17:50 -0500 Subject: [PATCH] fix port misconfiguration in yaml file --- .github/workflows/ci.yml | 2 ++ test/smoke.test.js | 46 +++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26bad8a..c6d3416 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,13 @@ jobs: runs-on: ubuntu-latest env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY}} + PORT: 4000 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci + - run: npm run start & sleep 3 - run: npm test - run: echo "Deploying to ${{ inputs.environment || 'dev' }}..." diff --git a/test/smoke.test.js b/test/smoke.test.js index 862cb57..4837f20 100644 --- a/test/smoke.test.js +++ b/test/smoke.test.js @@ -1,28 +1,26 @@ -// import assert from 'node:assert/strict'; -// assert.equal(1 + 1, 2, 'Math still works'); -// import '../server/server.js'; -// console.log('✅ smoke test passed'); -// import 'dotenv/config'; -// import { healthCheck } from '../server/db.js'; +import fetch from 'node-fetch'; -// async function main() { -// try { -// console.log('Running a smoke test'); +const port = process.env.PORT || 4000; +const url = `http://localhost:${port}/health`; -// const ok = await healthCheck(); -// if (!ok) { -// console.error("❌ Health check didn't pass"); -// process.exit(1); -// } +async function main() { + try { + console.log(`🔎 Checking API health @ ${url} ...`); + const res = await fetch(url); + const json = await res.json(); -// console.log('✅ Health check passed!'); -// process.exit(0); -// } catch (error) { -// console.error('Smoke test failed'); -// process.exit(1); -// } -// } + // const ok = await healthCheck(); + if (!res.ok || !json.ok) { + console.error('❌ Health check didn"t pass', json); + process.exit(1); + } -// main(); -console.log('✅ CI smoke test stub: nothing to check yet.'); -process.exit(0); + console.log('✅ Health check passed!', json); + process.exit(0); + } catch (error) { + console.error('❌ Smoke test failed'); + process.exit(1); + } +} + +main();