Skip to content

feat: add non-blocking version update check (#104)#214

Merged
spboyer merged 3 commits into
mainfrom
squad/104-version-check
Apr 21, 2026
Merged

feat: add non-blocking version update check (#104)#214
spboyer merged 3 commits into
mainfrom
squad/104-version-check

Conversation

@spboyer
Copy link
Copy Markdown
Member

@spboyer spboyer commented Apr 21, 2026

Summary

Closes #104. Adds a non-blocking version check that runs in the background on every command. If a newer waza version exists, prints a one-line notice after command output.

Changes

New: internal/version/ package

  • Checker — async version check against GitHub releases API (goroutine)
  • 24h cache in ~/.waza/version-check.json to avoid API hits
  • PrintNotice() — prints upgrade notice to stderr
  • Functional options: WithHTTPClient, WithCacheDir, WithAPIBaseURL, WithRepo
  • Filters azd-ext-* tags; only checks v-prefixed CLI releases
  • Graceful on all failures: API errors, timeouts, corrupt cache, dev builds → silent nil

Modified: cmd/waza/root.go

  • PersistentPreRun: starts background checker (unless --no-update-check or WAZA_NO_UPDATE_CHECK)
  • PersistentPostRun: prints notice if update available (100ms max wait — never blocks)

Docs

  • CLI reference: new --no-update-check flag, WAZA_NO_UPDATE_CHECK env var, "Automatic Update Check" section
  • README: "Update Notifications" section
  • Site builds clean

Tests (18 total)

  • Newer version available / current / ahead
  • Dev version skipped
  • Cache hit / cache expired / cache dir auto-created / invalid cache JSON
  • API failure / API timeout / context cancelled
  • azd-ext tag filtering / no releases
  • PrintNotice: nil, no update, update available, custom install cmd
  • Semver parsing: v-prefix, bare, invalid

Non-blocking guarantee

The check runs in a goroutine. Result() waits at most 100ms. If the check hasn't finished, it returns nil and the command output is unaffected.

Add automatic version check that runs in the background on every command.
If a newer version is available, prints a one-line notice after output.

- New internal/version package with Checker (async GitHub API check),
  24h cache in ~/.waza/version-check.json, and PrintNotice helper
- Functional options pattern (WithHTTPClient, WithCacheDir, WithAPIBaseURL)
- --no-update-check flag and WAZA_NO_UPDATE_CHECK env var to disable
- Filters azd-ext-* tags, only checks v-prefixed CLI releases
- Graceful on all failures: API errors, timeouts, bad cache, dev builds
- 18 tests covering: newer/current/ahead versions, cache hit/expired,
  API failure/timeout, azd-ext tag filtering, context cancellation
- Updated CLI reference, README, docs site

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot enabled auto-merge (squash) April 21, 2026 21:36
Copilot AI added 2 commits April 21, 2026 17:39
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix gofmt formatting (tabs vs spaces from heredoc creation)
- Handle resp.Body.Close() error return (errcheck)
- Handle w.Close() error return in tests (errcheck)
- Fix 'cancelled' → 'canceled' spelling (misspell)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer spboyer merged commit 4f4bea7 into main Apr 21, 2026
6 checks passed
@spboyer spboyer deleted the squad/104-version-check branch April 21, 2026 21:50
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.

Add a mechanism to notify users that new versions of WAZA are avaiable.

2 participants