Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
Comment on lines +17 to +20
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Reconsider Node.js version matrix.

A few suggestions about the Node.js versions:

  1. Node.js 22.x is currently in development and not recommended for production use
  2. Node.js 18.x will reach end-of-life in April 2025
  3. Consider adding fail-fast configuration for the matrix strategy
 strategy:
+      fail-fast: false
       matrix:
-        node-version: [18.x, 20.x, 22.x]
+        node-version: [18.x, 20.x]
         # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/


steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
Comment on lines +29 to +31
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider uploading build artifacts and implementing tests.

A few suggestions to improve the workflow:

  1. Upload build artifacts if the build step produces any outputs
  2. The modified test script suggests tests aren't implemented yet, which reduces the effectiveness of this CI workflow
 - run: npm ci
 - run: npm run build --if-present
 - run: npm test
+- name: Upload build artifacts
+  if: success() && steps.build.outcome == 'success'
+  uses: actions/upload-artifact@v4
+  with:
+    name: build-artifacts
+    path: dist/

Would you like help with:

  1. Setting up a testing framework (Jest/Mocha)?
  2. Creating initial test cases?
    Let me know if you'd like me to open a GitHub issue to track this task.

Committable suggestion skipped: line range outside the PR's diff.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "echo \"Warning: no tests specified yet\"",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consider maintaining fail-fast behavior for missing tests

While changing the test script to a warning allows the CI pipeline to pass initially, it masks the absence of tests which could lead to reduced test coverage going forward. Since this is a TypeScript Express.js project, proper testing is crucial for maintaining code quality.

Consider:

  1. Keeping the original fail-fast behavior:
-    "test": "echo \"Warning: no tests specified yet\"",
+    "test": "echo \"Error: no test specified\" && exit 1"
  1. Or better, add a proper testing setup with Jest:
+    "test": "jest",
+    "test:watch": "jest --watch",

Would you like me to help set up a basic testing infrastructure with appropriate dependencies and configuration?

Committable suggestion skipped: line range outside the PR's diff.

"start:dev": "npx nodemon",
"build": "rimraf ./build && tsc",
"start": "npm run build && node ./build/server.js"
Expand Down