diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..14bc0fe --- /dev/null +++ b/.github/workflows/ci.yml @@ -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/checkout@v5.0.0 + with: + path: . + - name: Setup Node + uses: actions/setup-node@v5.0.0 + - 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 + exit 1 + - name: Install Frontend & Run + run: | + cd frontend + npm install + # npm run test + npm run build + + + + + diff --git a/backend/__tests__/auth.test.js b/backend/__tests__/auth.test.js index a122d16..b784b02 100644 --- a/backend/__tests__/auth.test.js +++ b/backend/__tests__/auth.test.js @@ -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(); @@ -101,4 +101,4 @@ describe('Auth API', () => { expect(setupResponse.body.message).toBe('Default currency is required'); }); -}); \ No newline at end of file +});