CI: no coverage report; integration tests and scanners not separable

Đang mở
#53 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, github-actions, go
Lĩnh vực
ci-cd, devops, testing

Hướng nghiên cứu

Start with .github/workflows/ci.yml (the test and sandbox jobs) and Makefile, then read the TestIntegration* guards in internal/sandbox/integration_test.go and internal/engine/integration_test.go. Done means the coverage figure is published in CI, make test-short skips the container tests, and TestExternalScannersInstalled in internal/seed/external_test.go can be run against installed scanners. The scanner and CI parts need maintainer input on pinned versions and coverage floors before work starts.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

ci severity: low

Summary

CI reports no coverage, container integration tests cannot be excluded from a plain make test, and the external scanner adapters are never run against the real tools.

Where

  • .github/workflows/ci.yml:40
  • .github/workflows/ci.yml:73
  • internal/sandbox/integration_test.go:19
  • internal/engine/integration_test.go:55
  • internal/bench/run_test.go:381
  • Makefile:22
  • internal/seed/external_test.go:410
  • internal/seed/external_test.go:415
  • internal/seed/external_test.go:433
  • .github/workflows/ci.yml:41

Details

No workflow, Makefile target or make.ps1 target produces a coverage profile (a search for coverprofile, codecov and coverage in .github, Makefile, make.ps1 and action.yml finds only rm -rf ... coverage.out in clean). Coverage therefore fell to 30.0% for internal/cli and 52.8% for internal/gitx with nothing reporting it. Separately, the 13 TestIntegration* tests have no build tag and no testing.Short() guard (sandbox/integration_test.go:19-32, engine/integration_test.go:55-73); they run in every plain go test ./... on a machine with Docker, and the Linux test job runs them twice per push (once in test, once in sandbox). In this audit's run they took 9 to 19 seconds each (internal/sandbox 58 s in total), and TestRunDeterministicRealCorpus took 50 s; only that test and the scanner test honor -short (bench/run_test.go:381, seed/external_test.go:418). There is no documented fast loop: CONTRIBUTING.md:65 and AGENTS.md:16 give only make test.

TestExternalScannersInstalled runs each adapter only when its binary is on PATH and skips otherwise (external_test.go:415-417); for semgrep, osv-scanner and trivy a failed run is also turned into a skip (433-435). No workflow installs any of the five scanners, and there is no equivalent of SPACKLE_REQUIRE_RUNTIME for them, so in CI all five subtests skip on every run. In this audit's run 4 of 5 skipped (only gitleaks is installed here). The rest of external_test.go checks parsers against JSON written by hand in the test file.

Impact

Coverage gaps like the ones above appear without notice. Local make test takes several minutes on a developer machine with Docker running, which discourages running it.

The command lines Spackle builds (external.go, 837 lines) and the output shapes it parses are pinned only to hand-written samples. A scanner release that renames a flag or a JSON field makes the adapter fail or return nothing for users, and CI stays green. A missing lead source is a silent loss of recall.

Suggested fix

(1) In the Linux test job add -coverprofile=coverage.out -coverpkg=./internal/... to one matrix cell, print go tool cover -func to the job summary, and fail when the total or a named package (internal/cli, internal/gitx, internal/engine) drops below an agreed floor. (2) Make the integration tests skip under -short (add the check to integrationRuntime and to TestIntegrationRealSandboxProofAndFix, but keep SPACKLE_REQUIRE_RUNTIME=1 overriding it), add a test-short target to Makefile and make.ps1 running go test -short -shuffle=on ./..., and document it and the single-test form (go test -run TestName ./internal/pkg) in CONTRIBUTING.md. (3) Run the matrix test job with -short on Linux so the container tests run once, in the sandbox job.

Add a scheduled and manually triggered Linux job that installs pinned versions of gitleaks, hadolint, semgrep, osv-scanner and trivy and runs go test -run TestExternalScannersInstalled ./internal/seed with a new SPACKLE_REQUIRE_SCANNERS=1 that turns both skips into failures (mirroring integration_test.go:25-27). In that mode also assert a minimum result per tool on the planted tree: semgrep reports the os.system call, hadolint reports the latest tag or root user, gitleaks reports the planted token (already asserted at external_test.go:440). Save one real output file per pinned scanner version under internal/seed/testdata/ and feed it to the existing parser tests so parser regressions are caught on every PR without the tools.

Acceptance criteria

  • CI publishes a coverage figure
  • A short-mode or tag separates container tests
  • One CI job runs the adapters against installed scanners
  • make lint, make test and make build pass

Getting started

  • Relevant files: .github/workflows/ci.yml, internal/sandbox/integration_test.go, internal/engine/integration_test.go, internal/bench/run_test.go, Makefile, internal/seed/external_test.go
  • How to run tests: make test (Unix) or .\make.ps1 test (Windows PowerShell); lint with make lint
  • Related docs: CONTRIBUTING.md, AGENTS.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 35948f7. Severity: low. Effort: M. audit-key: ci|.github/workflows/ci.yml|jobs.test

Ngôn ngữ chính
Go
Star
0
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/Spackle

Tất cả issue của TMHSDigital/Spackle

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.