Skip to content

Commit f9cd7c1

Browse files
authored
Update node.js.yml
1 parent 7a6cd4a commit f9cd7c1

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
11
name: CI
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches: [dev, master]
5+
pull_request:
6+
branches: [dev, master]
37

48
jobs:
59
test:
610
runs-on: ubuntu-latest
711
services:
812
mongo:
913
image: mongo:6.0
10-
ports: ['27017:27017']
14+
ports:
15+
- 27017:27017
1116
options: >-
1217
--health-cmd="mongosh --quiet --eval 'db.runCommand({ ping: 1 })' || exit 1"
13-
--health-interval=5s --health-timeout=3s --health-retries=20
18+
--health-interval=5s --health-timeout=3s --health-retries=30
19+
1420
steps:
1521
- uses: actions/checkout@v4
1622
- uses: actions/setup-node@v4
1723
with:
1824
node-version: 20
19-
- run: npm ci
25+
26+
- name: Install dependencies
27+
run: npm ci
2028
working-directory: server
21-
- run: npm test
29+
30+
- name: Wait for Mongo
31+
run: |
32+
for i in {1..60}; do
33+
if mongosh --quiet --eval "db.runCommand({ ping: 1 })" 127.0.0.1:27017; then
34+
echo "Mongo is up!"
35+
exit 0
36+
fi
37+
echo "Waiting for Mongo..."
38+
sleep 2
39+
done
40+
echo "Mongo did not start in time" && exit 1
41+
42+
- name: Run tests
43+
run: npm test -- --ci --runInBand --detectOpenHandles
2244
working-directory: server
2345
env:
2446
NODE_ENV: development

0 commit comments

Comments
 (0)