validate-before-merge

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Validate Before Merge

合并前验证

Overview

概述

This skill runs all checks that CI performs to validate code is ready for merge. Use this to catch issues locally before CI runs.
该Skill会执行CI所做的所有检查,以验证代码是否已准备好合并。可用于在CI运行前在本地发现问题。

Full Validation Sequence

完整验证流程

Run these checks in order. Each step must pass before proceeding.
按以下顺序执行这些检查。每一步必须通过后才能进行下一步。

Step 1: Lint and Format Check

步骤1:代码检查与格式校验

bash
pnpm lint:check
Expected: No errors or warnings If fails: Run
pnpm format
to auto-fix
bash
pnpm lint:check
预期结果:无错误或警告 如果失败:执行
pnpm format
自动修复

Step 2: Build All Packages

步骤2:构建所有包

bash
pnpm build
Expected: Successful build with no TypeScript errors If fails: Fix type errors in the reported files
bash
pnpm build
预期结果:构建成功,无TypeScript错误 如果失败:修复报告文件中的类型错误

Step 3: Unit Tests

步骤3:单元测试

bash
pnpm test:ci
Expected: All tests pass If fails:
  • Review failing test output
  • Fix code or update tests as appropriate
  • Never skip failing tests without justification
bash
pnpm test:ci
预期结果:所有测试通过 如果失败
  • 查看失败的测试输出
  • 相应地修复代码或更新测试
  • 若无合理理由,切勿跳过失败的测试

Step 4: Visual Regression Tests (if UI changed)

步骤4:视觉回归测试(若UI有变更)

Only required if changes touch:
  • packages/keychain/src/components/
  • packages/keychain/src/hooks/
    (UI-related)
  • Storybook configuration
bash
pnpm test:storybook
Expected: All visual comparisons pass If fails with intentional changes:
bash
pnpm test:storybook:update
git add packages/*/__image_snapshots__/
git commit -m "chore: update storybook snapshots"
仅当变更涉及以下内容时需要执行:
  • packages/keychain/src/components/
  • packages/keychain/src/hooks/
    (与UI相关)
  • Storybook配置
bash
pnpm test:storybook
预期结果:所有视觉对比通过 如果因有意变更导致失败
bash
pnpm test:storybook:update
git add packages/*/__image_snapshots__/
git commit -m "chore: update storybook snapshots"

Step 5: Verify No Uncommitted Changes

步骤5:验证无未提交变更

bash
git status
Expected: Clean working directory (or only untracked files you intend to ignore)
bash
git status
预期结果:工作目录干净(或仅存在你打算忽略的未跟踪文件)

Quick Validation Script

快速验证脚本

For a fast validation (similar to pre-commit):
bash
pnpm lint:check && pnpm build && pnpm test
如需快速验证(类似预提交检查):
bash
pnpm lint:check && pnpm build && pnpm test

Full CI Mirror

完整CI镜像检查

To exactly mirror what GitHub Actions runs:
bash
undefined
要完全复刻GitHub Actions的运行流程:
bash
undefined

Clean environment (optional but recommended)

清理环境(可选但推荐)

pnpm clean && pnpm i
pnpm clean && pnpm i

Quality job

质量检查任务

pnpm lint:check
pnpm lint:check

Test job

测试任务

pnpm build pnpm test:ci --coverage
pnpm build pnpm test:ci --coverage

Storybook job (if UI changes)

Storybook任务(若UI有变更)

pnpm test:storybook
undefined
pnpm test:storybook
undefined

Validation Checklist

验证检查清单

Before requesting merge, verify:
  • pnpm lint:check
    passes
  • pnpm build
    succeeds with no errors
  • pnpm test:ci
    all tests pass
  • pnpm test:storybook
    passes (if UI changed)
  • No console.log or debug statements left in code
  • No hardcoded secrets or credentials
  • PR description accurately describes changes
  • Related issues are linked
请求合并前,请确认:
  • pnpm lint:check
    通过
  • pnpm build
    成功且无错误
  • pnpm test:ci
    所有测试通过
  • pnpm test:storybook
    通过(若UI有变更)
  • 代码中无遗留的console.log或调试语句
  • 无硬编码的密钥或凭证
  • PR描述准确描述了变更内容
  • 已关联相关问题

Common Pre-Merge Issues

常见合并前问题

Forgotten console.log

遗留console.log

bash
grep -r "console.log" packages/*/src --include="*.ts" --include="*.tsx" | grep -v "test"
bash
grep -r "console.log" packages/*/src --include="*.ts" --include="*.tsx" | grep -v "test"

Outdated dependencies

依赖项过时

bash
git fetch origin main
git rebase origin/main
bash
git fetch origin main
git rebase origin/main

Merge conflicts

合并冲突

bash
git fetch origin main
git merge origin/main
bash
git fetch origin main
git merge origin/main

Resolve conflicts

解决冲突

pnpm build # Verify after resolving
undefined
pnpm build # 解决后验证
undefined

Reporting Results

结果报告

After validation, report:
markdown
undefined
验证完成后,按以下格式报告:
markdown
undefined

Validation Results

验证结果

  • Lint: Passed
  • Build: Passed
  • Tests: Passed (X tests, X% coverage)
  • Storybook: Passed (or N/A if no UI changes)
Ready for merge.

Or if issues found:

```markdown
  • 代码检查:通过
  • 构建:通过
  • 测试:通过(X个测试,覆盖率X%)
  • Storybook:通过(若无UI变更则标记为N/A)
已准备好合并。

若发现问题:

```markdown

Validation Results

验证结果

  • Lint: Passed
  • Build: Failed - Type error in packages/controller/src/account.ts:42
  • Tests: Not run (blocked by build failure)
  • 代码检查:通过
  • 构建:失败 - packages/controller/src/account.ts:42存在类型错误
  • 测试:未执行(被构建失败阻塞)

Issues to Fix

待修复问题

  1. Type error: Property 'foo' does not exist on type 'Bar'
undefined
  1. 类型错误:类型'Bar'上不存在属性'foo'
undefined