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

feat(sm-plugin): filter packages output list with exclude/include pattern #2869

Merged
merged 4 commits into from
May 22, 2024

Conversation

Ruadhri17
Copy link
Contributor

@Ruadhri17 Ruadhri17 commented May 9, 2024

Proposed changes

This PR introduce two new tedge configs: software.plugin.include and software.plugin.exclude. This allows to filter packages list output in sm-plugin using include pattern and exclude pattern. When both patterns are provided in config, include pattern takes precedence over exclude pattern.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#2848

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

codecov bot commented May 9, 2024

Codecov Report

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

Project coverage is 78.1%. Comparing base (33e6890) to head (eb60c35).
Report is 51 commits behind head on main.

Current head eb60c35 differs from pull request most recent head 40e1cfe

Please upload reports for the commit 40e1cfe to get more accurate results.

Additional details and impacted files
Files Coverage Δ
crates/core/plugin_sm/src/plugin_manager.rs 55.1% <100.0%> (-11.0%) ⬇️
.../tedge_config/src/tedge_config_cli/tedge_config.rs 76.5% <77.7%> (-0.5%) ⬇️
crates/core/tedge_api/src/error.rs 0.0% <0.0%> (ø)
crates/core/plugin_sm/src/plugin.rs 13.3% <12.9%> (+<0.1%) ⬆️

... and 45 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented May 9, 2024

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
435 0 3 435 100 0s

Copy link
Contributor

@reubenmiller reubenmiller left a comment

Choose a reason for hiding this comment

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

We'll have to do the settings in a non breaking way as the old apt.name and apt.maintainer (inclusive) filters still need to be accepted (otherwise it will break everyone's existing config, and it will be in violation of the semver versioning).

We can introduce new settings but we need to then map the old settings to the new ones.

Also I'm not sure I fully understand the decision around the tedge-apt-plugin flag choice, as it stands the user can't use inclusive and exclusive filters via the cli...I would have expected something like "--inclusive-name" and "--exclusive-name" flags. The flag renaming is less important here as this was only ever used for adhoc validation an shouldn't break anyone's existing setup

Copy link
Contributor

@gligorisaev gligorisaev left a comment

Choose a reason for hiding this comment

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

Test

  • filter_packages_list_output_with_exclude_pattern.robot
    Appears to be well-structured, covering a range of scenarios, and designed with maintainability and reliability in mind. Provides solid foundation for testing package filtering functionality
  • tests/RobotFramework/tests/plugin_apt/filter_packages_list_output_with_include_pattern.robot
    Changes should be acurate enought to check the functionality properly
  • tests/RobotFramework/tests/tedge/call_tedge_config_list.robot
    Effectively tests the setting and unsetting of configuration values for apt name and maintainer.

Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

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

Approved - with a suggestion

crates/core/plugin_sm/src/plugin.rs Outdated Show resolved Hide resolved
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request May 22, 2024 08:07 — with GitHub Actions Inactive
@Bravo555 Bravo555 dismissed their stale review May 22, 2024 08:53

.unwrap_or_default is safe, no blockers

Copy link
Contributor

@Bravo555 Bravo555 left a comment

Choose a reason for hiding this comment

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

Assuming the test cases are sufficient and correct, the implementation is correct.

Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
Copy link
Contributor

@reubenmiller reubenmiller left a comment

Choose a reason for hiding this comment

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

Looks great. I experimented with the filters on a Yocto device and the combination of filters was able to reduce the list from 2000 to 160, perfect.

@Ruadhri17 Ruadhri17 enabled auto-merge May 22, 2024 11:13
@Ruadhri17 Ruadhri17 added this pull request to the merge queue May 22, 2024
Merged via the queue into thin-edge:main with commit d400b89 May 22, 2024
30 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.

None yet

5 participants