microcks / microcks/microcks-cli
ci: add go test, go vet, and staticcheck gates to the build-verify workflow
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 52
- Fork
- 68
- Merge medio
- 6h 54m
- PR unite (30g)
- 10
Descrizione
### Reason/Context
The current `build-verify.yml` CI workflow only compiles binaries — it never runs tests, go vet, or any static analysis. This means bugs ship silently and contributors get no automated feedback on correctness.
Proof from the current open PR queue — every one of these bugs existed in `master` and CI never caught them:
1) `req.Body` read instead of `resp.Body` in `DownloadArtifact` → PR #338 (`go vet` catches this)
2) `panic(err.Error())` in connector code → PR #341, #319 (`staticcheck` catches this)
3) `TestDeleteContext` fails on every clean checkout → PR #334 (`go test ./...` catches this)
4) OAuth2 tokens printed unconditionally to stderr → PR #345 (caught by tests with log capture)
5) String-concatenation JSON injection risk → PR #341 (`staticcheck` catches this)
The motivation: CI should be the first line of defence. Right now it is not.
### Description
Add three mandatory quality gates to `build-verify.yml` that run on every PR and push:
1) `go test ./...` — runs the existing unit test suite (currently never executed in CI)
2) `go vet ./...` — Go's built-in analyser, catches real bugs like wrong body reads, bad panic arguments, printf mismatches
3) `staticcheck` — industry-standard linter, zero config, no false positives
Also add `make test` and `make vet` targets to `Makefile` so contributors can run the same checks locally before pushing.
This is not a breaking change — it only adds new CI steps. If existing tests are currently failing on master,
those failures will need to be fixed as part of this PR.
### Implementation ideas
Add before the existing `Build Go packages` step in `.github/workflows/build-verify.yml`:
```yaml
- name: Run unit tests
run: go test ./...
- name: Run go vet
run: go vet ./...
- name: Run staticcheck
uses: dominikh/staticcheck-action@v1
with:
version: latest
install-go: false
`staticcheck` is preferred over `golangci-lint` — zero config, no false positives, directly catches the bug classes above.
Add to `Makefile`:
```makefile
.PHONY: test
test:
go test ./...
.PHONY: vet
vet:
go vet ./...
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Start with .github/workflows/build-verify.yml and the existing Build Go packages step, then inspect Makefile and run the proposed Go checks locally. Done means the workflow runs go test ./..., go vet ./..., and staticcheck on pushes and pull requests, with matching make test and make vet targets and all existing tests passing.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- github-actions, go
- Ambito
- build-system, ci-cd, testing
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 74/100