fix: 登录密码校验/显隐与 Cloudflare Pages 部署修复 (#171) #150
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # BioQuest 持续集成 | |
| # 每次 push / PR 自动运行: | |
| # 1. JS 语法检查(node --check 全部 js) | |
| # 2. 单元测试(Jest:IRT / FSRS 核心算法) | |
| # 3. jsdom 烟雾测试(Wiki 模块) | |
| # | |
| # 说明:Playwright 浏览器回归测试(tests/qa-test*.js)需要真实浏览器 + 本地服务, | |
| # 开销较大,未纳入默认 CI,可单独运行本地开发命令执行。 | |
| name: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| jobs: | |
| test: | |
| name: lint + unit + smoke | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: vendor 完整性校验(P0 供应链门禁) | |
| # 防"以好心升级库为名"的投毒:任何 js/vendor/* 文件被替换/新增且未同步 | |
| # 更新清单,此处直接 FAIL。合法升级需人工审查后运行 | |
| # `node scripts/verify-vendor-integrity.js --update` 再提交。 | |
| run: node scripts/verify-vendor-integrity.js | |
| - name: 第三方资源白名单 + SRI 完整性校验(Issue #104) | |
| # 纯静态审计(不联网):外部 URL 域名必须进入 data/third-party-domains.txt | |
| # 白名单或内置豁免清单;外链样式/脚本/KaTeX preload 必须携带 integrity。 | |
| run: node scripts/verify-third-party.js | |
| - name: 提交信息规范校验(Issue #113) | |
| # pull_request 事件下 checkout 的是自动生成的 merge commit("Merge X into Y"), | |
| # 其信息不可作数,故显式校验 PR head 提交;push 事件无 pull_request 上下文, | |
| # 回退校验 HEAD(即最新提交本身)。 | |
| run: | | |
| PR_SHA="${{ github.event.pull_request.head.sha }}" | |
| if [ -n "$PR_SHA" ]; then | |
| # 默认 checkout 深度 1,PR head 对象可能不在本地,先以深度 1 拉取 | |
| git fetch origin "$PR_SHA" --depth=1 2>/dev/null || true | |
| node scripts/check-commit-msg.js --subject "$(git log -1 --format=%s "$PR_SHA" 2>/dev/null || true)" | |
| else | |
| node scripts/check-commit-msg.js | |
| fi | |
| - name: Install dependencies | |
| run: npm install | |
| - name: JS 语法检查 | |
| run: | | |
| fail=0 | |
| for f in $(git ls-files 'js/**/*.js' 'tests/*.js' 'tests/*.cjs'); do | |
| node --check "$f" || { echo "SYNTAX FAIL: $f"; fail=1; } | |
| done | |
| exit $fail | |
| - name: manifest CDN 锚点一致性校验(Issue #15) | |
| # 必须排在「题库重建确定性」重跑生成器之前——重跑会用 runner 环境 | |
| # 改写工作区 manifest,锚点被"洗白"后此校验失去意义 | |
| # (这正是 CI 之前抓不到 PR #25 fork 锚点的原因)。 | |
| run: node scripts/verify-manifest-anchor.js | |
| - name: 题库分片一致性校验(Issue #10) | |
| # 校验 manifest/index/bank 三层分片:SHA-256 完整性、bioID 全局唯一与格式、 | |
| # 模块前缀一致、index/bank 双向一致。(新题库为 M 格式;旧的内容寻址反算与 | |
| # bioid-map 迁移映射校验因 #150 更换数据体系 / 删除 bioid-map 而移除。) | |
| run: node scripts/verify-bio-shards.js | |
| - name: 单元测试(IRT / FSRS / 调度器 + 覆盖率门禁) | |
| # #140/#141:--coverage 已并入 test:unit;低于 jest.config.cjs | |
| # coverageThreshold 的任何指标都会使本步骤失败(防覆盖率回退) | |
| run: npm run test:unit | |
| - name: RLS 策略静态审计(Issue #100) | |
| # 离线审计 sql/*.sql:每个被创建的表必须启用 RLS 或存在策略, | |
| # 无保护表 → 非零退出(防「anon key 暴露 + RLS 配置错误」导致全表泄露)。 | |
| run: node scripts/audit-rls.js | |
| - name: 发布资源压缩构建验证(Issue #112) | |
| # 验证 js/css 可经 esbuild 压缩进 dist/(构建产物不入库), | |
| # 且首屏同步 CSS 可合并为 bundle-core.css(Issue #108)。 | |
| run: | | |
| npm run build:min | |
| npm run build:css | |
| - name: 烟雾测试(Wiki) | |
| run: npm run test:smoke | |
| e2e: | |
| name: Playwright E2E(Issue P1-28) | |
| runs-on: ubuntu-latest | |
| needs: test | |
| timeout-minutes: 15 | |
| # Playwright 需真实系统依赖,故各步骤使用默认环境(含 apt 的 ubuntu), | |
| # 不重复运行上游 job,避免拉长整套流水线耗时。 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Install Playwright 与 Chromium | |
| # 以 --no-save 方式装载 Playwright,避免把重型依赖写入仓库锁定文件; | |
| # --with-deps 自动安装浏览器所需的系统共享库。 | |
| run: | | |
| npm install --no-save playwright | |
| npx playwright install chromium --with-deps | |
| - name: 启动静态服务器 | |
| # 静态 SPA 由 python3 提供(与本地开发一致),绑定随机端口避免冲突。 | |
| run: | | |
| python3 -m http.server 8091 --bind 127.0.0.1 > /tmp/bioquest-http.log 2>&1 & | |
| echo "http server started (127.0.0.1:8091)" | |
| - name: Run Playwright E2E(P1-28) | |
| # e2e-smoke.js 内置服务器冷启动重试,测试脚本常在服务器就绪前才开始。 | |
| run: npm run test:e2e |