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

[breaking] gRPC UpdateIndex and UpdateLibrariesIndex improvements #2569

Merged
merged 6 commits into from
Mar 22, 2024

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Mar 22, 2024

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?

UpdateIndex and UpdateLibrariesIndex now have the update_if_older_than_secs field that prevents updating the index if it has already been updated. Also, the response is more explicit with oneof(..) clause, and the status of each update (in case of multiple index updates) is returned in the response.

The JSON output has been implemented for commands core update-index and lib update-index.

What is the current behavior?

$ arduino-cli lib update-index --format json
$ arduino-cli core update-index --additional-urls=file:///home/cmaglie/Workspace/arduino-cli/internal/integrationtest/testdata/test_index.json  --format json
$

What is the new behavior?

$ arduino-cli lib update-index --format json
{
  "libraries_index": {
    "index_url": "https://downloads.arduino.cc/libraries/library_index.tar.bz2",
    "status": "updated"
  }
}
$ arduino-cli core update-index --additional-urls=file:///home/cmaglie/Workspace/arduino-cli/internal/integrationtest/testdata/test_index.json  --format json
{
  "updated_indexes": [
    {
      "index_url": "https://downloads.arduino.cc/packages/package_index.tar.bz2",
      "status": "updated"
    },
    {
      "index_url": "file:///home/megabug/Workspace/arduino-cli/internal/integrationtest/testdata/test_index.json",
      "status": "skipped"
    }
  ]
}
$

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

Yes

Other information

The two calls now have the update_if_older_than_secs field that allows
to avoid updating the index if it has been already updated.

Also the response is more explicit with oneof(..) clause and the status
of each update (in case of multiple index update) is returned in the response.
@cmaglie cmaglie self-assigned this Mar 22, 2024
@cmaglie cmaglie added type: enhancement Proposed improvement topic: gRPC Related to the gRPC interface labels Mar 22, 2024
@cmaglie cmaglie added this to the Arduino CLI v1.0.0 milestone Mar 22, 2024
Copy link

codecov bot commented Mar 22, 2024

Codecov Report

Attention: Patch coverage is 74.66667% with 38 lines in your changes are missing coverage. Please review.

Project coverage is 69.58%. Comparing base (31e3288) to head (e92a812).
Report is 1 commits behind head on master.

Files Patch % Lines
commands/instances.go 73.77% 14 Missing and 2 partials ⚠️
commands/daemon/daemon.go 50.00% 11 Missing ⚠️
internal/cli/lib/search.go 55.55% 2 Missing and 2 partials ⚠️
internal/cli/core/search.go 75.00% 2 Missing and 1 partial ⚠️
internal/cli/feedback/result/rpc.go 92.59% 2 Missing ⚠️
internal/cli/lib/update_index.go 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2569      +/-   ##
==========================================
+ Coverage   69.48%   69.58%   +0.09%     
==========================================
  Files         205      205              
  Lines       20204    20267      +63     
==========================================
+ Hits        14038    14102      +64     
- Misses       5045     5049       +4     
+ Partials     1121     1116       -5     
Flag Coverage Δ
unit 69.58% <74.66%> (+0.09%) ⬆️

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.

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.

Looks good, in the future we could expand the daemon and cli --json tests, checking that IndexUpdateReport contains what we'd expect.

@cmaglie cmaglie merged commit 6faca0f into arduino:master Mar 22, 2024
104 checks passed
@cmaglie cmaglie deleted the update_index_changes branch March 25, 2024 08:41
@cmaglie
Copy link
Member Author

cmaglie commented Mar 25, 2024

Related to #2565

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants