-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(env): add environment caching with module cacheability support #7761
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f9b2b3e
feat(env): add environment caching with module cacheability support
jdx 536e8e8
[autofix.ci] apply automated fixes
autofix-ci[bot] 89c227c
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] a76e847
fix(env): address CI failures in env cache PR
jdx 4102d69
fix(cli): sort --fresh-env flag alphabetically in exec and run
jdx d0f72a1
[autofix.ci] apply automated fixes
autofix-ci[bot] 2b8fd76
feat(cache): add env cache to pruning and clear commands
jdx c7a0f9d
fix: address PR feedback
jdx f63266f
docs: document MiseEnv cacheability options
jdx 5381d18
fix: address additional PR feedback
jdx 77b1d29
fix: address more PR feedback
jdx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Test env caching feature | ||
|
|
||
| # Enable env caching with encryption key (as would be set by `mise activate`) | ||
| export MISE_ENV_CACHE=1 | ||
| export __MISE_ENV_CACHE_KEY="dGVzdGtleXRlc3RrZXl0ZXN0a2V5dGVzdGtleXRlc3Q=" | ||
|
|
||
| # Create a basic config with env vars | ||
| cat >"$MISE_CONFIG_DIR/config.toml" <<EOF | ||
| [env] | ||
| CACHE_TEST_VAR="value1" | ||
| EOF | ||
|
|
||
| # First run should compute env and create cache | ||
| assert_contains "mise env -s bash" "CACHE_TEST_VAR=value1" | ||
|
|
||
| # Second run should use cached env (same result) | ||
| assert_contains "mise env -s bash" "CACHE_TEST_VAR=value1" | ||
|
|
||
| # Modify config - cache should be invalidated due to mtime change | ||
| sleep 1 # Ensure mtime is different | ||
| cat >"$MISE_CONFIG_DIR/config.toml" <<EOF | ||
| [env] | ||
| CACHE_TEST_VAR="value2" | ||
| EOF | ||
|
|
||
| # Should reflect the new value | ||
| assert_contains "mise env -s bash" "CACHE_TEST_VAR=value2" | ||
|
|
||
| # Test that cache dir exists when caching is enabled | ||
| assert_directory_exists "$HOME/.local/state/mise/env-cache" | ||
|
|
||
| # Disable caching and verify it still works | ||
| unset MISE_ENV_CACHE | ||
|
|
||
| cat >"$MISE_CONFIG_DIR/config.toml" <<EOF | ||
| [env] | ||
| CACHE_TEST_VAR="value3" | ||
| EOF | ||
|
|
||
| assert_contains "mise env -s bash" "CACHE_TEST_VAR=value3" |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Test --fresh-env flag with caching | ||
|
|
||
| # Enable env caching | ||
| export MISE_ENV_CACHE=1 | ||
|
|
||
| # Set up a cache encryption key as if activated | ||
| export __MISE_ENV_CACHE_KEY="dGVzdGtleXRlc3RrZXl0ZXN0a2V5dGVzdGtleXRlc3Q=" | ||
|
|
||
| # Create config | ||
| cat >"$MISE_CONFIG_DIR/config.toml" <<EOF | ||
| [env] | ||
| FRESH_TEST_VAR="original" | ||
| EOF | ||
|
|
||
| # First run caches | ||
| mise exec -- true | ||
|
|
||
| # Modify config | ||
| sleep 1 | ||
| cat >"$MISE_CONFIG_DIR/config.toml" <<EOF | ||
| [env] | ||
| FRESH_TEST_VAR="modified" | ||
| EOF | ||
|
|
||
| # Normal exec should see cache invalidated due to mtime change | ||
| assert_contains "mise exec -- bash -c 'echo \$FRESH_TEST_VAR'" "modified" | ||
|
|
||
| # Verify --fresh-env flag exists on exec | ||
| assert_contains "mise exec --help" "fresh-env" | ||
|
|
||
| # Verify --fresh-env flag exists on run | ||
| assert_contains "mise run --help" "fresh-env" |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
The version
0.10ofchacha20poly1305may not be the latest. Consider using a more recent version to benefit from security updates and improvements. Check crates.io for the latest stable version.