feat: tell of a newer release once a day, at a terminal - #74
Merged
Merged
Conversation
npm used to tell people when a new version was out; a downloaded binary stays as it is, so users would not notice releases. At most once a day the CLI asks where GitHub's latest-release redirect points, which costs none of the API's rate limit, and caches the answer in ~/.steadybit. A newer release is shown on stderr after the command, with `brew upgrade steadybit` for Homebrew installs. It stays quiet where nobody would read it or where it would get in the way: when stderr is not a terminal, in CI, during completion, for builds that are not releases, and with STEADYBIT_NO_UPDATE_CHECK set. A command waits for the check at most a second, once a day, and offline the check is not retried until the next day.
- The request gives up after 800 ms, earlier than the command's 1 s wait, so a request that runs out of time behind a firewall is still recorded before the command ends; before, every later command could wait again. - The cache is replaced through a renamed temporary file, so a command ending mid-write, or two running at once, never leave a broken file. - A check dated in the future, from a wrong clock or a copied cache, is due instead of trusted until the clock catches up. - Completion skips the check wherever global flags put it in the arguments (`--profile x completion zsh`, `-v __complete ...`), not only first. - STEADYBIT_NO_UPDATE_CHECK=0 or false no longer turns the check off. - The container image sets STEADYBIT_NO_UPDATE_CHECK: each run starts fresh, often in a pipeline whose CI variables are not passed in, and is updated by pulling an image, so the check would only ask GitHub every time and advise the wrong thing. - The cache path comes from the config package, which owns ~/.steadybit. - Tests no longer depend on how fast a refused connection fails, which on Windows takes longer than the check waits.
# Conflicts: # CHANGELOG.md
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
With npm gone, nothing tells people a new CLI release is out: a downloaded binary stays as it is.
Behaviour
https://github.com/steadybit/cli/releases/latestredirects. That costs nothing against the GitHub API's rate limit. It caches the answer in~/.steadybit/update-check.json.CI,JENKINS_URL,TF_BUILDorBUILDKITEvariables are set;completionor__complete;go install …@main, dev builds);STEADYBIT_NO_UPDATE_CHECKis set.Testing
go test -race ./...andgo vet(alsoGOOS=windows) pass.CI=true, or forcompletion;brew upgrade steadybit.