ci
它能做什么
这项技能让用 Ginkgo 编写的 Go 测试能在自动化构建中可靠运行。适合希望持续集成运行能发现错误并清楚报告结果的开发者。
适用场景
- ✓当你在持续集成流水线中设置 Ginkgo 测试的时候。
- ✓当 Ginkgo 测试在你的电脑上通过,但在持续集成中表现不同时。
- ✓当你想从自动运行中获得机器可读的测试报告时。
技能链接
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ci/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请设置我的 Go Ginkgo 测试,使用推荐参数在持续集成中运行,并生成 JSON 报告。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体通过 go run 运行 Ginkgo 工具,使其版本与你的项目一致,并添加随机顺序、并行运行、遇到遗留的 pending 或 focus 标记即失败,以及 JSON 报告等参数。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Ginkgo in CI
A CI invocation should maximize signal — surface flakes and spec pollution, catch mistakes that pass locally, and emit machine-readable artifacts — while collecting every failure in one run. This builds on the CLI (ginkgo:running) and report formats (ginkgo:reporting). Full rationale: https://onsi.github.io/ginkgo/#recommended-continuous-integration-configuration.
The recommended flag set
Invoke via go run so the CLI version always tracks the github.com/onsi/ginkgo/v2 in your go.mod — no separately-installed binary to drift (→ ginkgo:setup).
go run github.com/onsi/ginkgo/v2/ginkgo \
-r -p --randomize-all --randomize-suites \
--fail-on-pending --fail-on-empty --keep-going \
--cover --coverprofile=cover.profile --race --trace \
--json-report=report.json --output-dir=.ginkgo-report \
--timeout=TIMEOUT --poll-progress-after=Xs --poll-progress-interval=Ys
| Flag | Why |
|---|---|
-r |
recursively find and run every suite |
-p |
run each suite in parallel (→ ginkgo:parallelism; set --procs=N/--compilers=N if CPU detection is wrong) |
--randomize-all / --randomize-suites |
shuffle all specs and the suite order to surface spec pollution (→ ginkgo:running) |
--fail-on-pending |
fail if any Pending specs were committed |
--fail-on-empty |
fail if no specs ran (usually a malformed filter) |
--keep-going |
don't stop at the first failed suite — collect all failures |
--cover --coverprofile=cover.profile |
compute coverage into one merged profile (→ ginkgo:reporting) |
--race |
run with the race detector (costs a fixed ~1s per suite — see below) |
--trace |
full stack traces on failure (worth it without a local feedback loop) |
--json-report=report.json |
structured results for diagnosis and downstream tools (→ ginkgo:debugging-failures) |
--timeout=TIMEOUT |
cap the whole run (default 1h — often not enough) |
--poll-progress-after/--poll-progress-interval |
emit progress reports for stuck specs (→ ginkgo:timeouts-and-async) |
The exit-code safeguards — CI's real value
Three flags turn "looks green" into "is actually trustworthy." They make CI fail on mistakes that pass silently on a developer's machine:
--fail-on-pending— a committedPending/PIt/XItbecomes a CI failure, so dev-time placeholders can't rot into the suite.--fail-on-empty— a typo'd--label-filter(or an over-aggressive--skip) that selects zero specs fails instead of falsely passing.- Committed programmatic focus already fails CI for free. A passing suite that contains
FIt/FDescribe/Focusexits non-zero — Ginkgo's built-in guard against shipping focus. Don't suppress it; fix it withginkgo unfocus(→ginkgo:filtering).
Collecting artifacts
Point reports and profiles at one directory and upload it as a build artifact:
--output-dir=.ginkgo-reportcollects the JSON report (and, under-r, merges all suites into onereport.json) plus coverage/profiles into one place. →ginkgo:reportingfor--keep-separate-reportsand the other formats.--junit-report=junit.xmladditionally if your CI system renders JUnit — but keep--json-reportas the source of truth; JUnit loses Ginkgo metadata.- An agent or human then diagnoses failures straight from
report.jsonwithjq→ginkgo:debugging-failures.
CI-friendly console output
--github-output— formats the console log for GitHub Actions readability (grouped, annotated).--force-newlines— flush output line-by-line for CI systems that only flush on newline.--no-color(orGINKGO_NO_COLOR=TRUE) — drop ANSI codes from logs that don't render them.
The race detector's fixed per-suite cost
--race adds about a second to every suite, no matter how few specs it has. ThreadSanitizer sleeps for one second at process exit (atexit_sleep_ms, its default) so that races reported by goroutines still running at exit aren't lost, and Ginkgo has to wait for the processes it spawned. Under -r -p that lands in the gap between suites, where it looks exactly like compilation.
The tell is that it's flat across package size — a 2-spec package pays the same as a 2000-spec package. A build cost can't behave that way; a per-process cost must. If you're auditing a slow race-enabled run, measure with precompiled binaries (ginkgo build -r) so compilation is excluded by construction rather than by
常见问题
为什么要用 go run 运行 Ginkgo?
这样 Ginkgo 工具的版本会与 go.mod 文件中的版本保持一致,无需单独安装,也不会产生版本偏差。
安全检查能发现什么?
提交进代码的 focus 或 pending 标记,以及没有匹配任何测试的过滤条件,否则它们可能掩盖失败。
为什么要随机化测试顺序?
随机顺序有助于发现那些无意中相互依赖的测试。
详情
作者的原始描述
Configure Ginkgo for continuous integration — the recommended CLI flag set and the rationale for each flag (-r -p --randomize-all --randomize-suites --fail-on-pending --fail-on-empty --keep-going --cover --race --trace --json-report --timeout --poll-progress-after/-interval), invoking via go run to pin the CLI to go.mod, the exit-code safeguards that catch committed Focus/Pending and empty filters, collecting report and coverage artifacts with --output-dir, CI-friendly output (--github-output/--force-newlines/--no-color), and the fixed per-suite cost --race adds (GORACE=atexit_sleep_ms=0). Use
repo: onsi/ginkgo
热度
- GitHub 星标
- 9.1k
- 排名
- #12298
- 许可证
- MIT
- 更新时间
- 2026/10/9
评论
- …
同一仓库的更多技能
debugging-failures
9.1k帮你的智能体通过阅读摘要行,并从 JSON 报告中提取确切的失败测试和消息,找出 Ginkgo 测试失败的原因。
decorators
9.1k帮你的智能体正确使用 Ginkgo 测试装饰器,例如 Serial、Ordered、Label、Focus 和超时设置,并解释每一个的作用。
filtering
9.1k帮你的智能体只运行部分 Ginkgo 测试,按正确的优先顺序使用 pending、skip、focus、标签、版本约束和文件过滤器。
ordering-and-flakes
9.1k帮你的智能体控制 Go 测试的执行顺序并处理不稳定的测试,使用 Ginkgo 的 Serial 和 Ordered 设置以及重试选项。