chore: refresh CI tooling and wire up golangci-lint#14
Merged
Conversation
CI freshness pass on a repo that had drifted while untouched. Linting: - Migrate .golangci.yml from v1 to v2 schema (golangci-lint v2). - Wire golangci-lint into the CI lint job via golangci-lint-action@v8 (the config existed but was never run); drop the now-redundant manual gofmt/vet steps since v2 covers both. - Fix all findings the linter surfaced on its first run: errcheck (unchecked errors, incl. response-body Close and cookie Save), gosec (cookie file perms 0600, int-overflow shift, caller-controlled file read), govet shadowing, misspell (cancelled->canceled), prealloc, predeclared, gocritic exitAfterDefer, and godot comment style. - Refactor over-long functions (funlen): extract per-attempt request logic in GetOrderLedger (also fixes a latent defer-in-loop on resp.Body.Close), split GetOrder/GetPurchaseHistory response handling into helpers, and break the CLI main() into per-command handlers. CI versions/actions: - Test matrix now covers Go 1.21 (go.mod floor), 1.25, 1.26; single-version jobs pinned to 1.26 via a GO_VERSION env. - Drop redundant actions/cache@v3 step (setup-go@v5 caches natively). - Bump deprecated actions: upload-artifact@v3->v4, codeql-action upload-sarif@v2->v3, softprops/action-gh-release@v1->v2. Verified locally: go build, go test -race, golangci-lint run (0 issues), gofmt, go vet, go mod verify, and actionlint on the workflows all pass.
Covers the two largest gaps left after the CI refresh, including the code paths touched by the funlen refactors. - internal/cookies (0% -> ~82%): curl cookie extraction, store set/get/count, GetAll snapshot independence, save/load round-trip, load error paths, and an assertion that saved cookie files are 0600. - orders.go (GetOrder and friends): success, delivery tip calculation, 403/418/429/500 status branches, malformed and empty payloads, GetOrderAutoDetect (first-try success and both-modes failure), and GetOrderAsJSON. Exercises the extracted parseOrderResponse / checkOrderResponseError helpers. - purchases.go (GetPurchaseHistory and friends): success, status branches, malformed payload, GetRecentOrders, cursor-based pagination in GetAllOrders, SearchOrders, GetOrdersByType, and GetOrdersAsJSON. Root package coverage rises from ~40% to ~73%. Tests mirror the existing orderledger_test.go style (table-driven, httptest.Server via testTransport) and keep cookie writes under t.TempDir().
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
===========================================
+ Coverage 38.31% 56.00% +17.69%
===========================================
Files 9 9
Lines 817 857 +40
===========================================
+ Hits 313 480 +167
+ Misses 488 335 -153
- Partials 16 42 +26
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan