validate-before-merge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseValidate 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:checkExpected: No errors or warnings
If fails: Run to auto-fix
pnpm formatbash
pnpm lint:check预期结果:无错误或警告
如果失败:执行自动修复
pnpm formatStep 2: Build All Packages
步骤2:构建所有包
bash
pnpm buildExpected: 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:ciExpected: 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/- (UI-related)
packages/keychain/src/hooks/ - Storybook configuration
bash
pnpm test:storybookExpected: 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/- (与UI相关)
packages/keychain/src/hooks/ - 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 statusExpected: 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 testFull CI Mirror
完整CI镜像检查
To exactly mirror what GitHub Actions runs:
bash
undefined要完全复刻GitHub Actions的运行流程:
bash
undefinedClean 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
undefinedpnpm test:storybook
undefinedValidation Checklist
验证检查清单
Before requesting merge, verify:
- passes
pnpm lint:check - succeeds with no errors
pnpm build - all tests pass
pnpm test:ci - passes (if UI changed)
pnpm test:storybook - 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 - 通过(若UI有变更)
pnpm test:storybook - 代码中无遗留的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/mainbash
git fetch origin main
git rebase origin/mainMerge conflicts
合并冲突
bash
git fetch origin main
git merge origin/mainbash
git fetch origin main
git merge origin/mainResolve conflicts
解决冲突
pnpm build # Verify after resolving
undefinedpnpm build # 解决后验证
undefinedReporting Results
结果报告
After validation, report:
markdown
undefined验证完成后,按以下格式报告:
markdown
undefinedValidation 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)
已准备好合并。
若发现问题:
```markdownValidation 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
待修复问题
- Type error: Property 'foo' does not exist on type 'Bar'
undefined- 类型错误:类型'Bar'上不存在属性'foo'
undefined