Skip to content

Let board listall return boards sorted with the same order as in the original boards.txt #1903

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 4 commits into from
Oct 4, 2022

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Oct 3, 2022

Please check if the PR fulfills these requirements

See how to contribute

  • 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?

The ordering of the boards returned by board listall is now the same as the order of definition in the boards.txt of the platform.

What is the current behavior?

The ordering is undefined (random):

$ arduino-cli board listall arduino:avr --format json | jq '.boards[] | .name'
"Arduino Industrial 101"
"Arduino Esplora"
"Arduino Robot Motor"
"Arduino Nano"
"Arduino Yún"
"Arduino Mini"
"Arduino Uno WiFi"
"Arduino Duemilanove or Diecimila"
"Arduino Uno Mini"
"Adafruit Circuit Playground"
"Arduino Gemma"
"LilyPad Arduino"
"Arduino Mega ADK"
"Arduino Leonardo ETH"
"Arduino Micro"
"Arduino Robot Control"
"Arduino Pro or Pro Mini"
"Linino One"
"Arduino Ethernet"
"Arduino Mega or Mega 2560"
"Arduino Fio"
"Arduino BT"
"Arduino Leonardo"
"Arduino NG or older"
"Arduino Yún Mini"
"Arduino Uno"
"LilyPad Arduino USB"

What is the new behavior?

The ordering is the same as in the boards.txt

$ arduino-cli board listall arduino:avr --format json | jq '.boards[] | .name'
"Arduino Yún"
"Arduino Uno"
"Arduino Uno Mini"
"Arduino Duemilanove or Diecimila"
"Arduino Nano"
"Arduino Mega or Mega 2560"
"Arduino Mega ADK"
"Arduino Leonardo"
"Arduino Leonardo ETH"
"Arduino Micro"
"Arduino Esplora"
"Arduino Mini"
"Arduino Ethernet"
"Arduino Fio"
"Arduino BT"
"LilyPad Arduino USB"
"LilyPad Arduino"
"Arduino Pro or Pro Mini"
"Arduino NG or older"
"Arduino Robot Control"
"Arduino Robot Motor"
"Arduino Gemma"
"Adafruit Circuit Playground"
"Arduino Yún Mini"
"Arduino Industrial 101"
"Linino One"
"Arduino Uno WiFi"

Does this PR introduce a breaking change, and is titled accordingly?

No

@cmaglie cmaglie self-assigned this Oct 3, 2022
@cmaglie cmaglie added type: enhancement Proposed improvement priority: medium Resolution is a medium priority topic: code Related to content of the project itself criticality: medium Of moderate impact labels Oct 3, 2022
@codecov
Copy link

codecov bot commented Oct 3, 2022

Codecov Report

Base: 36.71% // Head: 36.72% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (d95e9fa) compared to base (e404a3b).
Patch coverage: 90.90% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1903   +/-   ##
=======================================
  Coverage   36.71%   36.72%           
=======================================
  Files         231      231           
  Lines       19723    19724    +1     
=======================================
+ Hits         7242     7244    +2     
+ Misses      11652    11648    -4     
- Partials      829      832    +3     
Flag Coverage Δ
unit 36.72% <90.90%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
commands/board/listall.go 0.00% <0.00%> (ø)
arduino/cores/cores.go 62.17% <100.00%> (+0.59%) ⬆️
arduino/cores/packagemanager/loader.go 72.21% <100.00%> (-0.10%) ⬇️
arduino/cores/packagemanager/package_manager.go 65.82% <0.00%> (-0.76%) ⬇️
arduino/cores/packagemanager/download.go 27.71% <0.00%> (+4.81%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@umbynos umbynos left a comment

Choose a reason for hiding this comment

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

Code LGTM, let's wait for a review by @AlbyIanna, build artifact here

@AlbyIanna
Copy link

I tested the command as described in the PR description and it works fine.
I have one more request though: would it be possible to get the boards listed in the same way when using the board details command? I'm asking it because the Arduino IDE is using the board details command (instead of listall) to get the list. This allows us to call the CLI only once to get other valuable data.

@cmaglie does it make sense to you? Otherwise we could just call the arduino-cli twice, once to get the ordered list and another time to get the other data.

@cmaglie
Copy link
Member Author

cmaglie commented Oct 3, 2022

Actually, the BoardDetails request returns details about one board, because you must specify the FQBN of that board:

message BoardDetailsRequest {
  // Arduino Core Service instance from the `Init` response.
  Instance instance = 1;
  // The fully qualified board name of the board you want information about
  // (e.g., `arduino:avr:uno`).
  string fqbn = 2;
}

this means that the IDE obtains the FQBN in some other ways (for example with a BoardListAll request or similar).
BTW I can extend the ordering to other calls too, but not the BoardDetails since it returns the details of just one board and there is nothing to sort there :-).

@AlbyIanna
Copy link

Sorry @cmaglie, my bad. You are right, we use the BoardDetails request for doing another thing.

We are actually using the BoardSearch request to get those packages.

I can easily make a change to use listall instead.

Thank you @cmaglie !

Copy link

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

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

I gave the build a try with the IDE 2 and this was the result:
Screenshot 2022-10-04 at 10 51 36

Which, to me, looks pretty similar to the IDE 1 listing:
Screenshot 2022-10-04 at 10 51 46

LGTM 🚀
Thanks @cmaglie !

@cmaglie cmaglie merged commit 3d5a87e into arduino:master Oct 4, 2022
@cmaglie cmaglie deleted the fix_board_list_order branch October 4, 2022 08:59
@cmaglie cmaglie linked an issue Oct 6, 2022 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
criticality: medium Of moderate impact priority: medium Resolution is a medium priority topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sort boards as defined in the platform configuration file
3 participants