Skip to content

Commit

Permalink
Update ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
urbantech authored Nov 16, 2024
1 parent 0fcd423 commit 99234e8
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

services:
mongodb:
image: mongo:latest
image: mongo:6.0 # Pin MongoDB version for consistency
ports:
- 27017:27017

Expand All @@ -29,28 +29,35 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '16' # Update Node.js version to a stable, supported version

- name: Install dependencies
run: npm install [email protected]

- name: Install dependencies
run: npm install
run: npm ci # Ensures clean installation from package-lock.json

- name: Install dev dependencies
run: npm install --save-dev jest chai supertest mongoose sinon dotenv chai-http
run: npm install --save-dev jest chai supertest sinon dotenv chai-http

- name: Check installed packages
run: npm list mongoose # Debugging step to confirm mongoose version

- name: Set up MongoDB logs
run: mkdir -p logs && touch logs/mongo.log # Prepare logs directory for MongoDB

- name: Wait for MongoDB to start
run: |
sleep 10
echo "Waiting for MongoDB to start..." # Ensures MongoDB is ready before testing
- name: Run tests
env:
MONGO_URI: ${{ env.MONGODB_URI }} # Explicitly pass env variables to the test step
run: npm test

- name: Print MongoDB logs
run: docker logs $(docker ps -q --filter "ancestor=mongo:6.0") || echo "No MongoDB logs available"

- name: Start application
env:
MONGO_URI: ${{ env.MONGODB_URI }} # Ensure the app uses the correct DB URI
PORT: ${{ env.PORT }}
run: npm start

- name: Check Docker service
run: sudo systemctl status docker

- name: Pull MongoDB image
run: docker pull mongo:latest

- name: Print Docker logs
run: docker logs $(docker ps -q --filter "ancestor=mongo:latest")

0 comments on commit 99234e8

Please sign in to comment.