validate-and-fix

bởi openshift

Chạy toàn bộ quy trình xác thực (make test, make lint, tùy chọn make test-e2e) và tự động sửa các lỗi nhỏ như định dạng và vấn đề import. Sử dụng khi...

npx skills add https://github.com/openshift/lightspeed-operator --skill validate-and-fix

Validate & Auto-Fix

Run the project validation pipeline, auto-fix trivial issues, and re-run until green or a real failure is found.

Rules

  • CRITICAL: Never use go test directly - ALWAYS use make test (handles envtest, CRDs, build flags)
  • Never modify production logic to fix a test. Only fix test expectations, imports, formatting.
  • Never skip or delete a failing test.
  • Stop after 3 auto-fix cycles to avoid loops.
  • Report real failures clearly; do not attempt speculative fixes.

Step 1: Run Unit Tests

make test 2>&1 | tail -60

Important: The Makefile handles essential setup (envtest, CRDs, build flags) that go test doesn't.

If all pass, proceed to Step 3 (linting). If failures occur, classify each failure (see Step 2).

Step 2: Classify and Fix Failures

For each failure, determine its type:

Auto-fixable (fix immediately, then re-run Step 1):

TypeFix
Test expects old constant valueUpdate assertion to match new value
Test uses renamed functionUpdate function name in test
Import error from refactorUpdate import path
Missing cleanup in testAdd cleanup or use existing cleanup helpers

Real failures (do not auto-fix):

  • Logic errors in production code
  • Assertion failures reflecting actual behavior regressions
  • Reconciliation loop failures
  • Context cancellation issues
  • Failures in code you did not modify

For real failures: report the test name, file, error message, and stop.

Step 3: Run Linting

make lint 2>&1 | tail -40

This runs: golangci-lint, go fmt, go vet, and custom checks.

If failures occur, apply the same classify-and-fix logic from Step 2. Common fixes at this stage:

TypeFix
gofmt formattinggo fmt ./...
Unused importRemove the import
Unused variableRemove the variable or use _ = variable if intentional
Missing error checkAdd if err != nil { return err }
Ineffectual assignmentRemove or fix the assignment

Re-run make lint after each fix. Proceed to Step 4 when green.

Step 4: Run E2E Tests (Optional)

Only if the user explicitly asks or if changes affect reconciliation logic:

make test-e2e 2>&1 | tail -30

Requirements: Requires a running OpenShift/Kubernetes cluster with operator deployed.

E2E test failures are almost always real failures. Report and stop.

Step 5: Check Bundle and Manifests

If API changes were made (api/v1alpha1/), regenerate manifests:

make generate
make manifests
git diff

If there are differences, commit them:

git add api/ config/
git commit -m "Regenerate manifests"

Step 6: Report

Report exactly:

  • make test: X passed / Y failed
    • List any failing tests with brief error summary
  • make lint: pass/fail
    • List any remaining lint errors
  • make test-e2e: (if run) X passed / Y failed
  • Auto-fixes applied:
    • File: what was fixed (e.g., "internal/controller/utils/utils_test.go: updated assertion")
  • Cycles used: N/3

If all green:

✅ All validation passed:
  - make test: all tests passing
  - make lint: no issues
  
Ready to commit or push.

Do not include unrelated diagnostics or suggestions.

Thêm skills từ openshift

openshift-expert
openshift
Chuyên gia nền tảng OpenShift và Kubernetes với kiến thức sâu về kiến trúc cluster, operators, mạng, lưu trữ, xử lý sự cố và pipeline CI/CD. Sử dụng…
official
find-token
openshift
Tìm mã xác thực ẩn. Chạy tập lệnh find-token để lấy mã duy nhất.
official
code-review
openshift
Xem xét một pull request về chất lượng mã, tính đúng đắn và các quy ước của dự án. Sử dụng khi người dùng yêu cầu xem xét một PR, đánh giá mã, hoặc kiểm tra các thay đổi trên một…
official
css-review
openshift
Xem xét CSS về phong cách mã hóa, cách sử dụng token PatternFly và các phương pháp tốt nhất. Sử dụng khi người dùng yêu cầu xem xét CSS, kiểm tra kiểu dáng hoặc kiểm tra các tệp CSS.
official
review-readmes
openshift
Xem xét tất cả các tệp README.md trong kho lưu trữ để tìm lỗi chính tả, lỗi sai và thông tin lỗi thời. Sử dụng khi người dùng yêu cầu xem xét README, kiểm tra độ chính xác của tài liệu, hoặc…
official
review-skills
openshift
Xem xét các kỹ năng AI của dự án để phát hiện trùng lặp, tham chiếu lỗi thời, sai sót và vấn đề cấu trúc. Sử dụng khi người dùng yêu cầu xem xét kỹ năng, kiểm tra kỹ năng, kiểm tra…
official
test
openshift
Chạy kiểm thử đầu cuối được lọc theo thẻ. Sử dụng khi người dùng yêu cầu chạy kiểm thử, chạy Playwright, hoặc kiểm thử một tính năng cụ thể có thẻ như @core hoặc @attach.
official
unused-exports
openshift
Tìm các ký hiệu được xuất khẩu nhưng không bao giờ được nhập vào tệp khác. Sử dụng khi người dùng nói "kiểm tra xuất khẩu", "xuất khẩu không dùng" hoặc yêu cầu dọn dẹp xuất khẩu.
official