ci(sdk-go): add CI workflow and fix test helper#22
Conversation
Add GitHub Actions CI workflow for the Go SDK with lint (go vet + golangci-lint), tests across Go 1.21-1.23 with race detection, coverage reporting, and build verification. Also rename client_test_helpers.go to client_test_helpers_test.go so it can access test-only types (testServer, validAPIKey) defined in other _test.go files. Without this fix, the package fails to compile under `go test`.
Suppress unchecked error returns flagged by errcheck: - resp.Body.Close() in transport.go wrapped in defer closure - json.NewEncoder().Encode() calls in test server handlers - client.Shutdown() calls in defer statements across all test files - Replace nil context with context.TODO() in test helper
There was a problem hiding this comment.
Pull request overview
Adds a dedicated GitHub Actions workflow to run CI for the Go SDK and updates Go transport/tests to satisfy errcheck (and fix a test helper compilation/access issue via _test.go naming).
Changes:
- Add
.github/workflows/sdk-go.ymlto run linting, tests (Go 1.21–1.23, race), coverage output, and build verification forsdks/go. - Update Go transport + tests to explicitly handle previously-ignored error returns (
Close(),Encode(),Shutdown()). - Rename/add Go test helper file as
_test.goso test-only declarations are visible to other_test.gofiles.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
sdks/go/logwell/transport_test.go |
Ignore/handle JSON encoder errors in test HTTP handlers to satisfy errcheck. |
sdks/go/logwell/transport.go |
Ignore/handle resp.Body.Close() return value to satisfy errcheck. |
sdks/go/logwell/client_test_helpers_test.go |
Fix Shutdown(nil) by passing a context and make helpers available to other tests. |
sdks/go/logwell/client_test.go |
Ignore/handle Shutdown() and JSON encoder errors to satisfy errcheck. |
.github/workflows/sdk-go.yml |
Introduce Go SDK CI workflow (lint/test/coverage/build). |
Comments suppressed due to low confidence (1)
sdks/go/logwell/client_test_helpers_test.go:123
- This test helper uses
context.TODO()for Shutdown. Elsewhere in the Go SDK tests, Shutdown is consistently called withcontext.Background(). Using Background here would keep context usage consistent and avoid TODO-style placeholders in test code.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Check go.mod is tidy | ||
| run: | | ||
| go mod tidy | ||
| git diff --exit-code go.mod |
There was a problem hiding this comment.
The “Check go.mod is tidy” step only fails on changes to go.mod, but go mod tidy can also modify go.sum. This can let an untidy go.sum slip through CI. Consider checking both go.mod and go.sum (or just git diff --exit-code after running tidy) so the job fails if either file changes.
| git diff --exit-code go.mod | |
| git diff --exit-code go.mod go.sum |
Add GitHub Actions CI workflow for the Go SDK with lint (go vet + golangci-lint), tests across Go 1.21-1.23 with race detection, coverage reporting, and build verification.
Also rename client_test_helpers.go to client_test_helpers_test.go to fix compilation by allowing access to test-only declarations in other _test.go files.
And fix all errcheck violations from golangci-lint by properly handling unchecked error returns in transport and test code.