Skip to content

Commit 3365ce1

Browse files
Add GitHub Actions Playwright integration workflow for JA/EN website locale rendering with screenshot artifacts (#2925)
* ci: add website ja/en integration test workflow with playwright Agent-Logs-Url: https://github.com/sensuikan1973/pedax/sessions/b671752b-d862-42eb-991d-dd43c6931560 Co-authored-by: sensuikan1973 <23427957+sensuikan1973@users.noreply.github.com> * Update labeler.yml * ci: upload ja/en page screenshots as website test artifacts Agent-Logs-Url: https://github.com/sensuikan1973/pedax/sessions/d3b24a0c-0c7f-4f12-95a2-ef116bd57001 Co-authored-by: sensuikan1973 <23427957+sensuikan1973@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sensuikan1973 <23427957+sensuikan1973@users.noreply.github.com>
1 parent d408d59 commit 3365ce1

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

.github/labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ windows:
2121
website:
2222
- changed-files:
2323
- any-glob-to-any-file: website/**/*
24+
- any-glob-to-any-file: .github/workflows/website_integration_test.yaml
2425

2526
libedax:
2627
- changed-files:
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
name: Website Integration Test
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- '.github/workflows/website_integration_test.yaml'
8+
- 'website/**'
9+
push:
10+
branches: [main]
11+
paths:
12+
- '.github/workflows/website_integration_test.yaml'
13+
- 'website/**'
14+
workflow_dispatch:
15+
16+
jobs:
17+
website_integration_test:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 15
20+
defaults:
21+
run:
22+
working-directory: website
23+
24+
steps:
25+
- uses: actions/checkout@v6
26+
27+
# https://github.com/actions/setup-node/issues/206#issuecomment-774538395
28+
- uses: nodenv/actions/node-version@main
29+
id: nodenv
30+
- uses: actions/setup-node@v6
31+
with:
32+
node-version: '${{ steps.nodenv.outputs.node-version }}'
33+
34+
- run: yarn install --frozen-lockfile
35+
- run: yarn build
36+
37+
- name: Verify JA/EN website pages with Playwright
38+
run: |
39+
yarn serve --port 3000 --host 127.0.0.1 >"$RUNNER_TEMP/docusaurus-serve.log" 2>&1 &
40+
41+
started=false
42+
for i in {1..60}; do
43+
if curl -fsS "http://127.0.0.1:3000/pedax/" >/dev/null && \
44+
curl -fsS "http://127.0.0.1:3000/pedax/en/" >/dev/null; then
45+
started=true
46+
break
47+
fi
48+
sleep 1
49+
done
50+
51+
if [ "$started" != "true" ]; then
52+
cat "$RUNNER_TEMP/docusaurus-serve.log"
53+
echo "Docusaurus server failed to start"
54+
exit 1
55+
fi
56+
57+
mkdir -p "$RUNNER_TEMP/playwright"
58+
mkdir -p "$RUNNER_TEMP/playwright/screenshots"
59+
cat <<'EOF' >"$RUNNER_TEMP/playwright/package.json"
60+
{
61+
"name": "website-integration-test",
62+
"private": true
63+
}
64+
EOF
65+
66+
cat <<'EOF' >"$RUNNER_TEMP/playwright/website.integration.spec.js"
67+
const { test, expect } = require('@playwright/test')
68+
const path = require('path')
69+
const screenshotDir = process.env.SCREENSHOT_DIR
70+
71+
test('ja locale page is displayed', async ({ page }) => {
72+
const response = await page.goto('http://127.0.0.1:3000/pedax/')
73+
expect(response.ok()).toBeTruthy()
74+
await expect(page.getByText('edax 用のリバーシ盤')).toBeVisible()
75+
await page.screenshot({ path: path.join(screenshotDir, 'ja-page.png'), fullPage: true })
76+
})
77+
78+
test('en locale page is displayed', async ({ page }) => {
79+
const response = await page.goto('http://127.0.0.1:3000/pedax/en/')
80+
expect(response.ok()).toBeTruthy()
81+
await expect(page.getByText('Reversi Board with edax')).toBeVisible()
82+
await page.screenshot({ path: path.join(screenshotDir, 'en-page.png'), fullPage: true })
83+
})
84+
EOF
85+
86+
cd "$RUNNER_TEMP/playwright"
87+
npm install --no-fund --no-audit @playwright/test
88+
npx playwright install chromium
89+
SCREENSHOT_DIR="$RUNNER_TEMP/playwright/screenshots" npx playwright test website.integration.spec.js --reporter=line
90+
91+
- name: Upload website locale screenshots
92+
if: always()
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: website-integration-screenshots
96+
path: ${{ runner.temp }}/playwright/screenshots
97+
if-no-files-found: warn

0 commit comments

Comments
 (0)