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

path_utilities: Adjust GetContainingPackage() and Edk2Path behavior #186

Merged
merged 8 commits into from Nov 9, 2022

Conversation

makubacki
Copy link
Member

@makubacki makubacki commented Nov 3, 2022

path_utilities: Adjust GetContainingPackage() and Edk2Path behavior
Fixes #183, fixes #185

Updates the Edk2Path constructor with the following changes:

  • Avoid changing global object state during intermediary validation
    operations. If an exception were returned or execution is otherwise
    interrupted the PackagePathList and WorkspacePath will have
    predictable values only set once validation succeeds.
  • Raise a NotADirectoryError exception on invalid directory input.
    This allows the caller to implement more focused exception handling.
  • Update the definition of a package to be a directory with a .dec file
    and use that as the basis for detecting nested packages.
  • Update the nested package path algorithm to fix [Bug]: Unit tests can fail based on state of system temporary directory #183 and prevent
    exceeding ascension in the directory hierarchy beyond the maximum
    root directory being compared.
  • Minor documentation cleanup.

Update GetContainingPackage() with the following changes:

  • Only return a containing package if a file is in a directory with
    a .dec file. Avoid returning directory parents outside edk2
    packages. Closes [Bug]: Simplify GetContainingPkg() #185.
  • Minor documentation cleanup.

Updates both functions to remove superfluous logging and leave it to
the caller to manage logging messages based on the context of the
actions they are trying to perform.

Updates unit tests to align with updated function expectations.

Signed-off-by: Michael Kubacki michael.kubacki@microsoft.com

makubacki added a commit to makubacki/edk2-pytool-extensions that referenced this pull request Nov 3, 2022
Updates `get_packages_to_build()` to return all possible packages if
a file is modified outside a package.

Originally, this was implemented behind a new argument with the
default behavior unchanged. However, feedback indicated it would
be easier to adopt without an argument and this would be acceptable
behavior.

This does mean some files, such as documentation files, could trigger
packages to build that would have not previously built. However, the
impact and frequency of this is considered minimal enough to not
justify additional complexity. The change mainly focuses on files
such as dependency trackers (e.g. PIP requirements, submodules),
Python scripts, and other files that can impact overall build
results.

Requires tianocore/edk2-pytool-library#186.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Base: 78.25% // Head: 78.31% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (4d3bc4d) compared to base (c09b298).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #186      +/-   ##
==========================================
+ Coverage   78.25%   78.31%   +0.05%     
==========================================
  Files          91       91              
  Lines       10059    10067       +8     
==========================================
+ Hits         7872     7884      +12     
+ Misses       2187     2183       -4     
Flag Coverage Δ
Linux 75.63% <97.29%> (+0.05%) ⬆️
Windows_NT 78.27% <100.00%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
edk2toollib/uefi/edk2/path_utilities.py 100.00% <100.00%> (+2.89%) ⬆️
edk2toollib/uefi/edk2/test_path_utilities.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@makubacki
Copy link
Member Author

makubacki commented Nov 4, 2022

