Repository navigation
71 lines (61 loc) · 1.92 KB
/
Copy pathmain.yaml
File metadata and controls
71 lines (61 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
environment: Testing
strategy:
matrix:
node-version: [20.x, 22.x]
max-parallel: 1
services:
mongodb:
image: mongo:latest
options: >-
--health-cmd "mongosh --username admin --password mongodb --authenticationDatabase admin --eval \"db.adminCommand('ping')\""
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
env:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: mongodb
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: |
mern/server/package-lock.json
mern/client/package-lock.json
- name: Install server npm packages
run: npm ci
working-directory: mern/server
- name: Install client npm packages
run: npm ci
working-directory: mern/client
- name: Start server in the background
env:
ATLAS_URI: mongodb://admin:mongodb@localhost:27017/employees?authSource=admin
run: |
echo "ATLAS_URI=$ATLAS_URI" > config.env
npm start > /tmp/server.log 2>&1 &
echo "Server PID: $!"
working-directory: mern/server
- name: Wait for server to be ready
run: |
npx wait-on http://localhost:5050/record --timeout 30000 || (cat /tmp/server.log && exit 1)
- name: Install Cypress and run tests
uses: cypress-io/github-action@v6
with:
working-directory: mern/client
start: npm run dev
wait-on: 'http://localhost:5173'