Skip to content

Create test.yml

Create test.yml #1

Workflow file for this run

name: Run tests
on:
push:
branches: [ main, develop ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
mongodb-version: ['4.2', '4.4', '5.0', '6.0']
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Start MongoDB Replica Set
run: |
sudo mongod --replSet "rs" &
sleep 5
mongo --eval "rs.initiate()"
- name: Restore MongoDB Test Data
run: mongorestore -d "mainstayX" ./dbTest
- name: Start App
run: |
JWT_SECRET="dhe?3wfje;wf1" \
DB_NAME="mainstayX" \
DB_PORT="27017" \
DB_HOST="127.0.0.1" \
LISTEN_API="4000" \
node ./src/app.js
- name: Run tests
run: npm test