Skip to content

ci: add go test, go vet, and staticcheck gates to the build-verify workflow #355

@Harishrs2006

Description

@Harishrs2006

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 fix typo in DownloadArtifact: was reading req.Body instead of resp.Body #338 (go vet catches this)
  2. panic(err.Error()) in connector code → PR fix(connectors): use json.Marshal in CreateTestResult to prevent injection and panics #341, fix: return errors instead of panicking on response parsing in connectors #319 (staticcheck catches this)
  3. TestDeleteContext fails on every clean checkout → PR test: use temporary config file in context delete test #334 (go test ./... catches this)
  4. OAuth2 tokens printed unconditionally to stderr → PR fix(login): OAuth2 access and refresh tokens unconditionally leaked to stderr on SSO login #345 (caught by tests with log capture)
  5. String-concatenation JSON injection risk → PR fix(connectors): use json.Marshal in CreateTestResult to prevent injection and panics #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:

- 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 ./...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions