diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml index 0b253f6..e2c7a39 100644 --- a/.github/workflows/publish-to-npm.yml +++ b/.github/workflows/publish-to-npm.yml @@ -17,7 +17,7 @@ jobs: ports: - 27017:27017 options: >- - --health-cmd="mongosh --eval 'db.runCommand({ ping: 1 })'" + --health-cmd="mongo --eval 'db.runCommand({ ping: 1 })'" --health-interval=10s --health-timeout=5s --health-retries=5 @@ -25,16 +25,24 @@ jobs: steps: # Step 1: Checkout the code - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 # Step 2: Setup Node.js environment - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v3 with: node-version: '16' registry-url: 'https://registry.npmjs.org/' - # Step 3: Cache Node.js dependencies + # Step 3: Install MongoDB CLI Tools + - name: Install MongoDB tools + run: | + wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - + echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list + sudo apt-get update + sudo apt-get install -y mongodb-org-shell + + # Step 4: Cache Node.js dependencies - name: Cache Node.js modules uses: actions/cache@v3 with: @@ -43,24 +51,10 @@ jobs: restore-keys: | ${{ runner.os }}-node- - # Step 4: Install project dependencies + # Step 5: Install project dependencies - name: Install dependencies run: npm install - # Step 5: Ensure MongoDB service is ready - - name: Wait for MongoDB - run: | - for i in {1..10}; do - if mongosh --eval "db.runCommand({ ping: 1 })"; then - echo "MongoDB is ready"; - exit 0; - fi; - echo "Waiting for MongoDB... (attempt $i/10)"; - sleep 5; - done; - echo "MongoDB failed to start"; - exit 1 - # Step 6: Run tests - name: Run tests env: