The Wayback Machine - https://web.archive.org/web/20210911023957/https://github.com/arduino/arduino-cli/pull/1416
Skip to content
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

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

Merged
merged 8 commits into from Aug 31, 2021
Merged

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 arduino/team_tooling Aug 26, 2021
@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 Aug 26, 2021
@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 Aug 26, 2021
cli/updater/updater.go Outdated Show resolved Hide resolved
cli/updater/updater.go Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
docs/installation.md Outdated Show resolved Hide resolved
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch from 52f32bf to f0cab1b Aug 26, 2021
@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
cli/updater/updater.go Outdated Show resolved Hide resolved
cli/updater/updater.go Outdated Show resolved Hide resolved
cli/version/version.go Outdated Show resolved Hide resolved
docs/installation.md Outdated Show resolved Hide resolved
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch from f0cab1b to 78a8ba4 Aug 30, 2021
updaterMessageChan <- nil
}
// Starts checking for updates
currentVersion, err := semver.Parse(globals.VersionInfo.VersionString)

This comment has been minimized.

@cmaglie

cmaglie Aug 30, 2021
Member

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

This comment has been minimized.

@silvanocerza

silvanocerza Aug 30, 2021
Author Contributor

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

This comment has been minimized.

@cmaglie

cmaglie Aug 30, 2021
Member

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.

This comment has been minimized.

@silvanocerza

silvanocerza Aug 31, 2021
Author Contributor

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 {

This comment has been minimized.

@cmaglie

cmaglie Aug 30, 2021
Member

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

This comment has been minimized.

@silvanocerza

silvanocerza Aug 30, 2021
Author Contributor

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"))

This comment has been minimized.

@cmaglie

cmaglie Aug 30, 2021
Member

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

This comment has been minimized.

@silvanocerza

silvanocerza Aug 30, 2021
Author Contributor

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

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
}
Comment on lines +46 to +51

This comment has been minimized.

@cmaglie

cmaglie Aug 30, 2021
Member

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
}

This comment has been minimized.

@silvanocerza

silvanocerza Aug 30, 2021
Author Contributor

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

cli/updater/updater.go Outdated Show resolved Hide resolved
Co-authored-by: Cristian Maglie <[email protected]>
@silvanocerza silvanocerza force-pushed the scerza/update-checker branch from 5fe844c to cf4d75a Aug 30, 2021
@silvanocerza silvanocerza merged commit bc998ed into master Aug 31, 2021
100 checks passed
100 checks passed
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
lint
Details
@github-actions
lint
Details
@github-actions
check
Details
@github-actions
check
Details
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
run-determination
Details
@github-actions
check-errors (./)
Details
@github-actions
check-errors (./)
Details
@github-actions
check
Details
@github-actions
check
Details
@github-actions
links
Details
@github-actions
links
Details
@github-actions
build
Details
@github-actions
build
Details
@github-actions
test (ubuntu-latest)
Details
@github-actions
test (ubuntu-latest)
Details
@github-actions
test (ubuntu-latest)
Details
@github-actions
test (ubuntu-latest)
Details
@github-actions
check-errors (arduino/discovery/discovery_client)
Details
@github-actions
check-errors (arduino/discovery/discovery_client)
Details
@github-actions
test (windows-latest)
Details
@github-actions
test (windows-latest)
Details
@github-actions
test (windows-latest)
Details
@github-actions
test (windows-latest)
Details
@github-actions
check-errors (client_example)
Details
@github-actions
check-errors (client_example)
Details
@github-actions
test (macos-latest)
Details
@github-actions
test (macos-latest)
Details
@github-actions
test (macos-latest)
Details
@github-actions
test (macos-latest)
Details
@github-actions
check-errors (commands/daemon/term_example)
Details
@github-actions
check-errors (commands/daemon/term_example)
Details
@github-actions
check-errors (docsgen)
Details
@github-actions
check-errors (docsgen)
Details
@github-actions
check-outdated (./)
Details
@github-actions
check-outdated (./)
Details
@github-actions
checksums artifact
Details
@github-actions
checksums artifact
Details
@github-actions
check-outdated (arduino/discovery/discovery_client)
Details
@github-actions
check-outdated (arduino/discovery/discovery_client)
Details
@github-actions
Linux_X86-32 artifact
Details
@github-actions
Linux_X86-32 artifact
Details
@github-actions
check-outdated (client_example)
Details
@github-actions
check-outdated (client_example)
Details
@github-actions
Linux_X86-64 artifact
Details
@github-actions
Linux_X86-64 artifact
Details
@github-actions
check-outdated (commands/daemon/term_example)
Details
@github-actions
check-outdated (commands/daemon/term_example)
Details
@github-actions
Linux_ARM64 artifact
Details
@github-actions
Linux_ARM64 artifact
Details
@github-actions
check-outdated (docsgen)
Details
@github-actions
check-outdated (docsgen)
Details
@github-actions
Linux_ARMv6 artifact
Details
@github-actions
Linux_ARMv6 artifact
Details
@github-actions
Linux_ARMv7 artifact
Details
@github-actions
Linux_ARMv7 artifact
Details
@github-actions
macOS_64 artifact
Details
@github-actions
macOS_64 artifact
Details
@github-actions
Windows_X86-32 artifact
Details
@github-actions
Windows_X86-32 artifact
Details
@github-actions
Windows_X86-64 artifact
Details
@github-actions
Windows_X86-64 artifact
Details
@github-actions
check-style (./)
Details
@github-actions
check-style (./)
Details
@github-actions
clean
Details
@github-actions
clean
Details
@github-actions
check-style (arduino/discovery/discovery_client)
Details
@github-actions
check-style (arduino/discovery/discovery_client)
Details
@github-actions
check-style (client_example)
Details
@github-actions
check-style (client_example)
Details
@github-actions
check-style (commands/daemon/term_example)
Details
@github-actions
check-style (commands/daemon/term_example)
Details
@github-actions
check-style (docsgen)
Details
@github-actions
check-style (docsgen)
Details
@github-actions
check-formatting (./)
Details
@github-actions
check-formatting (./)
Details
@github-actions
check-formatting (arduino/discovery/discovery_client)
Details
@github-actions
check-formatting (arduino/discovery/discovery_client)
Details
@github-actions
check-formatting (client_example)
Details
@github-actions
check-formatting (client_example)
Details
@github-actions
check-formatting (commands/daemon/term_example)
Details
@github-actions
check-formatting (commands/daemon/term_example)
Details
@github-actions
check-formatting (docsgen)
Details
@github-actions
check-formatting (docsgen)
Details
@github-actions
check-config (./)
Details
@github-actions
check-config (./)
Details
@github-actions
check-config (arduino/discovery/discovery_client)
Details
@github-actions
check-config (arduino/discovery/discovery_client)
Details
@github-actions
check-config (client_example)
Details
@github-actions
check-config (client_example)
Details
@github-actions
check-config (commands/daemon/term_example)
Details
@github-actions
check-config (commands/daemon/term_example)
Details
@silvanocerza silvanocerza deleted the scerza/update-checker branch Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants