Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ on:
jobs:
test:
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
container: node:lts
timeout-minutes: 30

services:
mongo:
image: mongo:7
ports:
- 27017:27017
Comment thread
PierreBrisorgueil marked this conversation as resolved.
Comment thread
PierreBrisorgueil marked this conversation as resolved.
Comment thread
PierreBrisorgueil marked this conversation as resolved.
options: >-
--health-cmd="mongosh --quiet --eval 'db.runCommand({ ping: 1 })'"
--health-interval=10s
Expand All @@ -21,11 +22,18 @@ jobs:

env:
NODE_ENV: ${{ vars.APP_ENV || 'test' }}
DEVKIT_NODE_db_uri: ${{ secrets.MONGO_URI || vars.MONGO_URI || 'mongodb://mongo:27017/NodeTest' }}
DEVKIT_NODE_db_uri: ${{ secrets.MONGO_URI || vars.MONGO_URI || 'mongodb://localhost:27017/NodeTest' }}

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
if: ${{ !vars.RUNNER }}
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: Wait for MongoDB
run: |
timeout 120 bash -c 'until node -e "const uri=process.env.DEVKIT_NODE_db_uri;let host=\"mongo\";let port=27017;try{if(uri){const u=new URL(uri);if(u.hostname)host=u.hostname;if(u.port)port=Number(u.port)||port;}}catch(e){}const s=require(\"net\").createConnection({host,port});s.setTimeout(5000);s.on(\"connect\",()=>{s.end();process.exit(0)});s.on(\"timeout\",()=>{s.destroy();process.exit(1)});s.on(\"error\",()=>process.exit(1))"; do echo "waiting for $DEVKIT_NODE_db_uri..."; sleep 1; done'
Expand Down
Loading