-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (155 loc) · 5.03 KB
/
Copy pathci.yml
File metadata and controls
185 lines (155 loc) · 5.03 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
177
178
179
180
181
182
183
184
185
name: CI
on:
push:
branches: [ master, main, development ]
pull_request:
branches: [ master, main, development ]
jobs:
test:
name: PHP Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test_db
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml, curl, mysql, pdo, pdo_mysql, gd, zip
coverage: xdebug
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Setup environment
run: |
CI_SECRET="test_secret_key_for_ci_$(openssl rand -hex 32)"
{
echo "DEBUG=true"
echo "DB_DRIVER=mysql"
echo "DB_HOST=127.0.0.1"
echo "DB_NAME=test_db"
echo "DB_USER=root"
echo "DB_PASS=root"
echo "FRONTEND_URL=http://localhost:3000"
echo "SECRET_KEY=$CI_SECRET"
echo "DEFAULT_BLOCK_LANG=1"
echo "SLIDERFILESPATH=upload/sliderImg/"
} > .env
- name: Wait for MySQL
run: |
for i in {1..30}; do
if mysqladmin ping -h 127.0.0.1 -u root -proot --silent; then
echo "MySQL is ready!"
break
fi
echo "Waiting for MySQL... ($i/30)"
sleep 2
done
- name: Create test database schema (if needed)
run: |
# Test database should be created automatically by MySQL service
# But we can verify it exists
mysql -h 127.0.0.1 -u root -proot -e "SHOW DATABASES;" || echo "MySQL connection check"
continue-on-error: true
- name: Run PHPUnit tests
run: vendor/bin/phpunit --testdox --colors=always
env:
DB_HOST: 127.0.0.1
DB_NAME: test_db
DB_USER: root
DB_PASS: root
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
.phpunit.result.cache
tests/_output/
phpstan:
name: PHPStan Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml, curl, mysql, pdo, pdo_mysql
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Run PHPStan
run: vendor/bin/phpstan analyse --memory-limit=1G
continue-on-error: true
codesniffer:
name: PHP CodeSniffer
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Run PHP CodeSniffer
run: vendor/bin/phpcs --standard=PSR12 app/ core/ --ignore=app/Views
continue-on-error: true
build-frontend:
name: Build Frontend Assets
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Build assets
run: npm run build
continue-on-error: true
- name: Check build output
run: |
if [ -d "public/css" ] && [ -d "public/js" ]; then
echo "Build successful - CSS and JS directories exist"
ls -la public/css/
ls -la public/js/
else
echo "Build may have failed - checking for errors"
exit 1
fi