Note: PR gates are failing due to pydocstyle in edk2-pytool-extensions (#187), unrelated to this change.

@Javagedes Javagedes added bug Something isn't working enhancement New feature or request labels Nov 8, 2022
@Javagedes Javagedes added this to the 0.12.0 milestone Nov 8, 2022
@makubacki
Copy link
Member Author

@Javagedes and @spbrogan, are you waiting on something else to approve this one?

@Javagedes
Copy link
Contributor

Javagedes commented Nov 9, 2022

@makubacki I was waiting to get my pydocstyle PR in. I've Approved, but there are comment conflicts due to my PR. Once the PR is passing the PR gates I'll merge.

@Javagedes
Copy link
Contributor

I'm also going to do a quick run of the integration checks just to make sure the change to GetContainingPackage() to return None instead of ws didn't break anything.

@Javagedes
Copy link
Contributor

@makubacki Integration tests passed; I'm ready to merge once the conflicts have been handled.

Fixes tianocore#183, fixes tianocore#185

Updates the Edk2Path constructor with the following changes:

- Avoid changing global object state during intermediary validation
  operations. If an exception were returned or execution is otherwise
  interrupted the `PackagePathList` and `WorkspacePath` will have
  predictable values only set once validation succeeds.
- Raise a `NotADirectoryError` exception on invalid directory input.
  This allows the caller to implement more focused exception handling.
- Update the definition of a package to be a directory with a .dec file
  and use that as the basis for detecting nested packages.
- Update the nested package path algorithm to fix tianocore#183 and prevent
  exceeding ascension in the directory hierarchy beyond the maximum
  root directory being compared.
- Minor documentation cleanup.

Update GetContainingPackage() with the following changes:

- Only return a containing package if a file is in a directory with
  a .dec file. Avoid returning directory parents outside edk2
  packages. Closes tianocore#185.
- Minor documentation cleanup.

Updates both functions to remove superfluous logging and leave it to
the caller to manage logging messages based on the context of the
actions they are trying to perform.

Updates unit tests to align with updated function expectations.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Allows callers to pass package paths that may not be valid
directories and control whether an exception is raised with the
error_on_invalid_pp Edk2Path constructor parameter.

Restores behavior introduced in tianocore#113

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Updates test_get_relative_path_when_package_path_inside_package() to
instantiate an Edk2Path object to ensure it can initialize properly
by not raising an exception and be used to get the relative path
of a file in the workspace.
Adds a test case to verify nested packages raise an exception.

This provides full test coverage of the checks in the Edk2Path
constructor.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki
Copy link
Member Author

@makubacki Integration tests passed; I'm ready to merge once the conflicts have been handled.

Conflict update pushed

@Javagedes Javagedes merged commit 9963ecf into tianocore:master Nov 9, 2022
makubacki added a commit to makubacki/edk2-pytool-extensions that referenced this pull request Nov 9, 2022
Updates `get_packages_to_build()` to return all possible packages if
a file is modified outside a package.

Originally, this was implemented behind a new argument with the
default behavior unchanged. However, feedback indicated it would
be easier to adopt without an argument and this would be acceptable
behavior.

This does mean some files, such as documentation files, could trigger
packages to build that would have not previously built. However, the
impact and frequency of this is considered minimal enough to not
justify additional complexity. The change mainly focuses on files
such as dependency trackers (e.g. PIP requirements, submodules),
Python scripts, and other files that can impact overall build
results.

Requires tianocore/edk2-pytool-library#186.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
makubacki added a commit to makubacki/edk2-pytool-extensions that referenced this pull request Nov 11, 2022
Updates `get_packages_to_build()` to return all possible packages if
a file is modified outside a package.

Originally, this was implemented behind a new argument with the
default behavior unchanged. However, feedback indicated it would
be easier to adopt without an argument and this would be acceptable
behavior.

This does mean some files, such as documentation files, could trigger
packages to build that would have not previously built. However, the
impact and frequency of this is considered minimal enough to not
justify additional complexity. The change mainly focuses on files
such as dependency trackers (e.g. PIP requirements, submodules),
Python scripts, and other files that can impact overall build
results.

Requires tianocore/edk2-pytool-library#186.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
makubacki added a commit to makubacki/edk2-pytool-extensions that referenced this pull request Nov 11, 2022
Updates `get_packages_to_build()` to return all possible packages if
a file is modified outside a package.

Originally, this was implemented behind a new argument with the
default behavior unchanged. However, feedback indicated it would
be easier to adopt without an argument and this would be acceptable
behavior.

This does mean some files, such as documentation files, could trigger
packages to build that would have not previously built. However, the
impact and frequency of this is considered minimal enough to not
justify additional complexity. The change mainly focuses on files
such as dependency trackers (e.g. PIP requirements, submodules),
Python scripts, and other files that can impact overall build
results.

Requires tianocore/edk2-pytool-library#186.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
makubacki added a commit to makubacki/edk2-pytool-extensions that referenced this pull request Nov 11, 2022
Updates `get_packages_to_build()` to return all possible packages if
a file is modified outside a package.

Originally, this was implemented behind a new argument with the
default behavior unchanged. However, feedback indicated it would
be easier to adopt without an argument and this would be acceptable
behavior.

This does mean some files, such as documentation files, could trigger
packages to build that would have not previously built. However, the
impact and frequency of this is considered minimal enough to not
justify additional complexity. The change mainly focuses on files
such as dependency trackers (e.g. PIP requirements, submodules),
Python scripts, and other files that can impact overall build
results.

Requires tianocore/edk2-pytool-library#186.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Javagedes pushed a commit to tianocore/edk2-pytool-extensions that referenced this pull request Nov 11, 2022
Updates `get_packages_to_build()` to return all possible packages if
a file is modified outside a package.

Originally, this was implemented behind a new argument with the
default behavior unchanged. However, feedback indicated it would
be easier to adopt without an argument and this would be acceptable
behavior.

This does mean some files, such as documentation files, could trigger
packages to build that would have not previously built. However, the
impact and frequency of this is considered minimal enough to not
justify additional complexity. The change mainly focuses on files
such as dependency trackers (e.g. PIP requirements, submodules),
Python scripts, and other files that can impact overall build
results.

Requires tianocore/edk2-pytool-library#186.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Simplify GetContainingPkg() [Bug]: Unit tests can fail based on state of system temporary directory
3 participants