8000 Adding upgrade rule mechanism in ZAP for SDKs by brdandu · Pull Request #1589 · project-chip/zap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding upgrade rule mechanism in ZAP for SDKs #1589

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

Conversation

brdandu
Copy link
Collaborator
@brdandu brdandu commented May 2, 2025
  • Users can now include an upgrade rules json file in the zcl.json file which has a list of all the upgrade rules that may be needed when a user updates an existing app from one version of the GSDK to another.
  • The upgrade rules json file lists a set of upgrade rules scripts with their priority as can be seen in upgrade-rules.json file. The scripts are run in order of priority with lower number signifying higher priority
  • The upgrade rules return an object including a message and status which helps determine if an upgrade rules was actually executed or not. These results can be output into a yaml file if required for post analysis on which upgrade rules ran on a certain .zap file once the GSDK was updated.
  • Github: ZAP#1020

@brdandu brdandu requested review from paulr34 and tecimovic as code owners May 2, 2025 13:48
@brdandu brdandu requested a review from Copilot May 2, 2025 13:52
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an upgrade rule mechanism for ZAP, allowing users to include an upgrade rules JSON file that lists upgrade rule scripts with associated priorities. The upgrade rules are read from each package, sorted by priority, and then executed during file import, with their messages gathered for optional output.

  • Added new return value in the test script for endpoint deletion.
  • Integrated upgrade rule processing in the main process startup and import/export modules.
  • Improved directory creation logic when writing out conversion results.

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.

File Description
test/resource/test-script-2.js Returns an object with a message and status after endpoint deletion.
src-electron/main-process/startup.js Introduces processing of upgrade rules from package JSONs with sorting by priority.
src-electron/importexport/import.js Adds handling and execution of post-import upgrade scripts and associated logging.
Files not reviewed (2)
  • zcl-builtin/silabs/upgrade-rules.json: Language not supported
  • zcl-builtin/silabs/zcl-zigbee.json: Language not supported
Comments suppressed due to low confidence (2)

test/resource/test-script-2.js:22

  • [nitpick] Consider using a predefined constant or enum for status values instead of magic strings to maintain consistency across similar functions.
return { message: 'Endpoint Deleted', status: 'automatic' } // Status can be 'nothing', 'automatic', 'user_verification', 'impossible'.

src-electron/main-process/startup.js:331

  • Validate that 'upgradeRuleScripts' exists and is an array before attempting to sort it to avoid potential runtime errors if the JSON structure doesn't match expectations.
upgradeRulesData.upgradeRuleScripts.sort((a, b) => a.priority - b.priority)

@brdandu brdandu requested review from ethanzhouyc and dhchandw May 2, 2025 13:56
@brdandu brdandu marked this pull request as draft May 2, 2025 13:56
brdandu

This comment was marked as resolved.

@brdandu brdandu force-pushed the feature/upgradeRulesForZapFilesFromSDK/ZAP#1020 branch 2 times, most recently from 155244c to 6d81f9c Compare May 8, 2025 19:18
@brdandu brdandu marked this pull request as ready for review May 8, 2025 20:45
}
```

**category**: Determines that these upgrade rules need to run for matter.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes if more than 2 zcl json files are not passed then users could pass a any zcl json with upgrade rules in it and they may get executed.

@brdandu brdandu requested a review from Copilot May 9, 2025 19:09
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new upgrade rule mechanism for SDKs by enabling users to specify an upgrade rules JSON file in the zcl.json file. Key changes include:

  • Extending the test suite to cover upgrade rule behaviors for both Zigbee and Matter devices. 8000
  • Modifying post-import processing and database queries (including a new query module for upgrade rules) to support upgrade rule scripts.
  • Updating documentation and the README to cover the new upgrade workflow.

Reviewed Changes

Copilot reviewed 15 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/startup.test.js Added tests for upgrade rules with new file import and generation tests.
test/resource/* Added new upgrade rule scripts for Zigbee, Matter, and generic attribute updates.
src-electron/util/post-import.js & post-import-api.js Updated to pass additional context for upgrade rules and to use async functions.
src-electron/main-process/startup.js & importexport/import.js Modified to load and execute upgrade rule scripts during import and upgrade processes.
src-electron/db/query-upgrade.js Introduced a new module to support queries related to upgrade rules.
docs/* & README.md Documentation updates for the new upgrade mechanism.
Files not reviewed (4)
  • zcl-builtin/matter/upgrade-rules-matter.json: Language not supported
  • zcl-builtin/matter/zcl-matter.json: Language not supported
  • zcl-builtin/silabs/upgrade-rules-zigbee.json: Language not supported
  • zcl-builtin/silabs/zcl-zigbee.json: Language not supported
Comments suppressed due to low confidence (1)

test/startup.test.js:44

  • Typo in comment: 'testiing' should be 'testing'.
// Save the original file content before tests. Used for uc upgrade testiing

Copy link
Collaborator
@tecimovic tecimovic left a comment

Choose a reason for hiding this comment

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

In principle this is ok, but I'd lie if I said I reviewed every line of code....

@codecov-commenter
Copy link
codecov-commenter commented May 9, 2025

Codecov Report

Attention: Patch coverage is 90.66667% with 7 lines in your changes missing coverage. Please review.

Project coverage is 67.10%. Comparing base (dc0747a) to head (4209037).
Report is 26 commits behind head on master.

Files with missing lines Patch % Lines
src-electron/main-process/startup.js 85.71% 4 Missing ⚠️
src-electron/importexport/import.js 88.23% 2 Missing ⚠️
src-electron/util/post-import-api.js 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1589      +/-   ##
==========================================
+ Coverage   66.93%   67.10%   +0.17%     
==========================================
  Files         197      199       +2     
  Lines       21827    22306     +479     
  Branches     4817     4936     +119     
==========================================
+ Hits        14609    14968     +359     
- Misses       7218     7338     +120     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brdandu brdandu force-pushed the feature/upgradeRulesForZapFilesFromSDK/ZAP#1020 branch from daf2900 to ef1b045 Compare May 13, 2025 15:07
- Users can now include an upgrade rules json file in the zcl.json file which has a list of all the upgrade rules that may be needed when a user updates an existing app from one version of the GSDK to another.
- The upgrade rules json file lists a set of upgrade rules scripts with their priority as can be seen in upgrade-rules.json file. The scripts are run in order of priority with lower number signifying higher priority
- The upgrade rules return an object including a message and status which helps determine if an upgrade rules was actually executed or not. These results can be output into a yaml file if required for post analysis on which upgrade rules ran on a certain .zap file once the GSDK was updated.
- Adding unit tests to update cluster revision attribute of all clusters
- Handling the multi protocol use case and adding unit tests that make sure that only the appropriate endpoints are updated when upgrade rules json files from both zigbee and matter exist
- Adding unit tests for matter only .zap file
- Adding documentation on how to add upgrade rules to your SDK
- Adding the update keys available to the context in postLoad
- Add unit tests to check the order in which the upgrade rules were run
- Github: ZAP#1020
@brdandu brdandu force-pushed the feature/upgradeRulesForZapFilesFromSDK/ZAP#1020 branch from ef1b045 to 3b4ecf0 Compare May 13, 2025 15:11
@brdandu brdandu merged commit af9340b into project-chip:master May 13, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade Rules needed for default xml changes and what is stored in the .zap file
4 participants
0