前端验证 / verify (push) Failing after 15m3s
- 使用内部 checkout 镜像,并校验运行环境中的 Node.js 22 - 检测预览服务端口冲突并重试,避免并行测试误连其他进程 - 调整布局测试的视口宽度和溢出断言,兼容经典滚动条 - 增加时钟暂停的时间余量,避免 CI 调度延迟导致测试失败
38 lines
1.5 KiB
YAML
38 lines
1.5 KiB
YAML
# 仅做前端验证,不包含发布、服务器登录或生产凭证。
|
|
name: 前端验证
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: 获取源码
|
|
# Runner 所在网络访问 github.com 不稳定;使用 git.crash.work 上的副本(手动从 GitHub 推送更新)。
|
|
uses: https://git.crash.work/actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
# Runner 位于中国大陆,ubuntu-latest 映射到自带 Node 22 的 node:22-bookworm-slim 镜像;
|
|
# 不再用 setup-node 从 GitHub 下载 Node(经常超时),只校验镜像内版本。
|
|
- name: 确认 Node.js
|
|
run: |
|
|
node -v
|
|
node -e 'if (Number(process.versions.node.split(".")[0]) !== 22) { console.error("需要 Node 22"); process.exit(1) }'
|
|
- name: 安装锁定依赖
|
|
run: npm ci
|
|
- name: 安装测试浏览器
|
|
run: npx playwright install --with-deps chromium firefox
|
|
- name: 检查源码并构建
|
|
run: |
|
|
npm run check
|
|
npm run build
|
|
- name: 验收真实生产构建
|
|
run: |
|
|
task_chrome_path="$(node --input-type=module -e 'import { chromium } from "playwright"; process.stdout.write(chromium.executablePath())')"
|
|
CHROME_PATH="$task_chrome_path" npm test
|
|
# deepmerge 尚无上游修复版本;低危传播项保留在审计输出,不通过降级框架隐藏。
|
|
- name: 阻止中危及以上依赖风险
|
|
run: npm audit --audit-level=moderate
|