From c223778a86ab423d6ff514d97ddd9a348210cdfb Mon Sep 17 00:00:00 2001 From: Harish R S Date: Sun, 10 May 2026 00:37:37 +0530 Subject: [PATCH] ci: add go test, go vet, and staticcheck gates to build-verify workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CI pipeline only compiled binaries — tests, go vet, and static analysis never ran on any PR. This allowed real bugs to ship undetected: - req.Body/resp.Body mismatch (PR #338) caught by go vet - panic(err.Error()) in connectors (PR #341, #319) caught by staticcheck - TestDeleteContext failing on clean checkout (PR #334) caught by go test - fmt.Errorf result discarded in watcher/executor.go caught by go vet (fixed here) Add three mandatory steps before the build: go test ./..., go vet ./..., and staticcheck via dominikh/staticcheck-action. Also add make test and make vet targets for local developer use. Also fix the go vet finding in pkg/watcher/executor.go where fmt.Errorf was called but its return value was discarded, silently swallowing errors. Fixes #355 Signed-off-by: Harish R S --- .github/workflows/build-verify.yml | 12 ++++++++++++ Makefile | 10 +++++++++- pkg/watcher/executor.go | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-verify.yml b/.github/workflows/build-verify.yml index aa11852..8756d78 100644 --- a/.github/workflows/build-verify.yml +++ b/.github/workflows/build-verify.yml @@ -36,6 +36,18 @@ jobs: go-version-file: ./go.mod cache-dependency-path: ./go.sum + - name: Run unit tests + run: go test ./... + + - name: Run go vet + run: go vet ./... + + - name: Run staticcheck + uses: dominikh/staticcheck-action@v1.3.0 + with: + version: latest + install-go: false + - name: Build Go packages run: | make clean diff --git a/Makefile b/Makefile index 11f799a..e7da568 100644 --- a/Makefile +++ b/Makefile @@ -27,4 +27,12 @@ build-binaries: .PHONY: build-watcher build-watcher: - go build -o ${DIST_DIR}/${BIN_NAME}-${WATCHER_NAME} ${PACKAGE}/watcher \ No newline at end of file + go build -o ${DIST_DIR}/${BIN_NAME}-${WATCHER_NAME} ${PACKAGE}/watcher + +.PHONY: test +test: + go test ./... + +.PHONY: vet +vet: + go vet ./... \ No newline at end of file diff --git a/pkg/watcher/executor.go b/pkg/watcher/executor.go index 3347fc6..3c42fca 100644 --- a/pkg/watcher/executor.go +++ b/pkg/watcher/executor.go @@ -12,7 +12,8 @@ func TriggerImport(entry config.WatchEntry) { // Retrieve config to get client options. cfgPath, err := config.DefaultLocalConfigPath() if err != nil { - fmt.Errorf("Error while loading config: %s", err.Error()) + fmt.Printf("Error while loading config: %s\n", err.Error()) + return } fmt.Println("[INFO] Re-importing changed file: " + entry.FilePath)