arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

Add first set of `profile` commands

Open MatteoPologruto opened this issue 6 months ago • 2 comments
trafficstars

Please check if the PR fulfills these requirements

See how to contribute

  • [x] The PR has no duplicates (please search among the Pull Requests before creating one)
  • [x] The PR follows our contributing guidelines
  • [x] 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)
  • [ ] configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Code enhancement

What is the current behavior?

Operations on the sketch.yaml project file must be done manually.

What is the new behavior?

First set of profile commands:

  1. profile init [<PATH>] [-m <PROFILE_NAME -b <FQBN>] [--default] creates a sketch.yaml file at the provided path. By default it creates the file in the current directory. A new profile can be added to the file by providing a profile name and FQBN (mandatory). The platform is detected automatically. If there is only one profile, it is automatically set as the default profile, otherwise the flag --default must be used. The command fails in the following cases:
    • the path does not exist or the main sketch file is missing
    • the FQBN is wrong or the platform related to it is not installed locally
  2. profile lib add <LIB_NAME@LIB_VERSION> [-m <PROFILE_NAME] [--dest-dir <PATH>] adds a library to the provided profile or to the default one. By default it checks for the sketch.yaml file in the current directory.
  3. profile lib remove <LIB_NAME> [-m <PROFILE_NAME] [--dest-dir <PATH>] removes a library from the provided profile or from the default one. By default it checks for the sketch.yaml file in the current directory.
  4. profile set-default <PROFILE_NAME> [--dest-dir <PATH>] sets the default profile to an existing profile. By default it checks for the sketch.yaml file in the current directory.
  5. profile dump [<PATH>] dumps the content of the sketch.yaml file. It supports the yaml and json formats.

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

Other information

MatteoPologruto avatar May 21 '25 15:05 MatteoPologruto

Codecov Report

:x: Patch coverage is 66.25000% with 216 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 68.29%. Comparing base (20e315c) to head (65354c4).

Files with missing lines Patch % Lines
commands/service_profile_lib_add.go 57.89% 30 Missing and 10 partials :warning:
internal/cli/profile/dump.go 20.93% 33 Missing and 1 partial :warning:
internal/arduino/sketch/profiles.go 52.94% 26 Missing and 6 partials :warning:
commands/service_profile_lib_list.go 0.00% 20 Missing :warning:
internal/cli/profile/lib.go 87.16% 16 Missing and 3 partials :warning:
commands/service_profile_dump.go 0.00% 16 Missing :warning:
commands/service_profile_lib_remove.go 54.54% 10 Missing and 5 partials :warning:
commands/service_profile_init.go 77.96% 9 Missing and 4 partials :warning:
commands/service_profile_set_default.go 52.63% 6 Missing and 3 partials :warning:
commands/service_library_install.go 50.00% 5 Missing and 2 partials :warning:
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2917      +/-   ##
==========================================
- Coverage   68.36%   68.29%   -0.08%     
==========================================
  Files         241      252      +11     
  Lines       22731    23328     +597     
==========================================
+ Hits        15541    15932     +391     
- Misses       5992     6166     +174     
- Partials     1198     1230      +32     
Flag Coverage Δ
unit 68.29% <66.25%> (-0.08%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar May 21 '25 15:05 codecov[bot]

Hello, this is great 🔥 Maybe you want to consider adding and removing multiple libs (later cores) with a single request. I do not know how it performs, but when a user interface wants to initialize a profile from a set of libraries and cores, one request would be better than multiple ones.


Update: I checked the changes only from the point of the proto API as a client.

kittaakos avatar May 27 '25 14:05 kittaakos