Skip to content

Add ways to let users verify if new CLI released #1416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 31, 2021

Conversation

silvanocerza
Copy link
Contributor

@silvanocerza silvanocerza commented Aug 26, 2021

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?

Adds a new feature and change behaviour of an existing command.

  • What is the current behavior?

Users are never notified of new releases of the Arduino CLI.

  • What is the new behavior?

If more than 24 hours have passed since the last check the Arduino CLI verifies if the currently executed version is the latest available, if not it notifies the user that a new release is available. e.g.

$ arduino-cli core list            
ID                  Installed Latest Name                                        
arduino:samd        1.8.10    1.8.11 Arduino SAMD Boards (32-bits ARM Cortex-M0+)
esp32:esp32         1.0.6     1.0.6  esp32                                       
SPRESENSE:spresense 2.0.2     2.2.1  Spresense Reference Board                   



A new release of arduino-cli is available: 0.18.0 → 0.18.3
https://arduino.github.io/arduino-cli/latest/installation/#latest-packages

$ arduino-cli version
arduino-cli alpha Version: 0.18.0 Commit: 6507e27c Date: 2021-08-26T13:57:48Z


A new release of arduino-cli is available: 0.18.0 → 0.18.3
https://arduino.github.io/arduino-cli/latest/installation/#latest-packages

$ arduino-cli version --format json
{
  "Application": "arduino-cli",
  "VersionString": "0.18.0",
  "LatestVersion": "0.18.3",
  "Commit": "6507e27c",
  "Status": "alpha",
  "Date": "2021-08-26T13:57:48Z"
}

The message is printed on the stderr output so it won't disrupt existing parsers and the JSON output.

This behaviour you can disable it by setting the updater.disable_notification config or the env var ARDUINO_UPDATER_DISABLE_NOTIFICATION to true.

arduino-cli version command will always force a check for new versions even if the above config or env var are set.

Nope.

  • Other information:

Heavily inspired by https://github.com/cli/cli.


See how to contribute

@silvanocerza silvanocerza requested a review from a team August 26, 2021 11:24
@silvanocerza silvanocerza self-assigned this Aug 26, 2021
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch 3 times, most recently from 00e71bf to 9596a7c Compare August 26, 2021 11:33
@silvanocerza silvanocerza changed the title Add period check to notify users of new CLI releases Add periodical check to notify users of new CLI releases Aug 26, 2021
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch 4 times, most recently from 6cc3694 to 2af3de5 Compare August 26, 2021 14:11
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch from 52f32bf to f0cab1b Compare August 26, 2021 15:39
@silvanocerza silvanocerza changed the title Add periodical check to notify users of new CLI releases Add ways to let users verify if new CLI released Aug 26, 2021
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch from f0cab1b to 78a8ba4 Compare August 30, 2021 14:53
updaterMessageChan <- nil
}
// Starts checking for updates
currentVersion, err := semver.Parse(globals.VersionInfo.VersionString)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is VersionString supposed to be always semver compliant? if yes you can use semver.MustParse to avoid checking the error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not always semver compliant, it can also be git-snapshot or nightly-<timestamp> so I can't use semver.MustParse.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't those versions be changed to 0.0.0-git or 0.0.0-nightly-<timestamp>?
These non-semver versions plugged in feels "wrong" to me...

Also we already had:

var (
	defaultVersionString = "0.0.0-git"
	versionString        = ""
	commit               = ""
	status               = "alpha"
	date                 = ""
	tr                   = i18n.Tr
)

in version.go IMHO we should follow the same pattern and force semver compliance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get what you mean but probably would be better if done in a separate PR.


// getLatestRelease queries the official Arduino download server for the latest release,
// if there are no errors or issues a version string is returned, in all other case an empty string.
func getLatestRelease() string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make this function return a *semver.Version (or nil if fails or not valid semver)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that would help that much, this getLatestRelease is only used in checkForUpdate and there we handle eventual errors in parsing the version string, if I change getLatestRelease to return a *semver.Version I'd have to check for the parsing error inside it and handle the nil version in checkForUpdate too.

Don't seem much of an improvement to me really. 🤔

color.YellowString(tr("A new release of Arduino CLI is available:")),
color.CyanString(globals.VersionInfo.VersionString),
color.CyanString(latestVersion),
color.YellowString("https://arduino.github.io/arduino-cli/latest/installation/#latest-packages"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this URL going to stay? Will it move at some point from arduino.github.io to arduino.cc/something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'll change it in the future when the Arduino CLI will be added to https://www.arduino.cc/en/software.

Comment on lines +46 to +51
if strings.Contains(globals.VersionInfo.VersionString, "git-snapshot") || strings.Contains(globals.VersionInfo.VersionString, "nightly") {
// We're using a development version, no need to check if there's a
// new release available
feedback.Print(globals.VersionInfo)
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is sensible here... I'd leave the version command to always check for the latest version (even in dev builds)

Suggested change
if strings.Contains(globals.VersionInfo.VersionString, "git-snapshot") || strings.Contains(globals.VersionInfo.VersionString, "nightly") {
// We're using a development version, no need to check if there's a
// new release available
feedback.Print(globals.VersionInfo)
return
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't, it would fail because globals.VersionInfo.VersionString can't be parsed as semver.

Co-authored-by: Cristian Maglie <[email protected]>
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch from 5fe844c to cf4d75a Compare August 30, 2021 15:49
@silvanocerza silvanocerza merged commit bc998ed into master Aug 31, 2021
@silvanocerza silvanocerza deleted the scerza/update-checker branch August 31, 2021 08:16
@rsora rsora added the topic: CLI Related to the command line interface label Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants