-
-
Notifications
You must be signed in to change notification settings - Fork 228
229 lines (195 loc) · 7.15 KB
/
Copy pathplaywright-pages.yml
File metadata and controls
229 lines (195 loc) · 7.15 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
name: Playwright Report
on:
workflow_dispatch:
concurrency:
group: playwright-report-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
playwright:
name: Run Playwright Against Docker Dev Stack
runs-on: ubuntu-latest
timeout-minutes: 120
outputs:
test_outcome: ${{ steps.playwright.outcome }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache-dependency-path: tests/playwright/package-lock.json
- name: Install Playwright dependencies
working-directory: tests/playwright/
run: npm ci
- name: Install Chromium
working-directory: tests/playwright/
run: npx playwright install --with-deps chromium
- name: Build and start FPP
env:
FPPBRANCH: ${{ github.ref_name }}
run: docker compose -f Docker/docker-compose.playwright.yml up -d --build fpp
- name: Wait for FPP web UI
run: |
for attempt in $(seq 1 60); do
if curl -fsSI http://127.0.0.1:8080/ >/dev/null; then
exit 0
fi
sleep 10
done
echo "FPP web UI did not become ready on http://127.0.0.1:8080"
docker compose -f Docker/docker-compose.playwright.yml ps
exit 1
- name: Complete initial setup gate for CI
run: |
curl -fsS -X PUT \
-H 'Content-Type: text/plain' \
--data-binary '1' \
http://127.0.0.1:8080/api/settings/initialSetup-02
sleep 2
- name: Wait for index.php to render
run: |
for attempt in $(seq 1 30); do
body="$(curl -fsS http://127.0.0.1:8080/index.php || true)"
if printf '%s' "${body}" | grep -q 'id="bodyWrapper"'; then
if ! printf '%s' "${body}" | grep -q 'initialSetup.php?redirect='; then
exit 0
fi
fi
sleep 5
done
echo "index.php did not reach the expected ready state"
echo "--- index.php response (first 200 lines) ---"
curl -sS http://127.0.0.1:8080/index.php | sed -n '1,200p'
echo "--- initialSetup.php response (first 120 lines) ---"
curl -sS http://127.0.0.1:8080/initialSetup.php | sed -n '1,120p'
exit 1
- name: Browser preflight diagnostics
working-directory: tests/playwright/
env:
PLAYWRIGHT_BASE_URL: http://127.0.0.1:8080
run: |
node <<'EOF'
const { chromium } = require('@playwright/test');
const fs = require('fs');
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ baseURL: process.env.PLAYWRIGHT_BASE_URL });
const requests = [];
page.on('requestfailed', request => {
requests.push(`FAILED ${request.method()} ${request.url()} :: ${request.failure()?.errorText || 'unknown'}`);
});
page.on('response', response => {
const status = response.status();
if (status >= 400) {
requests.push(`HTTP ${status} ${response.request().method()} ${response.url()}`);
}
});
page.on('pageerror', error => {
requests.push(`PAGEERROR ${error.message}`);
});
page.on('console', message => {
if (message.type() === 'error') {
requests.push(`CONSOLE ${message.type()} ${message.text()}`);
}
});
await page.goto('/index.php', { waitUntil: 'domcontentloaded', timeout: 30000 });
await page.waitForTimeout(3000);
const html = await page.content();
fs.writeFileSync('preflight-index.html', html);
await page.screenshot({ path: 'preflight-index.png', fullPage: true });
console.log(`FINAL_URL=${page.url()}`);
console.log(`PAGE_TITLE=${await page.title()}`);
console.log(`BODY_WRAPPER_COUNT=${await page.locator('#bodyWrapper').count()}`);
console.log(`INITIAL_SETUP_COUNT=${await page.locator('#initialSetup').count()}`);
console.log('--- PRELIGHT EVENTS ---');
for (const line of requests) {
console.log(line);
}
await browser.close();
})().catch(error => {
console.error(error);
process.exit(1);
});
EOF
- name: Run Playwright tests
id: playwright
continue-on-error: true
working-directory: tests/playwright/
env:
PLAYWRIGHT_BASE_URL: http://127.0.0.1:8080
run: npm test
- name: Upload Playwright debug artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-debug
path: |
tests/playwright/preflight-index.html
tests/playwright/preflight-index.png
tests/playwright/test-results
if-no-files-found: warn
retention-days: 14
- name: Upload Playwright report artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-report
path: tests/playwright/playwright-report
if-no-files-found: error
retention-days: 14
- name: Show Docker logs on failure
if: always()
run: docker compose -f Docker/docker-compose.playwright.yml logs --no-color fpp
- name: Stop Docker stack
if: always()
run: docker compose -f Docker/docker-compose.playwright.yml down --volumes
deploy:
name: Publish Report To GitHub Pages
needs: playwright
if: always() && needs.playwright.result != 'cancelled'
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Configure GitHub Pages
uses: actions/configure-pages@v6
- name: Download Playwright report artifact
uses: actions/download-artifact@v8
with:
name: playwright-report
path: tests/playwright/playwright-report
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: tests/playwright/playwright-report
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
finalize:
name: Finalize Workflow Status
needs:
- playwright
- deploy
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail workflow if tests failed
run: |
if [ "${{ needs.playwright.outputs.test_outcome }}" != "success" ]; then
echo "Playwright tests failed. Report was still deployed to GitHub Pages."
exit 1
fi
- name: Print Github Pages URL
run: |
echo "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}"