-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (92 loc) · 2.42 KB
/
ci.yml
File metadata and controls
99 lines (92 loc) · 2.42 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: CI/CD Pipeline
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
# Lint and format check
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "25"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
- name: Check formatting
run: npm run format -- --check
# Run tests
test:
name: Run Tests
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:latest
env:
MARIADB_ROOT_PASSWORD: testpassword
MARIADB_DATABASE: server_api_test
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis:8-alpine
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 25
cache: npm
- name: Install dependencies
run: npm ci
- name: Wait for MariaDB
run: |
sudo apt-get install -y mariadb-client
until mariadb -h 127.0.0.1 -u root -ptestpassword -e "SELECT 1" &> /dev/null; do
echo 'waiting for mariadb...'
sleep 2
done
- name: Setup database
run: mariadb -h 127.0.0.1 -u root -ptestpassword server_api_test < db/schema.sql
- name: Run tests
run: npm test
env:
NODE_ENV: test
DB_HOST: 127.0.0.1
DB_USER: root
DB_PASSWORD: testpassword
DB_NAME: server_api_test
REDIS_ENABLED: true
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
# Security audit
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 25
- name: Run npm audit
run: npm audit --audit-level=moderate
continue-on-error: true