Skip to content

chore: refresh CI tooling and wire up golangci-lint#14

Merged
eshaffer321 merged 10 commits into
mainfrom
chore/refresh-ci
Jun 8, 2026
Merged

chore: refresh CI tooling and wire up golangci-lint#14
eshaffer321 merged 10 commits into
mainfrom
chore/refresh-ci

Conversation

@eshaffer321

Copy link
Copy Markdown
Owner

Summary

  • Refresh CI tooling and wire up golangci-lint
  • Add coverage for cookies store and orders/purchases APIs

Test plan

  • CI passes

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

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.08434% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.00%. Comparing base (1656605) to head (8102829).

Files with missing lines Patch % Lines
ledger.go 81.42% 10 Missing and 3 partials ⚠️
orders.go 80.00% 7 Missing and 3 partials ⚠️
purchases.go 70.37% 5 Missing and 3 partials ⚠️
client.go 22.22% 5 Missing and 2 partials ⚠️
examples/basic/main.go 0.00% 4 Missing ⚠️
internal/cookies/store.go 0.00% 4 Missing ⚠️
examples/ledger/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
unittests 56.00% <71.08%> (+17.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/cookies/cookie.go 0.00% <ø> (-100.00%) ⬇️
models.go 94.28% <ø> (+45.71%) ⬆️
examples/ledger/main.go 0.00% <0.00%> (ø)
examples/basic/main.go 0.00% <0.00%> (ø)
internal/cookies/store.go 0.00% <0.00%> (-65.22%) ⬇️
client.go 32.28% <22.22%> (-1.87%) ⬇️
purchases.go 78.48% <70.37%> (+78.48%) ⬆️
orders.go 76.23% <80.00%> (+38.39%) ⬆️
ledger.go 77.57% <81.42%> (-1.00%) ⬇️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1656605...8102829. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eshaffer321 eshaffer321 merged commit 58729e0 into main Jun 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant