-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (148 loc) · 4.72 KB
/
Copy pathci.yml
File metadata and controls
176 lines (148 loc) · 4.72 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: CI
on:
pull_request:
branches: [ dev, main ]
push:
branches: [ dev, main, test/* ] # Added test/* for testing CI
env:
# Test environment variables
POSTGRES_USER: testuser
POSTGRES_DB: testdb
POSTGRES_PASSWORD: testpassword
POSTGRES_PORT: 5432
MINIO_ROOT_USER: testminio
MINIO_ROOT_PASSWORD: testminio123
MINIO_PORT: 9000
MINIO_CONSOLE_PORT: 9001
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: testuser
POSTGRES_DB: testdb
POSTGRES_PASSWORD: testpassword
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create .env file for testing
run: |
cat << EOF > .env
POSTGRES_USER=testuser
POSTGRES_DB=testdb
POSTGRES_PASSWORD=testpassword
POSTGRES_PORT=5432
DATABASE_URL=postgresql://testuser:testpassword@localhost:5432/testdb
MINIO_ROOT_USER=testminio
MINIO_ROOT_PASSWORD=testminio123
MINIO_PORT=9000
MINIO_CONSOLE_PORT=9001
MINIO_ENDPOINT=localhost
MINIO_ACCESS_KEY=testminio
MINIO_SECRET_KEY=testminio123
EOF
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
- name: Start MinIO manually
run: |
echo "Starting MinIO container manually..."
docker run -d \
--name minio-server \
-p 9000:9000 \
-p 9001:9001 \
-e MINIO_ROOT_USER=testminio \
-e MINIO_ROOT_PASSWORD=testminio123 \
minio/minio server /data --console-address ":9001"
echo "Waiting for MinIO to be ready..."
for i in {1..30}; do
if curl -f http://localhost:9000/minio/health/live 2>/dev/null; then
echo "MinIO is ready!"
break
fi
echo "MinIO is starting... (attempt $i/30)"
sleep 3
done
- name: Install dependencies
run: npm ci
- name: Wait for PostgreSQL to be ready
run: |
echo "Waiting for PostgreSQL..."
until pg_isready -h localhost -p 5432 -U testuser; do
echo "PostgreSQL is unavailable - sleeping"
sleep 2
done
echo "PostgreSQL is ready!"
- name: Comprehensive container communication test
run: |
echo "🧪 Running comprehensive container communication test..."
NODE_OPTIONS='--experimental-vm-modules' node verify-container-communication.js
- name: Run linter (if available)
run: npm run lint --if-present
- name: Test individual components
run: |
echo "Testing Jest configuration..."
npx jest --version
echo "Testing if test files exist..."
ls -la src/__tests__/
- name: Create test database
run: |
echo "Creating test database..."
PGPASSWORD=$POSTGRES_PASSWORD psql \
-h localhost \
-U $POSTGRES_USER \
-d $POSTGRES_DB \
-c "CREATE DATABASE ${POSTGRES_DB}_test;" || echo "Database may already exist"
echo "Test database ready!"
- name: Run database migrations
run: |
echo "Running database migrations..."
NODE_ENV=test npx sequelize-cli db:migrate
echo "Migrations completed!"
- name: Run all tests
run: |
echo "Running all tests without coverage..."
NODE_OPTIONS='--experimental-vm-modules' npm test -- --verbose --runInBand --no-cache --no-coverage
- name: Check test coverage (disabled due to ES modules issues)
run: echo "Coverage collection disabled for now due to ES modules compatibility issues"
- name: Cleanup MinIO container
if: always()
run: |
echo "Cleaning up MinIO container..."
docker stop minio-server || true
docker rm minio-server || true
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build --if-present
- name: Check for security vulnerabilities
run: npm audit --audit-level high