Repository navigation
ci: 添加 PR 视觉一致性检查 - #34
Merged
Merged
Conversation
PR 合入 main 前,用独立的 tools/svg-compare 工具分支对比 base 与 PR 的生成产物:三维度(总时长偏差 / 平均差异 / 最大差异)各自独立阈值, 全部通过才放行,未通过则 job 失败阻止合并。 - A 侧用 github.event.pull_request.base.sha,B 侧用 HEAD(PR merge commit);fetch-depth: 0 保证两者对象都在本地,fork PR 同样适用 - major 版本不一致时仍出完整报告并上传 artifact,但不阻止合并 - 工具分支 checkout 到子目录,依赖与 Playwright 浏览器在该目录安装, 主仓库代码不做改动
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
目的
为 main 分支添加 PR 视觉一致性检查:PR 合入前自动对比 base 与 PR 的生成产物,视觉回归超阈值则阻止合并。
实现
.github/workflows/visual-compare.yml,在pull_request时运行tools/svg-compare(与主仓库代码解耦,不参与本仓库构建),checkout 到svg-compare-tool/子目录使用github.event.pull_request.base.sha,B 侧 =HEAD(PR 的 merge commit);fetch-depth: 0保证两者提交对象都在本地,fork PR 同样适用,无需额外 fetch 或 secretsconfigs/batch/(可在该分支独立维护,不影响主仓库)major 版本策略
base 与 head 的 major 版本不一致时(如 3.x → 4.x),说明是有意的破坏性变更:仍执行完整对比、上传报告与 artifact,但不因视觉差异阻止合并。
需要的一次性配置
合并后在仓库设置中把
SVG Visual Consistency配置为 required status check,才能真正阻止合并:Settings → Branches → Branch protection rules → main → Require status checks to pass → 勾选
SVG Visual Consistency验证
src/与dist/未变),预期三维度为 0% 并通过Bun.YAML.parse校验结构,步骤顺序、hashFiles路径与 working-directory 均已核对依赖
tools/svg-compare分支已推送到远程