gate-ci-a11y
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGate CI with Real A11y CLI
借助Real A11y CLI管控CI流程
Shell/CI surface for live URLs. Docs: https://real-a11y.dev/packages/cli
Commands: https://real-a11y.dev/packages/cli/commands
Config: https://real-a11y.dev/packages/cli/configuration
PR bot recipe: https://real-a11y.dev/guide/ci-diff-bot
Commands: https://real-a11y.dev/packages/cli/commands
Config: https://real-a11y.dev/packages/cli/configuration
PR bot recipe: https://real-a11y.dev/guide/ci-diff-bot
面向实时URL的Shell/CI操作界面。文档:https://real-a11y.dev/packages/cli
命令:https://real-a11y.dev/packages/cli/commands
配置:https://real-a11y.dev/packages/cli/configuration
PR机器人方案:https://real-a11y.dev/guide/ci-diff-bot
命令:https://real-a11y.dev/packages/cli/commands
配置:https://real-a11y.dev/packages/cli/configuration
PR机器人方案:https://real-a11y.dev/guide/ci-diff-bot
Install in CI
在CI中安装
sh
npm i -D @real-a11y-dev/cli@beta playwright
npx real-a11y installServe the app (or point at a preview URL), wait until healthy, then audit.
sh
npm i -D @real-a11y-dev/cli@beta playwright
npx real-a11y install启动应用(或指向预览URL),等待应用就绪后执行审计。
Simple gate
简单管控
sh
npx real-a11y audit http://localhost:3000- Exit 1 on error-severity findings.
- Exit 2 (or non-zero failure) when the URL is unreachable — never treat network failure as a clean pass.
- Optional with
a11y.config.jsonanddefaultsfor multi-page runs.urls
sh
npx real-a11y audit http://localhost:3000- 若发现错误级问题,退出码为1。
- 若URL无法访问,退出码为2(或非零失败)——绝不将网络故障视为检查通过。
- 可选配置文件,通过
a11y.config.json和defaults实现多页面运行。urls
PR regression (snapshot → diff)
PR回归检测(快照→差异对比)
- On the base ref: (or configured set)
real-a11y snapshot <url> --output base.json - On the PR ref:
real-a11y snapshot <url> --output pr.json - — fails on new regressions
real-a11y diff base.json pr.json - Use for PR comments; optional
--format mdfor structural hints (advisory only — do not treat as a hard signal alone)--explain
Identity matching uses fingerprints — do not line-diff raw JSON by hand. Noisy
live pages (timestamps, ads) may need (see CLI docs / D3).
--ignore-view-lineCapture baselines in a fresh session if you also use for acts.
--session- 在基准分支上执行:(或已配置的URL集合)
real-a11y snapshot <url> --output base.json - 在PR分支上执行:
real-a11y snapshot <url> --output pr.json - 执行——若出现新的回归问题则检查失败
real-a11y diff base.json pr.json - 使用生成PR评论;可选
--format md参数获取结构提示(仅作参考——请勿单独将其作为硬性判断依据)--explain
身份匹配采用指纹识别——请勿手动对比原始JSON的行差异。包含动态内容(如时间戳、广告)的页面可能需要使用参数(详见CLI文档/D3)。
--ignore-view-line如果同时使用参数执行操作,请在全新会话中捕获基线。
--sessionAdopting on existing debt
适配既有问题场景
Use baseline suppression on (not ) so only new
issues fail the build:
real-a11y snapshotauditsh
npx real-a11y snapshot --config a11y.config.json --update-baseline
npx real-a11y snapshot --config a11y.config.json \
--baseline .a11y-baseline.json --fail-on error--baselinediff在****(而非)命令中使用基线抑制功能,仅让新出现的问题导致构建失败:
real-a11y snapshotauditsh
npx real-a11y snapshot --config a11y.config.json --update-baseline
npx real-a11y snapshot --config a11y.config.json \
--baseline .a11y-baseline.json --fail-on error--baselinediffArtifacts
产物
Prefer documented reporters (, , / ) for uploads to
code-scanning / test dashboards. The CLI is not a crawler — name the URLs.
sarifjunitjsonjsonl优先使用官方文档支持的报告格式(、、 / )上传至代码扫描/测试仪表盘。该CLI并非爬虫工具——需明确指定要检查的URL。
sarifjunitjsonjsonlRelated
相关工具
- One-off human/agent audit →
audit-a-page - In-suite snapshots →
a11y-snapshot-tests
- 单次人工/Agent审计 →
audit-a-page - 套件内快照测试 →
a11y-snapshot-tests