fix: update ci node version for markdownlint

This commit is contained in:
tukuaiai
2026-05-02 03:44:18 +08:00
parent a523b6d45f
commit 26e345e8d2
4 changed files with 27 additions and 5 deletions
+2 -2
View File
@@ -17,9 +17,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '22'
- name: Install markdownlint-cli
run: npm install -g markdownlint-cli
- name: Run markdownlint
+1 -1
View File
@@ -56,7 +56,7 @@ git push origin develop
## 3. Must-Run Commands(必须执行的命令清单)
### 环境要求
- Node.js 16+(用于 markdownlint-cli
- Node.js 22+(用于 markdownlint-cli
- Python 3.8+(用于 prompts-library 工具与备份脚本)
- Git
+1 -1
View File
@@ -192,7 +192,7 @@
### 环境要求
- Git:版本控制与 submodule 初始化
- Node.js 16+:运行 `markdownlint-cli`,与 GitHub Actions 中的 `setup-node@v3` 配置一致
- Node.js 22+:运行 `markdownlint-cli`,与 GitHub Actions 中的 `setup-node@v4` 配置一致
- Python 3.8+:运行 prompts-library 与备份脚本
### 初始化
@@ -35,6 +35,8 @@
- O9`.github/workflows/ci.yml` 只监听 `push.branches: [ main ]``pull_request.branches: [ main ]`
- O10:最近 `develop` 相关远端检查只有 `Labeler`,没有 `CI`
- O11:历史 CI 最近记录来自 2026-02 的 `main` push,且 `markdown-lint` 失败;这不是当前 `develop` 迁移提交的验证结果。
- O12:修复 CI 触发分支后,`develop` 的 push / PR 均触发了 CI。
- O13CI 的 `link-checker` 成功,`markdown-lint` 失败,失败原因是 Node.js 16 解析最新版 `markdownlint-cli` 依赖 `string-width` 中的正则 `/v` flag 报 `SyntaxError: Invalid regular expression flags`
## Hypotheses
@@ -59,6 +61,13 @@
- Test:查询 `gh repo view --json defaultBranchRef``git ls-remote --heads origin master main develop``gh run list --workflow CI``.github/workflows/ci.yml`
- Verdictconfirmed。
### H4: CI Node 版本过旧导致 markdownlint 运行时崩溃
- SupportsCI 日志显示 Node 16 环境下 `string-width/index.js``/v` 正则 flag 语法错误;本地 Node 环境运行 `make lint` 通过。
- Conflicts:无。
- Test:修复 CI 触发后查看失败日志。
- Verdictconfirmed。
## Experiments
### E1
@@ -88,9 +97,20 @@
- Verdictconfirmed。
- Revert:无需。
### E4
- HypothesisH4 CI Node 版本过旧导致 markdownlint 运行时崩溃。
- Change:查看 GitHub Actions 失败日志。
- Expected:如果成立,失败发生在工具启动阶段,而不是 Markdown 规则输出阶段。
- Result`markdown-lint` job 在解析依赖时抛出 `SyntaxError: Invalid regular expression flags``link-checker` job 成功。
- Verdictconfirmed。
- Revert:无需。
## Root Cause
- 当前迁移后的本地结构健康,但远端质量门禁存在配置错位:仓库默认分支是 `develop`,仍保留 `master`,不存在 `main`,而 CI workflow 只监听 `main`,导致当前默认开发流不会触发 `markdown-lint``link-checker`
- 当前迁移后的本地结构健康,但远端质量门禁存在两层问题:
1. 仓库默认分支是 `develop`,仍保留 `master`,不存在 `main`,而 CI workflow 原先只监听 `main`,导致当前默认开发流不会触发 `markdown-lint``link-checker`
2. CI 使用 Node.js 16 安装最新版 `markdownlint-cli`,其依赖已使用 Node 16 不支持的正则 `/v` flag,导致 `markdown-lint` 在工具启动阶段崩溃。
## Fix
@@ -99,6 +119,7 @@
- `pull_request.branches: [ develop, master ]`
- 已同步更新 `AGENTS.md` 中 CI 触发规则,避免 Agent 继续相信 `main` 是主线。
- 已给 CI 增加 `workflow_dispatch`,方便手动验证迁移大改。
- 已把 CI Node.js 从 16 升级到 22,并同步 README / AGENTS 的 Node.js 环境要求。
## Regression Evidence
@@ -108,3 +129,4 @@
- 子模块检查:`git submodule status --recursive` 正常。
- 远端检查:`develop` 最新提交只有 Labeler,没有 CI;CI 分支触发条件与默认分支不一致。
- 修复后本地复测:`make lint`、本地 Markdown 相对链接检查、`git diff --check`、断软链接检查、submodule 状态检查均通过。
- 修复后需要再次 push 触发远端 CI,确认 `markdown-lint` 不再因 Node 16 崩溃。