ci: add backend workflow for lint, tests, and audit checks#43
ci: add backend workflow for lint, tests, and audit checks#43srija-pixel wants to merge 2 commits intofuzziecoder:mainfrom
Conversation
|
@srija-pixel is attempting to deploy a commit to the Revon Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds a new GitHub Actions workflow (.github/workflows/backend.yml) that runs on pull requests affecting the backend directory: checks out code, sets up Node.js 20, installs dependencies, starts the backend briefly as a smoke test, and runs Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/backend.yml (1)
24-28: Smoke test doesn't verify server health.The current approach sleeps for 5 seconds without checking if the server actually started. If the server crashes immediately, the step still passes. Consider adding a health check request.
♻️ Proposed improvement with health check
- name: Start backend briefly run: | node backend/server.js & + SERVER_PID=$! sleep 5 - kill $! || true + curl --fail --silent --max-time 5 http://localhost:3000/health || (echo "Server health check failed" && exit 1) + kill $SERVER_PID || trueIf no health endpoint exists, at minimum check the process is still running:
- name: Start backend briefly run: | node backend/server.js & SERVER_PID=$! sleep 5 if ! kill -0 $SERVER_PID 2>/dev/null; then echo "Server process crashed" exit 1 fi kill $SERVER_PID || true🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/backend.yml around lines 24 - 28, The smoke test step "Start backend briefly" currently just sleeps and may miss a crashed process; update that step to start backend/server.js in background, capture its PID (e.g., SERVER_PID), then verify the server is healthy before killing it—preferably by issuing an HTTP health-check request to the server's health endpoint and failing the step if the check does not return success, otherwise fall back to checking the process is still alive with kill -0 $SERVER_PID and exit non‑zero if it crashed, then cleanly kill the process.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/backend.yml:
- Around line 30-31: The "Run security audit" step currently uses "npm audit ||
true" in the repo root which both silences failures and runs in the wrong
directory; update the step so it runs in the backend directory (set
working-directory to backend) and remove the "|| true" so the job fails on
vulnerabilities, and add an audit level flag such as "--audit-level=high" (or
"--audit-level=critical" if preferred) to the npm audit command to only fail on
high/critical issues.
- Around line 21-22: The "Install dependencies" CI step currently runs `npm
install` in the repo root (step name "Install dependencies", run: `npm
install`), so backend deps aren't installed; update that step to run in the
backend package directory—either set the step's working-directory to "backend"
or run installation with a prefix (e.g., `npm ci --prefix backend`) so the
backend/package.json is used and dependencies are installed correctly.
---
Nitpick comments:
In @.github/workflows/backend.yml:
- Around line 24-28: The smoke test step "Start backend briefly" currently just
sleeps and may miss a crashed process; update that step to start
backend/server.js in background, capture its PID (e.g., SERVER_PID), then verify
the server is healthy before killing it—preferably by issuing an HTTP
health-check request to the server's health endpoint and failing the step if the
check does not return success, otherwise fall back to checking the process is
still alive with kill -0 $SERVER_PID and exit non‑zero if it crashed, then
cleanly kill the process.
| - name: Run security audit | ||
| run: npm audit || true No newline at end of file |
There was a problem hiding this comment.
Security audit is ineffective and runs in wrong directory.
Two issues:
|| truemeans this step always passes, even with critical vulnerabilities—defeating the purpose of CI security checks.- Like
npm install, this runs in the repo root instead ofbackend/.
🐛 Proposed fix
- name: Run security audit
- run: npm audit || true
+ run: npm audit --audit-level=high
+ working-directory: backendUsing --audit-level=high will fail only on high/critical vulnerabilities while allowing moderate/low ones to pass. Adjust to --audit-level=critical if you want even less strict enforcement.
📝 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.
| - name: Run security audit | |
| run: npm audit || true | |
| - name: Run security audit | |
| run: npm audit --audit-level=high | |
| working-directory: backend |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/backend.yml around lines 30 - 31, The "Run security audit"
step currently uses "npm audit || true" in the repo root which both silences
failures and runs in the wrong directory; update the step so it runs in the
backend directory (set working-directory to backend) and remove the "|| true" so
the job fails on vulnerabilities, and add an audit level flag such as
"--audit-level=high" (or "--audit-level=critical" if preferred) to the npm audit
command to only fail on high/critical issues.
Added GitHub Actions backend workflow to run on pull requests touching backend.
Includes:
Ensures backend CI checks run automatically.
Summary by CodeRabbit