-
-
Notifications
You must be signed in to change notification settings - Fork 75
289 lines (236 loc) · 10.6 KB
/
e2e.yml
File metadata and controls
289 lines (236 loc) · 10.6 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: E2E Tests
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
cypress:
runs-on: ubuntu-latest
timeout-minutes: 45 # Increased for setup wizard + Stripe test clock advancement
strategy:
matrix:
php: ["8.1", "8.2"] # Reduced PHP versions for faster CI
browser: ["chrome"] # Start with Chrome only for reliability
services:
mailpit:
image: axllent/mailpit:latest
ports:
- 1025:1025
- 8025:8025
options: >-
--health-cmd="wget --spider -q http://localhost:8025 || exit 1"
--health-interval=2s
--health-timeout=2s
--health-retries=10
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 18
- name: Cache NPM dependencies
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache
- name: Install NPM dependencies
run: npm ci
- name: Cache Composer dependencies
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3
with:
path: vendor
key: ${{ runner.os }}-composer-cache
- name: Install Composer dependencies
run: composer install
- name: Set PHP version and filter missing plugins for wp-env
run: |
node -e "
const fs = require('fs');
const path = require('path');
const config = JSON.parse(fs.readFileSync('.wp-env.json', 'utf8'));
const override = { config: { phpVersion: '${{ matrix.php }}' }, env: {} };
for (const [envName, envConfig] of Object.entries(config.env || {})) {
if (envConfig.plugins) {
const existing = envConfig.plugins.filter(p => {
const resolved = path.resolve(p);
return fs.existsSync(resolved);
});
override.env[envName] = { plugins: existing };
}
}
fs.writeFileSync('.wp-env.override.json', JSON.stringify(override, null, 2));
console.log('Override:', JSON.stringify(override, null, 2));
"
- name: Start WordPress Test Environment
run: npm run env:start:test
- name: Wait for WordPress to be ready
run: |
for i in {1..60}; do
if curl -s http://localhost:8889 | grep -q "WordPress"; then
echo "WordPress is ready";
break;
fi
echo "Waiting for WordPress... ($i/60)";
sleep 5;
done
echo "Final check:"
curl -s http://localhost:8889 || echo "WordPress not responding"
- name: Network-activate plugin in tests environment
run: |
echo "=== Network-activating Ultimate Multisite plugin ==="
PLUGIN_SLUG=$(basename "$PWD")
echo "Plugin slug: $PLUGIN_SLUG"
# Network-activate so wu_save_setting() and other functions
# are fully bootstrapped for all wp eval / eval-file calls.
npx wp-env run tests-cli wp plugin activate "$PLUGIN_SLUG" --network || \
npx wp-env run tests-cli wp plugin activate ultimate-multisite --network || \
echo "⚠️ Could not network-activate by directory name, listing plugins..."
echo "Plugin list after activation attempt:"
npx wp-env run tests-cli wp plugin list --status=active --format=table
echo "Verifying wu_save_setting() is available:"
npx wp-env run tests-cli wp eval "var_dump(function_exists('wu_save_setting'));" || true
- name: Comprehensive WordPress Debug
run: |
echo "=== WordPress Environment Debug ==="
echo "1. Basic URL Tests:"
curl -I http://localhost:8889 || echo "❌ WordPress not responding"
curl -I http://localhost:8889/wp-admin/ || echo "❌ WP Admin not responding"
curl -I http://localhost:8889/wp-admin/network/ || echo "❌ Network admin not responding"
echo -e "\n2. WordPress Content Test:"
curl -s http://localhost:8889 | head -20 | grep -E "(WordPress|wp-)" || echo "❌ No WordPress indicators found"
echo -e "\n3. Plugin Status Check:"
curl -s "http://localhost:8889/wp-admin/network/plugins.php" | grep -i "multisite-ultimate" || echo "❌ Plugin not found in network admin"
echo -e "\n4. Database Connection Test:"
curl -s "http://localhost:8889/wp-admin/network/" | grep -E "(Database|MySQL|connection)" || echo "✅ No database errors visible"
echo -e "\n5. Multisite Status:"
curl -s http://localhost:8889 | grep -i "multisite\|network" || echo "ℹ️ No multisite indicators in homepage"
echo -e "\n6. Error Log Check:"
docker logs $(docker ps -q --filter "name=tests-wordpress") 2>&1 | tail -20 || echo "ℹ️ Could not get container logs"
echo -e "\n7. File System Check:"
ls -la $(pwd) || echo "❌ Could not list current directory"
ls -la $(pwd)/multisite-ultimate.php 2>/dev/null && echo "✅ Main plugin file exists" || echo "❌ Main plugin file not found"
- name: Pre-Test Environment Verification
run: |
echo "=== Pre-Test Verification ==="
echo "1. Cypress Config Check:"
ls -la cypress.config.test.js && echo "✅ Config file exists" || echo "❌ Config file missing"
echo "2. Test Files Check:"
ls -la tests/e2e/cypress/integration/ && echo "✅ Test directory exists" || echo "❌ Test directory missing"
find tests/e2e/cypress/integration/ -name "*.spec.js" | wc -l | xargs echo "Test files found:"
echo "3. Support Files Check:"
ls -la tests/e2e/cypress/support/commands/ && echo "✅ Commands directory exists" || echo "❌ Commands missing"
echo "4. Cypress Environment Variables:"
echo "Base URL: http://localhost:8889"
cat cypress.env.json 2>/dev/null || echo "❌ cypress.env.json not found"
- name: Run Setup Test (Must Run First)
id: setup-test
run: |
echo "=== Starting Setup Test ==="
npx cypress run \
--config-file cypress.config.test.js \
--spec "tests/e2e/cypress/integration/000-setup.spec.js" \
--browser ${{ matrix.browser }}
- name: Dump container logs on setup failure
if: failure() && steps.setup-test.outcome == 'failure'
run: |
echo "=== Container logs (last 100 lines) ==="
docker logs $(docker ps -q --filter "name=tests-wordpress") 2>&1 | tail -100 || echo "Could not get container logs"
echo "=== PHP error log ==="
npx wp-env run tests-cli cat /var/www/html/wp-content/debug.log 2>&1 | tail -100 || echo "No debug.log found"
- name: Run Checkout Tests (After Setup)
id: checkout-tests
run: |
set +e
echo "=== Starting Checkout Tests ==="
CHECKOUT_TESTS=(
"tests/e2e/cypress/integration/010-manual-checkout-flow.spec.js"
"tests/e2e/cypress/integration/020-free-trial-flow.spec.js"
)
TOTAL_FAILURES=0
for TEST_SPEC in "${CHECKOUT_TESTS[@]}"; do
echo "Running: $TEST_SPEC"
npx cypress run \
--config-file cypress.config.test.js \
--spec "$TEST_SPEC" \
--browser ${{ matrix.browser }}
CYPRESS_EXIT_CODE=$?
if [ $CYPRESS_EXIT_CODE -eq 0 ]; then
echo "✅ $TEST_SPEC passed"
else
echo "❌ $TEST_SPEC failed with exit code $CYPRESS_EXIT_CODE"
TOTAL_FAILURES=$((TOTAL_FAILURES + 1))
fi
done
if [ $TOTAL_FAILURES -gt 0 ]; then
echo "❌ $TOTAL_FAILURES checkout test(s) failed"
exit 1
fi
echo "✅ All checkout tests passed!"
- name: Run SSO Redirect Loop Tests (After Setup)
id: sso-tests
run: |
echo "=== Starting SSO Redirect Loop Tests ==="
npx cypress run \
--config-file cypress.config.test.js \
--spec "tests/e2e/cypress/integration/065-sso-redirect-loop.spec.js" \
--browser ${{ matrix.browser }}
- name: Run Stripe Tests (After Setup)
id: stripe-tests
env:
STRIPE_TEST_PK_KEY: ${{ secrets.STRIPE_TEST_PK_KEY }}
STRIPE_TEST_SK_KEY: ${{ secrets.STRIPE_TEST_SK_KEY }}
run: |
if [ -z "$STRIPE_TEST_SK_KEY" ]; then
echo "⏭️ Skipping Stripe tests: STRIPE_TEST_SK_KEY secret not configured"
exit 0
fi
set +e
echo "=== Starting Stripe Tests ==="
STRIPE_TESTS=(
"tests/e2e/cypress/integration/030-stripe-checkout-flow.spec.js"
"tests/e2e/cypress/integration/040-stripe-renewal-flow.spec.js"
)
TOTAL_FAILURES=0
for TEST_SPEC in "${STRIPE_TESTS[@]}"; do
echo "Running: $TEST_SPEC"
npx cypress run \
--config-file cypress.config.test.js \
--spec "$TEST_SPEC" \
--browser ${{ matrix.browser }}
CYPRESS_EXIT_CODE=$?
if [ $CYPRESS_EXIT_CODE -eq 0 ]; then
echo "✅ $TEST_SPEC passed"
else
echo "❌ $TEST_SPEC failed with exit code $CYPRESS_EXIT_CODE"
TOTAL_FAILURES=$((TOTAL_FAILURES + 1))
fi
done
if [ $TOTAL_FAILURES -gt 0 ]; then
echo "❌ $TOTAL_FAILURES Stripe test(s) failed"
exit 1
fi
echo "✅ All Stripe tests passed!"
- name: Fix permissions for Cypress output
if: always()
run: sudo chown -R $USER:$USER tests/e2e/cypress
- name: Upload Cypress screenshots
if: always()
continue-on-error: true
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: cypress-screenshots-${{ matrix.php }}-${{ matrix.browser }}
path: tests/e2e/cypress/screenshots
- name: Upload Cypress videos
if: always()
continue-on-error: true
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: cypress-videos-${{ matrix.php }}-${{ matrix.browser }}
path: tests/e2e/cypress/videos
- name: Stop WordPress Environment
if: always()
run: npm run env:stop