Skip to content

Commit e6ed8de

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

File tree

3 files changed

+139
-6
lines changed

3 files changed

+139
-6
lines changed

.github/workflows/e2e-test.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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: Get pnpm store directory
36+
shell: bash
37+
run: |
38+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
39+
40+
- uses: actions/cache@v4
41+
name: Setup pnpm cache
42+
with:
43+
path: ${{ env.STORE_PATH }}
44+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
45+
restore-keys: |
46+
${{ runner.os }}-pnpm-store-
47+
48+
- name: Install dependencies
49+
run: pnpm install
50+
51+
- name: Install Playwright Browsers
52+
run: pnpm exec playwright install --with-deps
53+
54+
- name: Copy config.toml.sample to config.toml
55+
run: |
56+
awk '
57+
/^[[:space:]]*$/ { next }
58+
/^\[.*\]$/ { if (n++) print ""; print; next }
59+
/^[[:space:]]*#[^=]/ { print; next }
60+
{
61+
line = $0
62+
sub(/#.*/, "", line)
63+
sub(/[[:space:]]+$/, "", line)
64+
if (line != "") print line
65+
}
66+
' config.toml.sample > config-cleaned.toml
67+
68+
- name: Inject apiEndpoint into config.toml
69+
run: |
70+
EP="${{ matrix.lts.apiEndpoint }}"
71+
awk -v ep="$EP" '
72+
{
73+
if ($0 ~ /^apiEndpoint[[:space:]]*=/) {
74+
print "apiEndpoint = \"" ep "\""
75+
} else {
76+
print
77+
}
78+
}
79+
' config-cleaned.toml > config.toml
80+
81+
- name: Upload config.toml artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: config-toml-${{ matrix.lts.name }}
85+
path: config.toml
86+
87+
# - name: Run Relay
88+
# run: pnpm run relay
89+
90+
# - name: Build project
91+
# run: pnpm run build
92+
93+
# - name: Serve build at port 9081 (background)
94+
# run: |
95+
# npx serve -s -l 9081 > /dev/null 2>&1 &
96+
# echo "Waiting for server to start..."
97+
# for i in {1..30}; do
98+
# if curl -s http://127.0.0.1:9081 > /dev/null; then
99+
# echo "Server is up!"
100+
# break
101+
# fi
102+
# sleep 1
103+
# done
104+
105+
# - name: Prepare .env.playwright with local server URL
106+
# run: |
107+
# cp e2e/envs/.env.playwright.sample e2e/envs/.env.playwright
108+
# if grep -q '^BASE_URL=' e2e/envs/.env.playwright; then
109+
# sed -i 's|^BASE_URL=.*|BASE_URL=http://127.0.0.1:9081|' e2e/envs/.env.playwright
110+
# else
111+
# echo 'BASE_URL=http://127.0.0.1:9081' >> e2e/envs/.env.playwright
112+
# fi
113+
114+
- name: Run Relay Compiler
115+
run: pnpm run relay
116+
117+
- name: Run Playwright Tests
118+
run: pnpm exec playwright test
119+
120+
- name: Upload HTML report (on failure)
121+
if: failure()
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: playwright-report-${{ matrix.lts.name }}
125+
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)