Skip to content

ci: add local lint and shared pr checks#73

Merged
awsl233777 merged 2 commits intoSakuraByteCore:mainfrom
SurviveM:fix/release-default-web-port-and-align-codex-defaults
Apr 6, 2026
Merged

ci: add local lint and shared pr checks#73
awsl233777 merged 2 commits intoSakuraByteCore:mainfrom
SurviveM:fix/release-default-web-port-and-align-codex-defaults

Conversation

@SurviveM
Copy link
Copy Markdown
Collaborator

@SurviveM SurviveM commented Apr 6, 2026

Summary

  • Add a shared CI runner script so local checks and GitHub Actions use the same install, lint, and test steps
  • Add a zero-dependency lint script to syntax-check project source and JSON files before test runs
  • Cover the CI and lint contracts in unit tests so workflow drift fails before push

Tests

  • npm run lint
  • npm run test:ci

Summary by CodeRabbit

  • New Features

    • Added a local lint command and CI-oriented script entrypoints to standardize checks.
  • Tests

    • Added tests to verify CI workflow and lint integration remain aligned with project scripts.
  • Chores

    • CI updated to invoke project-defined npm entrypoints for install, lint, and test steps.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a373960d-f0b4-4437-ae07-1b6cc756afbc

📥 Commits

Reviewing files that changed from the base of the PR and between 20f26c9 and 27693b5.

📒 Files selected for processing (1)
  • scripts/lint.js
✅ Files skipped from review due to trivial changes (1)
  • scripts/lint.js

📝 Walkthrough

Walkthrough

CI workflow now delegates install/lint/test steps to project npm scripts (ci:install, ci:lint, ci:test). Added two CLI scripts (scripts/run-ci-check.js, scripts/lint.js) and contract tests to ensure workflow and package.json scripts remain aligned; test runner imports updated tests.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/ci.yml
Replaced direct npm ci/lint/test invocations with npm run ci:install, npm run ci:lint, npm run ci:test.
Package scripts
package.json
Added ci:install, ci:lint, ci:test, lint, and test:ci script entries pointing to new Node scripts or existing commands.
CLI scripts
scripts/run-ci-check.js, scripts/lint.js
Added run-ci-check.js to map/execute CI steps (install, lint, test, all) by spawning npm commands; added lint.js to recursively validate .js/.mjs/.cjs and .json files (JSON parse checks and Node --check for JS).
Contract tests
tests/unit/ci-workflow-contract.test.mjs, tests/unit/lint-contract.test.mjs
Added tests asserting .github/workflows/ci.yml triggers and step commands match package.json scripts and that scripts/lint.js exists and is referenced correctly.
Test harness
tests/unit/run.mjs
Imported the two new unit test modules so they run in the harness.

Sequence Diagram(s)

sequenceDiagram
  participant GH as "GitHub Actions Runner"
  participant NPM as "npm (script runner)"
  participant RC as "run-ci-check.js"
  participant LINT as "scripts/lint.js"
  participant NODE as "Node / spawned commands"

  GH->>NPM: run `npm run ci:install` / `ci:lint` / `ci:test`
  NPM->>RC: invoke `node scripts/run-ci-check.js <step>`
  RC->>NODE: spawn `npm ci` / `npm run lint --if-present` / `npm run test --if-present`
  RC->>LINT: (for lint) run `node scripts/lint.js`
  LINT->>NODE: Node performs JSON parse and `node --check` syntax checks
  NODE-->>RC: exit status
  RC-->>NPM: return status (propagate failure if non-zero)
  NPM-->>GH: workflow step success/failure
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • ymkiux
  • awsl233777

Poem

🐰 A nimble script hops through CI's gate,
Running installs, lint, and tests in state,
Contracts snugged tight to keep steps in line,
I nibble whitespace and call it fine. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding a local lint script and shared CI checks via new scripts and workflow modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ymkiux
Copy link
Copy Markdown
Collaborator

