Skip to content

Commit

Permalink
chore: change the workflows
Browse files Browse the repository at this point in the history
Signed-off-by: ramprasathmk <[email protected]>
  • Loading branch information
ramprasathmk committed Nov 27, 2024
1 parent 0146cdf commit 8ee0b2d
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,32 @@ 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
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:
Expand All @@ -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:
Expand Down

0 comments on commit 8ee0b2d

Please sign in to comment.