-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (143 loc) · 5.21 KB
/
ci.yml
File metadata and controls
164 lines (143 loc) · 5.21 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
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_call: # Allow release.yml to call this workflow
jobs:
# ─── PHP Lint ───────────────────────────────────────────────
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: pdo_mysql, curl, openssl, json, mbstring, redis
- name: Check PHP syntax
run: |
echo "Checking PHP files for syntax errors..."
error_count=0
while IFS= read -r file; do
if ! php -l "$file" 2>&1 | grep -q "No syntax errors"; then
php -l "$file"
error_count=$((error_count + 1))
fi
done < <(find FINAL_PRODUCTION_SYSTEM -name '*.php' -not -path '*/vendor/*' -not -path '*/frontend/*')
if [ "$error_count" -gt 0 ]; then
echo "❌ Found syntax errors in $error_count file(s)"
exit 1
else
echo "✅ All PHP files pass syntax check"
fi
# ─── Frontend Build & Test ──────────────────────────────────
frontend:
name: Frontend Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: FINAL_PRODUCTION_SYSTEM/frontend
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: FINAL_PRODUCTION_SYSTEM/frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: TypeScript & Build
run: npm run build
- name: Run tests
run: npm test
- name: Lint (warnings only)
continue-on-error: true
run: npm run lint
# ─── Docker Stack Health Check ──────────────────────────────
docker-health:
name: Docker Stack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create .env file
run: |
cat > .env <<'EOF'
DB_HOST=db
DB_NAME=oem_activation
DB_USER=oem_user
DB_PASS=ci_oem_pass
MARIADB_ROOT_PASSWORD=ci_root_pass
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=ci_redis_pass
APP_TIMEZONE=UTC
BACKUP_RETENTION_DAYS=30
CORS_ORIGINS=
PHP_MEMORY_LIMIT=256M
PHP_UPLOAD_MAX_FILESIZE=50M
PHP_POST_MAX_SIZE=50M
EOF
# Strip leading whitespace from heredoc
sed -i 's/^[[:space:]]*//' .env
echo "--- .env contents ---"
cat .env
- name: Generate self-signed SSL cert for CI
run: |
mkdir -p ssl
openssl req -x509 -nodes -days 1 -newkey rsa:2048 \
-keyout ssl/server.key -out ssl/server.crt \
-subj "/CN=localhost" 2>/dev/null
echo "✅ SSL cert generated"
- name: Build Docker images
run: docker compose build
- name: Start database and Redis first
run: |
docker compose up -d db redis
echo "Waiting for database to be healthy..."
for i in $(seq 1 40); do
if docker compose exec -T db mariadb -uroot -pci_root_pass -e "SELECT 1" > /dev/null 2>&1; then
echo "✅ Database ready after ~$((i * 5))s"
break
fi
if [ "$i" -eq 40 ]; then
echo "❌ Database failed to start"
docker compose logs db
exit 1
fi
sleep 5
done
- name: Start web and remaining services
run: docker compose up -d
- name: Wait for web server
run: |
echo "Waiting for web server health endpoint..."
for i in $(seq 1 30); do
if curl -sf http://localhost:8080/api/health.php > /dev/null 2>&1; then
echo "✅ Web server healthy after ~$((i * 5))s"
break
fi
if [ "$i" -eq 30 ]; then
echo "❌ Web server failed to start"
docker compose ps
docker compose logs web --tail 50
exit 1
fi
sleep 5
done
- name: Test API health endpoint
run: |
response=$(curl -sf http://localhost:8080/api/health.php)
echo "Health response: $response"
echo "$response" | grep -q "healthy" || (echo "❌ Health check failed" && exit 1)
echo "✅ API health check passed"
- name: Test database connectivity
run: |
docker compose exec -T db mariadb -uoem_user -pci_oem_pass oem_activation -e "SELECT COUNT(*) as table_count FROM information_schema.tables WHERE table_schema = 'oem_activation';" || (echo "❌ Database check failed" && exit 1)
echo "✅ Database connectivity check passed"
- name: Cleanup
if: always()
run: docker compose down -v