From a214b638fdd9610e825b87d0ed37dcf0d09235af Mon Sep 17 00:00:00 2001 From: Escap1ng Date: Wed, 25 Nov 2026 19:31:43 +0800 Subject: [PATCH 1/2] Fix CI: fetch the Electron binary explicitly before the window smoke npm ci does not download the Electron dist in this environment, so the sandbox-fix step failed on a missing chrome-sandbox; run install.js with retries like the previous workflow did --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b04fa0..1fb0346 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,18 @@ jobs: - name: 安装 JS 依赖(含 Electron 二进制) run: npm ci --no-audit --no-fund + - name: 取回 Electron 二进制 + # npm ci 在此环境不触发 electron 的下载,dist/ 为空;显式跑 install.js,失败重试三次。 + run: | + ok=0 + for attempt in 1 2 3; do + if node node_modules/electron/install.js; then ok=1; break; fi + echo "第 $attempt 次取回 Electron 失败,10 秒后重试" + sleep 10 + done + [ "$ok" = 1 ] || exit 1 + ls -l node_modules/electron/dist | head -12 + - name: 构建 run: npm run build From 17115e95e96ce2097b06a0da7d99c1b2166992ba Mon Sep 17 00:00:00 2001 From: Escap1ng Date: Wed, 25 Nov 2026 19:33:54 +0800 Subject: [PATCH 2/2] Maintain CI: add a core offline-pipeline job and harden the smoke job - New ubuntu job installs numpy/matplotlib plus xelatex/pandoc and runs the offline pipeline end to end, asserting result.json, figure and PDF/DOCX - Guard the layering rule: gateway must not import modeling - Fetch the Electron binary explicitly with retries before the window smoke - Add per-job timeouts and npm caching --- .github/workflows/ci.yml | 68 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fb0346..9790bc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: build: name: 类型与构建 · ${{ matrix.os }} runs-on: ${{ matrix.os }} + timeout-minutes: 15 strategy: fail-fast: false matrix: @@ -34,6 +35,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: '22' + cache: npm - name: 安装 JS 依赖 run: npm ci --no-audit --no-fund @@ -43,15 +45,76 @@ jobs: - name: 内核语法检查 run: python -m compileall -q modeling gateway + - name: 依赖方向守卫(gateway 不得 import modeling) + shell: bash + run: | + python - <<'PY' + import pathlib, re, sys + bad = [ + str(p) for p in pathlib.Path('gateway/src').rglob('*.py') + if re.search(r'(import|from)\s+mms_modeling', p.read_text(encoding='utf-8')) + ] + print('gateway -> modeling imports:', bad or 'none') + sys.exit(1 if bad else 0) + PY + - name: 类型检查 run: npm run typecheck - name: 构建 run: npm run build + core-pipeline: + name: 核心离线全链 · ubuntu + runs-on: ubuntu-latest + timeout-minutes: 20 + + steps: + - uses: actions/checkout@v4 + + - name: 准备 Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: 装数值依赖 + run: | + python -m pip install --upgrade pip + python -m pip install -r modeling/requirements.txt + + - name: 装排版工具 + run: | + sudo apt-get update -q + sudo apt-get install -yq pandoc texlive-xetex texlive-lang-chinese texlive-latex-extra + + - name: 跑离线全链 + run: | + mkdir -p runs/ci + printf '某工厂有 120 条生产线,附件给出每条产线的温度、压力与产量记录。问题一:建立产量与温度、压力的关系模型并做预测;问题二:分析异常产线并给出改进建议;问题三:评估模型稳健性。\n' > runs/ci/problem.txt + python modeling/cli.py run --problem-file runs/ci/problem.txt --out runs/ci/out + + - name: 断言产物 + run: | + python - <<'PY' + import json, pathlib, sys + out = pathlib.Path('runs/ci/out') + result = json.loads((out / 'code' / 'outputs' / 'result.json').read_text(encoding='utf-8')) + pdf = out / 'paper' / 'paper.pdf' + docx = out / 'paper' / 'paper.docx' + checks = { + 'result.ok': bool(result.get('ok')), + 'figure.png': (out / 'code' / 'outputs' / 'figure.png').is_file(), + 'paper.pdf': pdf.is_file() and pdf.open('rb').read(4) == b'%PDF', + 'paper.docx': docx.is_file() and docx.open('rb').read(2) == b'PK', + } + print(checks) + sys.exit(0 if all(checks.values()) else 1) + PY + window-smoke: name: 真启动冒烟 · ubuntu runs-on: ubuntu-latest + timeout-minutes: 20 steps: - uses: actions/checkout@v4 @@ -65,12 +128,13 @@ jobs: uses: actions/setup-node@v4 with: node-version: '22' + cache: npm - - name: 安装 JS 依赖(含 Electron 二进制) + - name: 安装 JS 依赖 run: npm ci --no-audit --no-fund - name: 取回 Electron 二进制 - # npm ci 在此环境不触发 electron 的下载,dist/ 为空;显式跑 install.js,失败重试三次。 + # npm ci 在此环境不触发 electron 下载,dist/ 为空;显式跑 install.js,失败重试三次。 run: | ok=0 for attempt in 1 2 3; do