validate-and-fix

โดย openshift

เรียกใช้ไปป์ไลน์การตรวจสอบแบบเต็ม (make test, make lint, และ make test-e2e ตามตัวเลือก) และแก้ไขอัตโนมัติสำหรับข้อผิดพลาดเล็กน้อย เช่น การจัดรูปแบบและปัญหาการนำเข้า ใช้เมื่อ...

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.

Skills เพิ่มเติมจาก openshift

openshift-expert
openshift
ผู้เชี่ยวชาญด้านแพลตฟอร์ม OpenShift และ Kubernetes ที่มีความรู้เชิงลึกเกี่ยวกับสถาปัตยกรรมคลัสเตอร์ โอเปอเรเตอร์ เครือข่าย พื้นที่จัดเก็บข้อมูล การแก้ไขปัญหา และไปป์ไลน์ CI/CD ใช้…
official
find-token
openshift
ค้นหาโทเค็นการยืนยันที่ซ่อนอยู่ รันสคริปต์ find-token เพื่อดึงโทเค็นที่ไม่ซ้ำกัน
official
code-review
openshift
ตรวจสอบ pull request เพื่อดูคุณภาพโค้ด ความถูกต้อง และความสอดคล้องกับข้อกำหนดของโปรเจกต์ ใช้เมื่อผู้ใช้ขอให้ตรวจสอบ PR, ตรวจสอบโค้ด หรือตรวจสอบการเปลี่ยนแปลงใน...
official
css-review
openshift
ตรวจสอบ CSS สำหรับรูปแบบการเขียนโค้ด การใช้โทเค็น PatternFly และแนวปฏิบัติที่ดีที่สุด ใช้เมื่อผู้ใช้ขอให้ตรวจสอบ CSS ตรวจสอบสไตล์ หรือตรวจสอบไฟล์ CSS
official
review-readmes
openshift
ตรวจสอบไฟล์ README.md ทั้งหมดใน repo เพื่อหาคำผิด ข้อผิดพลาด และข้อมูลที่ล้าสมัย ใช้เมื่อผู้ใช้ขอให้ตรวจสอบ README ตรวจสอบความถูกต้องของเอกสาร หรือ…
official
review-skills
openshift
ตรวจสอบทักษะ AI ของโครงการเพื่อหาความซ้ำซ้อน การอ้างอิงที่ล้าสมัย ข้อผิดพลาด และปัญหาเชิงโครงสร้าง ใช้เมื่อผู้ใช้ขอให้ตรวจสอบทักษะ ตรวจสอบทักษะ ตรวจสอบหา…
official
test
openshift
รันการทดสอบแบบ end-to-end ที่กรองตามแท็ก ใช้เมื่อผู้ใช้ขอให้รันการทดสอบ รัน Playwright หรือทดสอบฟีเจอร์เฉพาะแท็ก เช่น @core หรือ @attach
official
unused-exports
openshift
ค้นหาสัญลักษณ์ที่ถูกส่งออกแต่ไม่เคยถูกนำเข้าโดยไฟล์อื่น ใช้เมื่อผู้ใช้พูดว่า "ตรวจสอบการส่งออก" "ส่งออกที่ไม่ได้ใช้" หรือขอให้ทำความสะอาดการส่งออก
official