ymkiux commented Apr 6, 2026

@coderabbitai 如果我直接合并会带来回归性异常吗

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I'll check the actual file contents to give you an accurate regression risk assessment.


🏁 Script executed:

#!/bin/bash
echo "=== package.json scripts section ==="
cat package.json | python3 -c "import sys,json; d=json.load(sys.stdin); [print(k,':',v) for k,v in d.get('scripts',{}).items()]"

echo ""
echo "=== scripts/run-ci-check.js ==="
cat scripts/run-ci-check.js

echo ""
echo "=== scripts/lint.js ==="
cat scripts/lint.js

echo ""
echo "=== tests/unit/run.mjs ==="
cat tests/unit/run.mjs

echo ""
echo "=== .github/workflows/ci.yml ==="
cat .github/workflows/ci.yml

echo ""
echo "=== tests/unit/ci-workflow-contract.test.mjs ==="
cat tests/unit/ci-workflow-contract.test.mjs

echo ""
echo "=== tests/unit/lint-contract.test.mjs ==="
cat tests/unit/lint-contract.test.mjs

Length of output: 11359


@ymkiux 根据对所有变更文件的逐一审查,以下是合并风险评估:


✅ 低风险区域

变更项 风险 原因
package.json 🟢 无 现有脚本完全未修改,仅追加了新的 ci:* 入口
scripts/run-ci-check.js 🟢 极低 只是将原有命令(npm cinpm run lint --if-presentnpm run test --if-present)封装了一层,行为上功能等价
tests/unit/run.mjs 🟢 极低 新增的两条测试 import 是顺序执行的,且失败仅计入 failures 计数,不会阻断其他已有测试
合约测试 (ci-workflow-contract, lint-contract) 🟢 低 这两个测试校验的就是本 PR 自身新增的内容,只要 PR 内部一致就会通过

⚠️ 需注意的点

