6e7179eb24
新增 nas-frontend job(checkout→npm ci→npm run build→rsync dist 到 NAS homes/admin/frontend/dist),与 nas-smoke 并行;vps job 改 needs[nas-smoke,nas-frontend]。打通.vue 改动→push→CI 自动 build→NAS web 自动生效闭环(此前前端 dist 被 gitignore+promote.sh 无 frontend+workflow 无 build,CI 对前端完全断)。复用 Mac runner node v26/npm,HOME=/Users/chufeng 复用 ~/.npm cache。VPS 无 web 不部署前端。容器 bind mount homes/admin->/app,放挂载源即生效,无需改 Dockerfile。
100 lines
4.2 KiB
YAML
100 lines
4.2 KiB
YAML
name: CI/CD
|
||
# 三机流水线:push master → Mac runner 单测 → NAS 冒烟(ssh) → [prod gate] → VPS 部署+冒烟
|
||
# Runner: 复用 online 的 mac-mini-arm64 (label: macos-arm64),host executor 直接跑 Mac shell。
|
||
# 关键:①不用 actions/checkout(避免从 github 拉 action 国内 EOF),改 git fetch Gitea 本仓库
|
||
# ②env HOME=/Users/chufeng 恢复 Mac 全环境(ssh config/key + venv310),act_runner 默认 HOME 是临时目录
|
||
# ③git config --local http.proxy "" 禁代理(LAN Gitea 直连,不动全局 .gitconfig)
|
||
on:
|
||
push:
|
||
branches: [master]
|
||
workflow_dispatch: {}
|
||
|
||
jobs:
|
||
# ---------- P2: 验证 ----------
|
||
test:
|
||
runs-on: macos-arm64
|
||
env:
|
||
HOME: /Users/chufeng
|
||
steps:
|
||
- name: checkout (直连 Gitea, git fetch 绕过 github action)
|
||
env:
|
||
TOKEN: ${{ github.token }}
|
||
run: |
|
||
git init .
|
||
git config --local http.proxy ""
|
||
git config --local https.proxy ""
|
||
git remote add origin "http://oauth2:${TOKEN}@192.168.2.154:3000/${GITHUB_REPOSITORY}.git"
|
||
git fetch --depth 1 origin "${GITHUB_SHA}"
|
||
git checkout FETCH_HEAD
|
||
- name: pytest 冒烟 (venv310 python 绝对路径, 数据层核心)
|
||
# CI 冒烟=数据层核心(memory验证112 pass); source activate非交互不生效故用venv绝对python;
|
||
# api/live 需 fastapi(venv310未装)留各session自测; PYTHONPATH=workspace 跑 checkout 版本
|
||
run: |
|
||
PY=/Users/chufeng/.openclaw/sanguo_projects/sanguo_vnpy_v2/venv310/bin/python
|
||
PYTHONPATH="$GITHUB_WORKSPACE" $PY -m pytest tests/data_platform -q
|
||
|
||
nas-smoke:
|
||
needs: test
|
||
runs-on: macos-arm64
|
||
env:
|
||
HOME: /Users/chufeng
|
||
steps:
|
||
- name: NAS 冒烟 (replica dbbardata 可读)
|
||
# smoke_e2e.py 的 docker -v $(pwd):/app 覆盖镜像 /app 致 entrypoint/vnpy 丢失, 改直接查 NAS 副本冒烟
|
||
run: |
|
||
ssh sanguo-nas "python3 -c 'import sqlite3
|
||
c=sqlite3.connect(\"/volume1/stock/sanguo_vnpy_v2/data_backup/quant_trading.db\")
|
||
n=c.execute(\"SELECT COUNT(*) FROM dbbardata WHERE symbol=?\",(\"600519\",)).fetchone()[0]
|
||
print(\"dbbardata 600519 rows:\", n)
|
||
exit(0 if n>0 else 1)'"
|
||
|
||
# ---------- 前端 build + 部署 NAS(与 nas-smoke 并行; VPS 无 web 不部署前端) ----------
|
||
nas-frontend:
|
||
needs: test
|
||
runs-on: macos-arm64
|
||
env:
|
||
HOME: /Users/chufeng
|
||
steps:
|
||
- name: checkout
|
||
env:
|
||
TOKEN: ${{ github.token }}
|
||
run: |
|
||
git init .
|
||
git config --local http.proxy ""
|
||
git config --local https.proxy ""
|
||
git remote add origin "http://oauth2:${TOKEN}@192.168.2.154:3000/${GITHUB_REPOSITORY}.git"
|
||
git fetch --depth 1 origin "${GITHUB_SHA}"
|
||
git checkout FETCH_HEAD
|
||
- name: build 前端 (node 在 /opt/homebrew/bin; npm ci 复用 HOME 的 ~/.npm cache)
|
||
run: |
|
||
export PATH="/opt/homebrew/bin:$PATH"
|
||
cd frontend
|
||
npm ci
|
||
npm run build
|
||
- name: 部署 dist 到 NAS (容器 bind mount homes/admin->/app; StaticFiles 实时读文件无需 restart)
|
||
run: |
|
||
rsync -az --delete frontend/dist/ sanguo-nas:/volume1/homes/admin/.sanguo_projects/sanguo_vnpy_v2/frontend/dist/
|
||
|
||
# ---------- P3: VPS CD (prod gate) ----------
|
||
vps:
|
||
needs: [nas-smoke, nas-frontend]
|
||
runs-on: macos-arm64
|
||
env:
|
||
HOME: /Users/chufeng
|
||
environment: prod # 人工审批 gate;删此行 = 验证通过全自动推 VPS
|
||
steps:
|
||
- name: checkout
|
||
env:
|
||
TOKEN: ${{ github.token }}
|
||
run: |
|
||
git init .
|
||
git config --local http.proxy ""
|
||
git config --local https.proxy ""
|
||
git remote add origin "http://oauth2:${TOKEN}@192.168.2.154:3000/${GITHUB_REPOSITORY}.git"
|
||
git fetch --depth 1 origin "${GITHUB_SHA}"
|
||
git checkout FETCH_HEAD
|
||
- name: promote 代码到 NAS+VPS
|
||
run: bash scripts/nas_sync/promote.sh
|
||
- name: VPS 冒烟 (LocalUnifiedProvider 真数据)
|
||
run: ssh 49.232.102.198 'cd C:\sanguo_vnpy_v2 && C:\Python310\python.exe -X utf8 scripts/data_platform/verify_unified_e2e.py'
|