Record the approved design to add go vet and pinned staticcheck jobs to PR CI with minimal workflow changes.
2.6 KiB
2.6 KiB
Design: Issue #18 — Add go vet and staticcheck to CI
Context
Issue #18 requires expanding PR CI validation for this Go repository beyond existing gofmt and go test checks.
Current state:
- CI is defined in
.gitea/workflows/ci.yml. - Existing jobs:
fmt(gofmt -l .) andtest(go test ./...). - No
go vetorstaticcheckstep exists.
Goal
Add practical baseline static analysis to pull request CI by:
- Running
go vet ./.... - Running
staticcheck ./.... - Pinning
staticcheckversion in CI for deterministic behavior.
Non-goals
- Adding
golangci-lint. - Refactoring application code unrelated to CI wiring.
- Changing workflow triggers.
Approved approach
Use separate CI jobs for vet and staticcheck while keeping existing fmt and test jobs unchanged.
Why this approach
- Keeps changes surgical and easy to review.
- Makes failures explicit per check (better debugging signal than a combined lint step).
- Preserves current CI behavior while extending validation coverage.
Implementation design
Modify .gitea/workflows/ci.yml only.
Job: vet
runs-on: linux- Steps:
actions/checkout@v4actions/setup-go@v5withgo-version-file: go.modrun: go vet ./...
Job: staticcheck
runs-on: linux- Steps:
actions/checkout@v4actions/setup-go@v5withgo-version-file: go.mod- Install pinned staticcheck version:
go install honnef.co/go/tools/cmd/staticcheck@2025.1.1
- Run staticcheck:
$(go env GOPATH)/bin/staticcheck ./...
Failure behavior
- CI must fail if
go vet ./...exits non-zero. - CI must fail if
staticcheck ./...exits non-zero. - Existing
fmtandtestfailure behavior remains unchanged.
Verification plan
Local verification before PR creation:
gofmt -l .go test ./...go vet ./...staticcheck ./...(if tool is available locally)
CI verification through PR run:
- Confirm
fmt,test,vet, andstaticcheckjobs execute on pull requests. - Confirm non-zero from
vet/staticcheckmarks workflow failed.
Risks and mitigations
- Risk: pinned staticcheck version not present in runner cache.
- Mitigation: install in-job via
go installeach run.
- Mitigation: install in-job via
- Risk: staticcheck findings on current code block CI.
- Mitigation: if encountered, address only findings required to satisfy issue scope.
Acceptance mapping
- CI fail on vet errors →
vetjob runsgo vet ./.... - CI fail on staticcheck errors →
staticcheckjob runs pinned staticcheck binary. - Existing checks preserved →
fmtandtestjobs remain in workflow. - No
golangci-lint→ not introduced in workflow.