scripts/lint.js 对全仓库文件做语法检测(新行为):

  • 该脚本递归扫描所有 .js/.mjs/.cjs/.json 文件(跳过 .gitnode_modules.tmp,但不跳过 dist/build/
  • 如果仓库中存在任何之前未被检测到的语法错误,CI 现在将会失败——这是新引入的强制约束
  • 由于您已在本地成功运行 npm run lint,说明当前代码库通过了检测,此风险实际可控

📋 结论

可以安全合并。 本 PR 是纯粹的基础设施增量——没有修改任何现有业务逻辑、API 或接口,不存在回归性异常的实质风险。唯一新增的行为是全仓库语法检测,但您本地已验证通过。


🧠 Learnings used
Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-04-04T01:36:26.964Z
Learning: In PR `#68` for SakuraByteCore/codexmate, github-actions[bot] again flagged that CodeRabbit was introducing breaking changes. The maintainer's absolute constraint (reinforced across PRs `#55`, `#59`, `#67`, `#68`) is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-03-30T04:47:15.352Z
Learning: In PR `#55` for SakuraByteCore/codexmate, github-actions[bot] repeatedly flagged that CodeRabbit was introducing breaking changes. The maintainer's absolute constraint is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-03-31T12:37:51.023Z
Learning: In PR `#59` for SakuraByteCore/codexmate, github-actions[bot] repeatedly flagged that CodeRabbit was introducing breaking changes. The maintainer's absolute constraint is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-04-03T10:42:22.368Z
Learning: In PR `#67` for SakuraByteCore/codexmate, github-actions[bot] flagged that CodeRabbit was again introducing breaking changes. The maintainer's absolute constraint (reinforced across PRs `#55`, `#59`, `#67`) is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me check the actual file contents to give you a precise answer.


🏁 Script executed:

#!/bin/bash
echo "=== .github/workflows/ci.yml ==="
cat .github/workflows/ci.yml

echo ""
echo "=== package.json (scripts section) ==="
cat package.json | python3 -c "import json,sys; d=json.load(sys.stdin); print(json.dumps(d.get('scripts', {}), indent=2))"

echo ""
echo "=== scripts/run-ci-check.js ==="
cat scripts/run-ci-check.js

echo ""
echo "=== scripts/lint.js ==="
cat scripts/lint.js

echo ""
echo "=== tests/unit/run.mjs ==="
cat tests/unit/run.mjs

echo ""
echo "=== tests/unit/ci-workflow-contract.test.mjs ==="
cat tests/unit/ci-workflow-contract.test.mjs

echo ""
echo "=== tests/unit/lint-contract.test.mjs ==="
cat tests/unit/lint-contract.test.mjs

Length of output: 11361


@ymkiux 根据对所有变更文件的仔细审查,合并风险很低,以下是具体分析:


✅ 不会引入回归的部分

变更 风险说明
package.json 新增脚本 纯增量,现有脚本(test, test:unit, test:e2e 等)完全未改动
ci.yml 指令切换 run-ci-check.js 内部执行的命令与原来完全一致:npm cinpm run lint --if-presentnpm run test --if-present
新增合约测试 增量测试,不影响现有测试逻辑
scripts/run-ci-check.js 仅是对原有命令序列的封装,行为等价

⚠️ 一处值得注意的行为变化(非回归,是有意改动)

之前 ci.ymlnpm run lint --if-present 因为 package.json 没有 lint 脚本,实际上是空操作(被 --if-present 跳过)。

合并后,lint 脚本正式定义为 node scripts/lint.js,CI 中的 Lint 步骤将真正执行,对所有 .js.mjs.cjs.json 文件进行语法检查。

这是 PR 的核心目的,PR 描述中也确认已通过 npm run lint 测试。


🔍 一处低风险的技术细节

scripts/lint.js 使用正则 /\b(?:import|export)\b|import\.meta/ 来判断 .js 文件是否为 ESM。如果项目中某个 CJS 文件的注释或字符串里包含 import/export 关键字,可能被误判为 ESM 模块从而导致 lint 失败。由于作者已本地测试通过,当前代码库中不存在此问题,但这是未来新增文件时需留意的点。


结论

可以直接合并,现有功能不会受到影响。唯一实质变化是 CI 的 Lint 阶段从"空操作"变为"真实执行",这正是此 PR 的目标。


🧠 Learnings used
Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-04-04T01:36:26.964Z
Learning: In PR `#68` for SakuraByteCore/codexmate, github-actions[bot] again flagged that CodeRabbit was introducing breaking changes. The maintainer's absolute constraint (reinforced across PRs `#55`, `#59`, `#67`, `#68`) is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-03-30T04:47:15.352Z
Learning: In PR `#55` for SakuraByteCore/codexmate, github-actions[bot] repeatedly flagged that CodeRabbit was introducing breaking changes. The maintainer's absolute constraint is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-03-31T12:37:51.023Z
Learning: In PR `#59` for SakuraByteCore/codexmate, github-actions[bot] repeatedly flagged that CodeRabbit was introducing breaking changes. The maintainer's absolute constraint is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

Learnt from: github-actions[bot]
Repo: SakuraByteCore/codexmate PR: 0
File: :0-0
Timestamp: 2026-04-03T10:42:22.368Z
Learning: In PR `#67` for SakuraByteCore/codexmate, github-actions[bot] flagged that CodeRabbit was again introducing breaking changes. The maintainer's absolute constraint (reinforced across PRs `#55`, `#59`, `#67`) is: no breaking changes in any review suggestion; limit all feedback to correctness, safety, and quality only within the existing design, without refactoring or altering APIs, interfaces, or behavior.

Copy link
Copy Markdown
Collaborator

@awsl233777 awsl233777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve after checks passed and change scope is clear.

@awsl233777 awsl233777 merged commit a5ffbfd into SakuraByteCore:main Apr 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants