-
Notifications
You must be signed in to change notification settings - Fork 7
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
Shared layer logic for consistent output and unit testing #327
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colincasey
reviewed
Sep 25, 2024
schneems
force-pushed
the
schneems/ruby-install-layer-refactor2
branch
from
September 25, 2024 15:06
d429dba
to
b4f8850
Compare
schneems
force-pushed
the
schneems/ruby-install-layer-refactor2
branch
from
September 30, 2024 20:46
fa3b1d6
to
ada317a
Compare
There was a newline preventing rust-analyzer from ordering the `use` statements. I removed it, and saved and this is the outcome.
It might be safe to `expect` in the specific case, but not in the general one. We can return a nicely formatted string with information if it ever happens.
Instead of asserting implementation (that diffing a metadata object returns a vec entry), assert the behavior we want (that it clears the cache).
To fully exercise all caching logic in the shared folder, I'm introducing a helper to create a temporary `BuildContext` that can be used for exercising caching logic in test. This also introduces tests for both `restored_layer_action` states as called through `cached_layer_write_metadata`. Which should address this comment #327 (comment).
In the ruby_install_layer we're exercising `cached_layer_write_metadata` but we were testing `restored_layer_action` which is called currently but might not be in the future via refactoring. This change asserts the behavior we want while using the exact same interface we are currently using.
schneems
force-pushed
the
schneems/ruby-install-layer-refactor2
branch
from
October 1, 2024 13:29
ada317a
to
b556b9a
Compare
colincasey
requested changes
Oct 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schneems I'm good with most of this code but the inability to choose between build: true
and launch: true
in the cached_layer_write_metadata
function seems like it should either be re-evaluated or explained.
colincasey
approved these changes
Oct 2, 2024
- Ensures each of these cases where the vec is not empty will clear the cache. - Makes it easier for reviewers to see the output as a user would see it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR #326 pointed out inconsistencies in the style of output for different layers and asked for additional tests. This refactor makes that request easier by introducing shared logic for invalid metadata and cache invalidation.
It's a ducktyping approach based on two traits:
magic_migrate::TryMigrate
provides an interface to (possibly) migrate invalid metadata or display errorsMetadataDiff
provides an interface to allow standardize cache invalidation and restoration logicThese allow me to remove the bulk of cache invalidation logic into a central shared location. They also expose a clean interface for unit testing cache invalidation logic, which can then be used on other layers.
I described some of the background desires in #325, comment: #325 (comment).