Skip to content

Conversation

MatteoPologruto
Copy link
Contributor

@MatteoPologruto MatteoPologruto commented May 21, 2025

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)
  • 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 MatteoPologruto self-assigned this May 21, 2025
@MatteoPologruto MatteoPologruto added type: enhancement Proposed improvement topic: code Related to content of the project itself labels May 21, 2025
@MatteoPologruto MatteoPologruto linked an issue May 21, 2025 that may be closed by this pull request
3 tasks
@MatteoPologruto MatteoPologruto changed the title Add first set of profile command Add first set of profile commands May 21, 2025
@codecov
Copy link

codecov bot commented May 21, 2025

Codecov Report

❌ Patch coverage is 66.25000% with 216 lines in your changes missing coverage. Please review.
✅ 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 ⚠️
internal/cli/profile/dump.go 20.93% 33 Missing and 1 partial ⚠️
internal/arduino/sketch/profiles.go 52.94% 26 Missing and 6 partials ⚠️
commands/service_profile_lib_list.go 0.00% 20 Missing ⚠️
internal/cli/profile/lib.go 87.16% 16 Missing and 3 partials ⚠️
commands/service_profile_dump.go 0.00% 16 Missing ⚠️
commands/service_profile_lib_remove.go 54.54% 10 Missing and 5 partials ⚠️
commands/service_profile_init.go 77.96% 9 Missing and 4 partials ⚠️
commands/service_profile_set_default.go 52.63% 6 Missing and 3 partials ⚠️
commands/service_library_install.go 50.00% 5 Missing and 2 partials ⚠️
... 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%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@MatteoPologruto MatteoPologruto force-pushed the add-profiles-command-support branch 5 times, most recently from 896841b to a2c86ef Compare May 23, 2025 15:21
@MatteoPologruto MatteoPologruto marked this pull request as ready for review May 27, 2025 14:08
@MatteoPologruto MatteoPologruto requested review from a team and cmaglie May 27, 2025 14:08
@kittaakos
Copy link
Contributor

kittaakos commented May 27, 2025

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.

Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

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

Great job! 🚀

We have a bug in the long standing:

res += p.Platforms.AsYaml()
res += p.Libraries.AsYaml()

arduino-cli profile init --profile Uno_profile -b arduino:avr:uno /tmp/sk

cat /tmp/sk/sketch.yaml

profiles:
  Uno_profile:
    fqbn: arduino:avr:uno
    platforms:
      - platform: arduino:avr (1.8.6)
    libraries:

default_profile: c

You can see here that it produces libraries: without [], this is an invalid yaml.

Basically we have to check if the items == 0, then we either skip that property or we set libraries: [].
I'm afraid it could also happen for the platforms so I'd put that check there too.

}

newProfile := &sketch.Profile{Name: req.GetProfileName(), FQBN: req.GetFqbn()}
// TODO: what to do with the PlatformIndexURL?
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have some kind of internal API that we can use to retrieve platform <-> index URL?

Copy link
Contributor

Choose a reason for hiding this comment

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

cc: @cmaglie

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

I feel that the design of the profile dump command is inappropriate. This command is actually printing the data of the entire sketch project file, not the build profile data alone. Although the primary usage of the sketch project file is currently for defining build profiles, it is not limited to this purpose and there is a good chance that it will be used for additional things unrelated to build profiles as time goes on.

The profile dump command should be a tool for printing the data from a build profile.

If you want a tool for printing the sketch project file, that should go somewhere else, such as under the sketch command (e.g., sketch project dump), not under the profile command.

If the user doesn't specify a profile ID, it should print the default build profile from the sketch project file. An --all flag could be added to cause it to print all build profiles present in the sketch project file.

@MatteoPologruto MatteoPologruto force-pushed the add-profiles-command-support branch from d92be42 to 5381938 Compare May 30, 2025 14:17
It creates a `sketch.yaml` file at the provided path. A new profile can be added to the file by providing a profile name and FQBN.
It adds one or multiple libraries to the specified profile.
It removes a library from the specified profile.
If the project file contains only one profile, it is automatically set as default, otherwise the `--default` flag can be used.
Library operations are automatically executed on the default profile.
Sets the default profile to the provided existing profile.
It dumps the content of the project file.
Co-authored-by: Per Tillisch <[email protected]>
@MatteoPologruto MatteoPologruto force-pushed the add-profiles-command-support branch from 5381938 to 3cd499a Compare September 26, 2025 15:44
@cmaglie cmaglie force-pushed the add-profiles-command-support branch from e9f6603 to dbfdebd Compare October 1, 2025 14:30
@cmaglie cmaglie force-pushed the add-profiles-command-support branch from dbfdebd to e9ec51c Compare October 2, 2025 12:59
This change makes the function libraryResolveDependencies a bit more
generic, moving the rpc-related conversion into the gRPC method.
This is useful for the next commits and, as a nice bonus, has also
made more straighforward the exising InstallLibrary implementation.
@cmaglie cmaglie force-pushed the add-profiles-command-support branch from e9ec51c to 1a2a522 Compare October 2, 2025 14:32
@cmaglie cmaglie force-pushed the add-profiles-command-support branch 2 times, most recently from 5721820 to 830a052 Compare October 2, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Add first set of profile commands

6 participants