Skip to content

Commit ceb5628

Browse files
committed
feat(FR-1329): add a github action for regression test
1 parent 2357539 commit ceb5628

File tree

3 files changed

+123
-6
lines changed

3 files changed

+123
-6
lines changed

.github/workflows/e2e-test.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# .github/workflows/playwright.yml
2+
name: Playwright Tests
3+
4+
on:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: [self-hosted, linux, x64]
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
lts:
14+
- name: "v25.6"
15+
apiEndpoint: "http://10.122.10.224:8090"
16+
- name: "v24.09"
17+
apiEndpoint: "http://10.122.10.224:8090"
18+
19+
name: E2E Playwright Tests for LTS ${{ matrix.lts.name }}
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- uses: pnpm/action-setup@v4
25+
name: Install pnpm
26+
with:
27+
version: latest
28+
run_install: false
29+
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version-file: ".nvmrc"
33+
cache: "pnpm"
34+
35+
- name: Install dependencies
36+
run: pnpm install
37+
38+
- name: Install Playwright Browsers
39+
run: pnpm exec playwright install --with-deps
40+
41+
- name: Copy config.toml.sample to config.toml
42+
run: |
43+
awk '
44+
/^[[:space:]]*$/ { next }
45+
/^\[.*\]$/ { if (n++) print ""; print; next }
46+
/^[[:space:]]*#[^=]/ { print; next }
47+
{
48+
line = $0
49+
sub(/#.*/, "", line)
50+
sub(/[[:space:]]+$/, "", line)
51+
if (line != "") print line
52+
}
53+
' config.toml.sample > config-cleaned.toml
54+
55+
- name: Inject apiEndpoint into config.toml
56+
run: |
57+
EP="${{ matrix.lts.apiEndpoint }}"
58+
awk -v ep="$EP" '
59+
{
60+
if ($0 ~ /^apiEndpoint[[:space:]]*=/) {
61+
print "apiEndpoint = \"" ep "\""
62+
} else {
63+
print
64+
}
65+
}
66+
' config-cleaned.toml > config.toml
67+
68+
- name: Upload config.toml artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: config-toml-${{ matrix.lts.name }}
72+
path: config.toml
73+
74+
# - name: Run Relay
75+
# run: pnpm run relay
76+
77+
# - name: Build project
78+
# run: pnpm run build
79+
80+
# - name: Serve build at port 9081 (background)
81+
# run: |
82+
# npx serve -s -l 9081 > /dev/null 2>&1 &
83+
# echo "Waiting for server to start..."
84+
# for i in {1..30}; do
85+
# if curl -s http://127.0.0.1:9081 > /dev/null; then
86+
# echo "Server is up!"
87+
# break
88+
# fi
89+
# sleep 1
90+
# done
91+
92+
# - name: Prepare .env.playwright with local server URL
93+
# run: |
94+
# cp e2e/envs/.env.playwright.sample e2e/envs/.env.playwright
95+
# if grep -q '^BASE_URL=' e2e/envs/.env.playwright; then
96+
# sed -i 's|^BASE_URL=.*|BASE_URL=http://127.0.0.1:9081|' e2e/envs/.env.playwright
97+
# else
98+
# echo 'BASE_URL=http://127.0.0.1:9081' >> e2e/envs/.env.playwright
99+
# fi
100+
101+
- name: Run Playwright Tests
102+
run: pnpm exec playwright test
103+
104+
# - name: Upload HTML report (on failure)
105+
# if: failure()
106+
# uses: actions/upload-artifact@v4
107+
# with:
108+
# name: playwright-report-${{ matrix.lts.name }}
109+
# path: playwright-report/

playwright.config.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ export default defineConfig({
7272
// },
7373
],
7474
/* Run your local dev server before starting the tests */
75-
// webServer: {
76-
// command: 'npm run start',
77-
// url: 'http://127.0.0.1:3000',
78-
// reuseExistingServer: !process.env.CI,
79-
// },
75+
webServer: process.env.CI
76+
? {
77+
command: 'concurrently "npm run build:d" "npm run server:d"',
78+
url: "http://127.0.0.1:9081",
79+
timeout: 1000 * 60 * 5,
80+
}
81+
: undefined,
8082
});

tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@
2525
"lib": ["es6", "dom", "es2016", "es2017", "es2020"],
2626
"preserveWatchOutput": true
2727
},
28-
"include": ["src/components/*", "src/plugins/*", "src/reducers/*", "src/*"]
28+
"include": [
29+
"src/components/*",
30+
"src/plugins/*",
31+
"src/reducers/*",
32+
"src/*",
33+
"playwright.config.ts"
34+
]
2935
}

0 commit comments

Comments
 (0)