Skip to content
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Paisable CI
on: [push,pull_request]
jobs:
CI:
runs-on: ubuntu-latest
# services:
# mongo:
# image: mongo:6
# ports:
# - 27017:27017
# options: >-
# --health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'"
# --health-interval=10s
# --health-timeout=5s
# --health-retries=5
env:
PORT: 5000
MONGO_URI: mongodb://mongo:27017/testdb
JWT_SECRET: ${{ secrets.JWT_SECRET }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
VITE_API_URL: http://localhost:5000/api
steps:
- name: Checkout
uses: actions/[email protected]
with:
path: .
- name: Setup Node
uses: actions/[email protected]
- name: Install Backend & Run
run: |
cd backend
npm install
npm run test
npm run dev > server.log 2>&1 &
server_pid=$!
echo "Server started with PID: $server_pid"

for i in {1..15}; do
if curl -fs http://localhost:5000 > /dev/null; then
echo "Server is up!"
kill $server_pid
echo "No issues found!"
exit 0
fi
echo "Waiting for server... (attempt $i/15)"
sleep 2
done

echo "Server failed to start. Printing logs:"
cat server.log
kill $server_pid
Copy link
Member

Choose a reason for hiding this comment

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

Have you test in case of DB not connected?
I think you need to update the db not to be take exit in case of CI workflow. Right?

Copy link
Author

Choose a reason for hiding this comment

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

There are some problems related to db test cases right now. I'm trying to figure it out. Once fixed i will mention you.

exit 1
- name: Install Frontend & Run
run: |
cd frontend
npm install
# npm run test
npm run build





4 changes: 2 additions & 2 deletions backend/__tests__/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { app, server } = require('../server');
const User = require('../models/User');

let mongoServer;

jest.setTimeout(30000);
beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
Expand Down Expand Up @@ -101,4 +101,4 @@ describe('Auth API', () => {
expect(setupResponse.body.message).toBe('Default currency is required');
});

});
});
Loading