Skip to content

Commit a2992f9

Browse files
fix: add action config yml
1 parent 5617d3f commit a2992f9

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: [ "master", "main" ]
6+
pull_request:
7+
branches: [ "master", "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
mongodb:
15+
image: mongo:4.4
16+
ports:
17+
- 27017:27017
18+
mysql:
19+
image: mysql:8.0
20+
env:
21+
MYSQL_ROOT_PASSWORD: mysecretpassword
22+
MYSQL_DATABASE: dvws_sqldb
23+
ports:
24+
- 3306:3306
25+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
26+
27+
strategy:
28+
matrix:
29+
node-version: [18.x, 20.x, 22.x]
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install system dependencies (Linux)
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get install -y libxml2 libxml2-dev
38+
39+
- name: Set up Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: '3.11'
43+
44+
- name: Use Node.js ${{ matrix.node-version }}
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: ${{ matrix.node-version }}
48+
cache: 'npm'
49+
50+
- name: Install Dependencies
51+
run: npm ci --build-from-source
52+
53+
- name: Seed Database
54+
env:
55+
SQL_LOCAL_CONN_URL: localhost
56+
SQL_USERNAME: root
57+
SQL_PASSWORD: mysecretpassword
58+
MONGO_LOCAL_CONN_URL: mongodb://localhost:27017/node-dvws
59+
run: node startup_script.js
60+
61+
- name: Start Server and Run Tests
62+
env:
63+
EXPRESS_JS_PORT: 3000
64+
SQL_LOCAL_CONN_URL: localhost
65+
SQL_USERNAME: root
66+
SQL_PASSWORD: mysecretpassword
67+
MONGO_LOCAL_CONN_URL: mongodb://localhost:27017/node-dvws
68+
JWT_SECRET: access
69+
run: |
70+
# Start server in background
71+
node app.js > app.log 2>&1 &
72+
PID=$!
73+
echo "Server started with PID $PID"
74+
75+
# Wait for server to be ready (swagger gen takes time)
76+
sleep 10
77+
78+
# Run tests
79+
npm run test:vulnerabilities
80+
81+
# Kill server
82+
kill $PID

0 commit comments

Comments
 (0)