-
Notifications
You must be signed in to change notification settings - Fork 1
189 lines (159 loc) · 5.53 KB
/
ci.yml
File metadata and controls
189 lines (159 loc) · 5.53 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
186
187
188
189
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
test:
name: Tests (PHP ${{ matrix.php-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: [ "8.3", "8.4" ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
tools: composer:v2
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-composer-
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: Validate composer.json
run: composer validate --no-check-all --no-check-lock
- name: Run Unit tests
run: ./vendor/bin/pest tests/Unit
e2e:
name: E2E Tests (WordPress ${{ matrix.wordpress-version }})
runs-on: ubuntu-latest
timeout-minutes: 10 # Жёсткий таймаут — не более 10 минут
strategy:
fail-fast: false
matrix:
php-version: [ "8.3" ]
wordpress-version: [ "latest", "6.7" ]
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress_test
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=3s --health-retries=5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mysqli, pdo_mysql
coverage: none # Отключаем coverage для E2E — ускоряет тесты
tools: composer:v2, wp-cli
ini-values: memory_limit=512M
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-composer-
- name: Cache WordPress
uses: actions/cache@v4
with:
path: /tmp/wordpress
key: wordpress-${{ matrix.wordpress-version }}-v1
restore-keys: |
wordpress-${{ matrix.wordpress-version }}-
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: Setup WordPress
run: |
# Проверяем, есть ли WordPress в кэше
if [ ! -f /tmp/wordpress/wp-load.php ]; then
echo "Downloading WordPress..."
mkdir -p /tmp/wordpress
cd /tmp/wordpress
if [ "${{ matrix.wordpress-version }}" = "latest" ]; then
wp core download --version=latest --allow-root
else
wp core download --version=${{ matrix.wordpress-version }} --allow-root
fi
else
echo "Using cached WordPress"
fi
cd /tmp/wordpress
# Конфигурация (всегда пересоздаём — БД новая)
wp config create \
--dbname=wordpress_test \
--dbuser=wordpress \
--dbpass=wordpress \
--dbhost=127.0.0.1 \
--force \
--allow-root
# Установка WordPress
wp core install \
--url=http://localhost:8080 \
--title="WP Queue Test" \
--admin_user=admin \
--admin_password=admin \
--admin_email=admin@example.com \
--skip-email \
--allow-root
mkdir -p wp-content/uploads
chmod 755 wp-content/uploads
- name: Install Plugin
run: |
cd /tmp/wordpress
rm -rf wp-content/plugins/wp-queue 2>/dev/null || true
ln -s ${{ github.workspace }} wp-content/plugins/wp-queue
wp plugin activate wp-queue --allow-root
- name: Run E2E tests
timeout-minutes: 5 # Таймаут на сами тесты
run: |
cd ${{ github.workspace }}
./vendor/bin/pest tests/Feature --configuration=phpunit-e2e.xml --stop-on-failure --no-coverage
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib
WP_CORE_DIR: /tmp/wordpress
lint:
name: Fix Code Style
runs-on: ubuntu-latest
steps:
- name: Checkout
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
- name: Checkout
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: Laravel Pint
run: ./vendor/bin/pint
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: apply Laravel Pint auto-format"