Skip to content

Commit ad66e1f

Browse files
committed
test: add dev testing scripts with Docker clean install
1 parent f3c0ecf commit ad66e1f

6 files changed

Lines changed: 629 additions & 42 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# 🤖 VSMONSTER CI/CD Pipeline
1+
# 🤖 VSMONSTER CI Pipeline (本機軟體,不需要部署)
22
#
33
# 每次 push 或 PR 自動執行:
44
# 1. 安裝依賴
55
# 2. 類型檢查
66
# 3. 建構所有套件
77
# 4. 執行測試
8-
# 5. 截圖/錄影保存 (Playwright)
8+
#
9+
# 注意:此軟體是本機運行,不需要雲端部署
910

1011
name: CI
1112

@@ -120,46 +121,6 @@ jobs:
120121
packages/mission-control/playwright-report/
121122
retention-days: 30
122123

123-
# ============================================
124-
# 🚀 自動部署 (僅 main 分支)
125-
# ============================================
126-
deploy:
127-
name: Deploy
128-
runs-on: ubuntu-latest
129-
needs: [build, e2e]
130-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
131-
132-
steps:
133-
- name: 📥 Checkout
134-
uses: actions/checkout@v4
135-
136-
- name: 🔧 Setup pnpm
137-
uses: pnpm/action-setup@v2
138-
with:
139-
version: ${{ env.PNPM_VERSION }}
140-
141-
- name: 🟢 Setup Node.js
142-
uses: actions/setup-node@v4
143-
with:
144-
node-version: ${{ env.NODE_VERSION }}
145-
cache: 'pnpm'
146-
147-
- name: 📦 Install dependencies
148-
run: pnpm install --frozen-lockfile
149-
150-
- name: 🏗️ Build for production
151-
run: pnpm build
152-
153-
# Vercel 部署 (如果有設定)
154-
- name: 🔺 Deploy to Vercel
155-
if: env.VERCEL_TOKEN != ''
156-
uses: amondnet/vercel-action@v25
157-
with:
158-
vercel-token: ${{ secrets.VERCEL_TOKEN }}
159-
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
160-
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
161-
working-directory: packages/mission-control
162-
163124
# ============================================
164125
# 🏷️ 發布新版本 (當 push tag 時)
165126
# ============================================

.gitignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ============================================
2+
# 📦 Dependencies
3+
# ============================================
4+
node_modules/
5+
.pnpm-store/
6+
7+
# ============================================
8+
# 🏗️ Build outputs
9+
# ============================================
10+
dist/
11+
.next/
12+
out/
13+
*.vsix
14+
15+
# ============================================
16+
# 🧪 開發測試(不上傳)
17+
# ============================================
18+
dev-test-results/
19+
test-results/
20+
playwright-report/
21+
*.log
22+
23+
# 測試腳本(保留範本,忽略執行結果)
24+
scripts/*.local.sh
25+
26+
# ============================================
27+
# ⚙️ Config files (user specific)
28+
# ============================================
29+
configs/config.json
30+
configs/config.local.json
31+
.env
32+
.env.local
33+
.env.*.local
34+
35+
# ============================================
36+
# 💻 IDE
37+
# ============================================
38+
.idea/
39+
.vscode/settings.json
40+
.vscode/launch.json
41+
*.swp
42+
*.swo
43+
.DS_Store
44+
45+
# ============================================
46+
# 🐳 Docker (test only)
47+
# ============================================
48+
# 保留 docker-compose.yml 和 Dockerfile
49+
# 忽略測試用的臨時文件
50+
51+
# ============================================
52+
# 📊 Misc
53+
# ============================================
54+
*.tgz
55+
coverage/
56+
.turbo/

Dockerfile.test

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# 🐳 VSMONSTER 測試專用 Dockerfile
3+
#
4+
# 用途:乾淨的 Node.js 環境用於測試安裝流程
5+
#
6+
7+
FROM node:20-slim
8+
9+
# 安裝必要工具
10+
RUN apt-get update && apt-get install -y \
11+
git \
12+
curl \
13+
bc \
14+
# Playwright 依賴
15+
libnss3 \
16+
libnspr4 \
17+
libatk1.0-0 \
18+
libatk-bridge2.0-0 \
19+
libcups2 \
20+
libdrm2 \
21+
libxkbcommon0 \
22+
libxcomposite1 \
23+
libxdamage1 \
24+
libxfixes3 \
25+
libxrandr2 \
26+
libgbm1 \
27+
libasound2 \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
# 安裝 pnpm
31+
RUN npm install -g pnpm@8
32+
33+
# 設定工作目錄
34+
WORKDIR /app
35+
36+
# 複製專案檔案
37+
COPY . .
38+
39+
# 給腳本執行權限
40+
RUN chmod +x scripts/*.sh 2>/dev/null || true
41+
42+
# 預設執行測試
43+
CMD ["./scripts/dev-test.sh"]

docker-compose.test.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#
2+
# 🐳 VSMONSTER Docker 乾淨安裝測試環境
3+
#
4+
# 用途:在全新的 Docker 容器中測試安裝流程
5+
# 每次測試完會自動刪除容器,確保環境乾淨
6+
#
7+
# 使用方式:
8+
# docker-compose -f docker-compose.test.yml up --build
9+
# docker-compose -f docker-compose.test.yml down -v # 刪除
10+
#
11+
12+
version: '3.8'
13+
14+
services:
15+
# ============================================
16+
# 🧪 安裝測試容器
17+
# ============================================
18+
install-test:
19+
build:
20+
context: .
21+
dockerfile: Dockerfile.test
22+
container_name: vsmonster-install-test
23+
volumes:
24+
# 掛載測試結果到本機
25+
- ./dev-test-results:/app/dev-test-results
26+
# 不掛載 node_modules,確保乾淨安裝
27+
environment:
28+
- NODE_ENV=development
29+
- CI=true
30+
command: /bin/bash -c "./scripts/dev-test.sh 2>&1 | tee /app/dev-test-results/docker-test.log"
31+
# 測試完自動停止
32+
restart: "no"
33+
34+
# ============================================
35+
# 🎯 Gateway 測試
36+
# ============================================
37+
gateway-test:
38+
build:
39+
context: .
40+
dockerfile: Dockerfile.test
41+
container_name: vsmonster-gateway-test
42+
ports:
43+
- "3333:3333"
44+
volumes:
45+
- ./dev-test-results:/app/dev-test-results
46+
environment:
47+
- NODE_ENV=development
48+
command: |
49+
/bin/bash -c "
50+
pnpm install &&
51+
pnpm --filter @vsmonster/gateway build &&
52+
echo '✅ Gateway 建構成功' > /app/dev-test-results/gateway-test.log &&
53+
pnpm --filter @vsmonster/gateway dev
54+
"
55+
healthcheck:
56+
test: ["CMD", "curl", "-f", "http://localhost:3333/health"]
57+
interval: 10s
58+
timeout: 5s
59+
retries: 3
60+
restart: "no"
61+
62+
# ============================================
63+
# 🖥️ Mission Control 測試
64+
# ============================================
65+
mission-control-test:
66+
build:
67+
context: .
68+
dockerfile: Dockerfile.test
69+
container_name: vsmonster-mission-test
70+
ports:
71+
- "3001:3001"
72+
volumes:
73+
- ./dev-test-results:/app/dev-test-results
74+
environment:
75+
- NODE_ENV=development
76+
command: |
77+
/bin/bash -c "
78+
pnpm install &&
79+
pnpm --filter @vsmonster/mission-control build &&
80+
echo '✅ Mission Control 建構成功' > /app/dev-test-results/mission-test.log &&
81+
pnpm --filter @vsmonster/mission-control start
82+
"
83+
healthcheck:
84+
test: ["CMD", "curl", "-f", "http://localhost:3001"]
85+
interval: 10s
86+
timeout: 5s
87+
retries: 3
88+
depends_on:
89+
- gateway-test
90+
restart: "no"
91+
92+
# ============================================
93+
# 📸 E2E 截圖測試
94+
# ============================================
95+
e2e-test:
96+
build:
97+
context: .
98+
dockerfile: Dockerfile.test
99+
container_name: vsmonster-e2e-test
100+
volumes:
101+
- ./dev-test-results:/app/dev-test-results
102+
environment:
103+
- NODE_ENV=development
104+
- PLAYWRIGHT_VIDEO=on
105+
- PLAYWRIGHT_SCREENSHOT=on
106+
command: |
107+
/bin/bash -c "
108+
pnpm install &&
109+
pnpm exec playwright install chromium --with-deps &&
110+
pnpm --filter @vsmonster/mission-control build &&
111+
pnpm --filter @vsmonster/mission-control test:e2e || true &&
112+
cp -r packages/mission-control/test-results/* /app/dev-test-results/ 2>/dev/null || true &&
113+
cp -r packages/mission-control/playwright-report /app/dev-test-results/ 2>/dev/null || true &&
114+
echo '✅ E2E 測試完成'
115+
"
116+
depends_on:
117+
mission-control-test:
118+
condition: service_healthy
119+
restart: "no"
120+
121+
# ============================================
122+
# 🗂️ 測試完不保留 volumes
123+
# ============================================
124+
# 使用 docker-compose down -v 清除所有數據

0 commit comments

Comments
 (0)