Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add first set ofprofile commands#2917

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
MatteoPologruto wants to merge13 commits intoarduino:master
base:master
Choose a base branch
Loading
fromMatteoPologruto:add-profiles-command-support

Conversation

MatteoPologruto
Copy link
Contributor

@MatteoPologrutoMatteoPologruto commentedMay 21, 2025
edited
Loading

Please check if the PR fulfills these requirements

Seehow to contribute

  • The PR has no duplicates (please search among thePull 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 thesketch.yaml project file must be done manually.

What is the new behavior?

First set ofprofile commands:

  1. profile init [<PATH>] [-m <PROFILE_NAME -b <FQBN>] [--default] creates asketch.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 thesketch.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 thesketch.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 thesketch.yaml file in the current directory.
  5. profile dump [<PATH>] dumps the content of thesketch.yaml file. It supports theyaml andjson formats.

Does this PR introduce a breaking change, and istitled accordingly?

Other information

@MatteoPologrutoMatteoPologruto self-assigned thisMay 21, 2025
@MatteoPologrutoMatteoPologruto added type: enhancementProposed improvement topic: codeRelated to content of the project itself labelsMay 21, 2025
@MatteoPologrutoMatteoPologruto linked an issueMay 21, 2025 that may beclosed by this pull request
3 tasks
@MatteoPologrutoMatteoPologruto changed the titleAdd first set ofprofile commandAdd first set ofprofile commandsMay 21, 2025
@codecovCodecov
Copy link

codecovbot commentedMay 21, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is68.68932% with129 lines in your changes missing coverage. Please review.

Project coverage is 67.84%. Comparing base(dd621ee) to head(5381938).
Report is 1 commits behind head on master.

Files with missing linesPatch %Lines
internal/cli/profile/dump.go20.93%33 Missing and 1 partial⚠️
commands/service_profile_lib_add.go60.00%12 Missing and 6 partials⚠️
commands/service_profile_dump.go0.00%16 Missing⚠️
internal/cli/profile/lib.go84.31%14 Missing and 2 partials⚠️
commands/service_profile_init.go78.68%9 Missing and 4 partials⚠️
commands/service_profile_lib_remove.go58.62%8 Missing and 4 partials⚠️
commands/service_profile_set_default.go52.63%6 Missing and 3 partials⚠️
commands/cmderrors/cmderrors.go25.00%6 Missing⚠️
internal/arduino/sketch/profiles.go78.57%2 Missing and 1 partial⚠️
internal/cli/profile/init.go94.44%2 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##           master    #2917      +/-   ##==========================================+ Coverage   67.83%   67.84%   +0.01%==========================================  Files         238      248      +10       Lines       22442    22854     +412     ==========================================+ Hits        15223    15506     +283- Misses       6016     6124     +108- Partials     1203     1224      +21
FlagCoverage Δ
unit67.84% <68.68%> (+0.01%)⬆️

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.

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.
@MatteoPologrutoMatteoPologrutoforce-pushed theadd-profiles-command-support branch 2 times, most recently fromab96ed6 to8a41c13CompareMay 22, 2025 12:25
It adds one or multiple libraries to the specified profile.
@MatteoPologrutoMatteoPologrutoforce-pushed theadd-profiles-command-support branch from8a41c13 tod3d7a59CompareMay 22, 2025 13:32
It removes a library from the specified profile.
@MatteoPologrutoMatteoPologrutoforce-pushed theadd-profiles-command-support branch from67c9a2c tof98bf7dCompareMay 22, 2025 14:46
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.
@MatteoPologrutoMatteoPologrutoforce-pushed theadd-profiles-command-support branch from896841b toa2c86efCompareMay 23, 2025 15:21
@MatteoPologrutoMatteoPologruto marked this pull request as ready for reviewMay 27, 2025 14:08
@MatteoPologrutoMatteoPologruto requested review fromcmaglie anda teamMay 27, 2025 14:08
@kittaakos
Copy link
Contributor

kittaakos commentedMay 27, 2025
edited
Loading

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-peruginialessio-perugini left a comment
edited
Loading

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/skcat /tmp/sk/sketch.yamlprofiles:  Uno_profile:    fqbn: arduino:avr:uno    platforms:      - platform: arduino:avr (1.8.6)    libraries:default_profile: c

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

Basically we have to check if the items == 0, then we either skip that property or we setlibraries: [].
I'm afraid it could also happen for theplatforms 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.

Comment on lines 36 to 46
sketchPath := paths.New(req.GetSketchPath())
projectFilePath, err := sketchPath.Join("sketch.yaml").Abs()
if err != nil {
return nil, err
}

// Returns an error if the main file is missing from the sketch so there is no need to check if the path exists
sk, err := sketch.New(sketchPath)
if err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sketchPath:=paths.New(req.GetSketchPath())
projectFilePath,err:=sketchPath.Join("sketch.yaml").Abs()
iferr!=nil {
returnnil,err
}
// Returns an error if the main file is missing from the sketch so there is no need to check if the path exists
sk,err:=sketch.New(sketchPath)
iferr!=nil {
returnnil,err
}
sketchPath:=paths.New(req.GetSketchPath())
projectFilePath,err:=sketchPath.Join("sketch.yaml").Abs()
iferr!=nil {
returnnil,err
}
// Returns an error if the main file is missing from the sketch so there is no need to check if the path exists
sk,err:=sketch.New(sketchPath)
iferr!=nil {
returnnil,err
}

Can you please move this snippet of code under a private function? Something likecheckProfilePreconditions.
And call that in all the new function you have created undercommands. I've noticed that you do this same check for al of them

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I have refactored it using the already existing functionsketch.GetProjectPath()

Copy link
Contributor

@per1234per1234 left a comment
edited
Loading

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 theprofile 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.

Theprofile 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 thesketch command (e.g.,sketch project dump), not under theprofile 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.

@MatteoPologrutoMatteoPologrutoforce-pushed theadd-profiles-command-support branch fromd92be42 to5381938CompareMay 30, 2025 14:17
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@alessio-peruginialessio-peruginialessio-perugini requested changes

@per1234per1234per1234 requested changes

@cmagliecmaglieAwaiting requested review from cmaglie

Requested changes must be addressed to merge this pull request.

Assignees

@MatteoPologrutoMatteoPologruto

Labels
topic: codeRelated to content of the project itselftype: enhancementProposed improvement
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add first set ofprofile commands
4 participants
@MatteoPologruto@kittaakos@alessio-perugini@per1234

[8]ページ先頭

©2009-2025 Movatter.jp