Chuyển đến nội dung
Skillpedia
Kiểm thử9.1k · #12298

ci

Skill này làm gì

Skill này thiết lập các bài kiểm thử Go viết bằng Ginkgo để chúng chạy đáng tin cậy trong các bản build tự động. Nó dành cho lập trình viên muốn lượt CI bắt được các lỗi và báo cáo kết quả rõ ràng.

Khi nào nên dùng

  • ✓Khi bạn đang thiết lập các bài kiểm thử Ginkgo trong một pipeline CI.
  • ✓Khi một lượt kiểm thử Ginkgo chạy đạt trên máy bạn nhưng hoạt động khác trong CI.
  • ✓Khi bạn muốn có báo cáo kiểm thử mà máy có thể đọc từ các lần chạy tự động.

Liên kết skill

https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ci/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ci/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết lập các bài kiểm thử Go Ginkgo của tôi để chạy trong CI với các cờ khuyến nghị và một báo cáo JSON.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent chạy công cụ Ginkgo qua go run để phiên bản khớp với dự án của bạn, và thêm các cờ cho thứ tự ngẫu nhiên, chạy song song, thất bại khi còn pending hoặc focus, và một báo cáo JSON.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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 committed Pending/PIt/XIt becomes 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/Focus exits non-zero — Ginkgo's built-in guard against shipping focus. Don't suppress it; fix it with ginkgo unfocus (→ ginkgo:filtering).

Collecting artifacts

Point reports and profiles at one directory and upload it as a build artifact:

  • --output-dir=.ginkgo-report collects the JSON report (and, under -r, merges all suites into one report.json) plus coverage/profiles into one place. → ginkgo:reporting for --keep-separate-reports and the other formats.
  • --junit-report=junit.xml additionally if your CI system renders JUnit — but keep --json-report as the source of truth; JUnit loses Ginkgo metadata.
  • An agent or human then diagnoses failures straight from report.json with jq → 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 (or GINKGO_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

Câu hỏi thường gặp

Vì sao phải chạy Ginkgo qua go run?

Cách này giữ phiên bản công cụ Ginkgo khớp với phiên bản trong file go.mod, nên không có cài đặt riêng nào bị lệch.

Các kiểm tra an toàn bắt được gì?

Các dấu focus hoặc pending được commit vào code, và các bộ lọc không khớp bài kiểm thử nào, vì chúng có thể che giấu lỗi.

Vì sao phải xáo trộn thứ tự kiểm thử?

Thứ tự ngẫu nhiên giúp phát hiện các bài kiểm thử phụ thuộc lẫn nhau một cách vô tình.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
9.1k
Vị trí xếp hạng
#12298
Giấy phép
MIT
Cập nhật
9/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự