Repository navigation
feat(task): include dependency artifacts in cache keys #11340
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 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,101 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| cat <<'EOF' >mise.toml | ||
| [settings] | ||
| experimental = true | ||
|
|
||
| [task_config.cache] | ||
| enabled = true | ||
|
|
||
| [tasks.lib] | ||
| run = ''' | ||
| mkdir -p lib-dist | ||
| cat lib.txt > lib-dist/result.txt | ||
| printf 'ran\n' >> lib-runs.txt | ||
| ''' | ||
| sources = ["lib.txt"] | ||
| outputs = ["lib-dist"] | ||
|
|
||
| [tasks.app] | ||
| depends = ["lib"] | ||
| run = ''' | ||
| mkdir -p app-dist | ||
| cat lib-dist/result.txt app.txt > app-dist/result.txt | ||
| printf 'ran\n' >> app-runs.txt | ||
| ''' | ||
| sources = ["app.txt"] | ||
| outputs = ["app-dist"] | ||
|
|
||
| [tasks.prepare] | ||
| run = ''' | ||
| mkdir -p prepare-dist | ||
| cat prepare.txt > prepare-dist/result.txt | ||
| printf 'ran\n' >> prepare-runs.txt | ||
| ''' | ||
| sources = ["prepare.txt"] | ||
| outputs = ["prepare-dist"] | ||
| cache = { enabled = false } | ||
|
|
||
| [tasks.consume] | ||
| depends = ["prepare"] | ||
| run = ''' | ||
| mkdir -p consume-dist | ||
| cat prepare-dist/result.txt consume.txt > consume-dist/result.txt | ||
| printf 'ran\n' >> consume-runs.txt | ||
| ''' | ||
| sources = ["consume.txt"] | ||
| outputs = ["consume-dist"] | ||
| EOF | ||
|
|
||
| printf 'lib-one\n' >lib.txt | ||
| printf 'app\n' >app.txt | ||
| printf 'prepare-one\n' >prepare.txt | ||
| printf 'consume\n' >consume.txt | ||
|
|
||
| mise run app | ||
| assert "wc -l < lib-runs.txt | tr -d ' '" "1" | ||
| assert "wc -l < app-runs.txt | tr -d ' '" "1" | ||
| assert "cat app-dist/result.txt" $'lib-one\napp' | ||
|
|
||
| # A fresh dependency still publishes its identity when it skips, allowing a | ||
| # missing downstream output to restore. | ||
| rm -rf app-dist | ||
| assert_contains "mise run app 2>&1" "restored outputs from cache" | ||
| assert "wc -l < lib-runs.txt | tr -d ' '" "1" | ||
| assert "wc -l < app-runs.txt | tr -d ' '" "1" | ||
|
|
||
| # A restored dependency contributes the same identity to the downstream key, | ||
| # so both tasks can restore without executing. | ||
| rm -rf lib-dist app-dist | ||
| assert_contains "mise run app 2>&1" "restored outputs from cache" | ||
| assert "wc -l < lib-runs.txt | tr -d ' '" "1" | ||
| assert "wc -l < app-runs.txt | tr -d ' '" "1" | ||
| assert "cat app-dist/result.txt" $'lib-one\napp' | ||
|
|
||
| # Changing the dependency changes its artifact identity and invalidates the | ||
| # downstream artifact even though the downstream task's own sources are unchanged. | ||
| printf 'lib-two\n' >lib.txt | ||
| mise run app | ||
| assert "wc -l < lib-runs.txt | tr -d ' '" "2" | ||
| assert "wc -l < app-runs.txt | tr -d ' '" "2" | ||
| assert "cat app-dist/result.txt" $'lib-two\napp' | ||
|
|
||
| # Returning to a previously cached dependency identity restores both the | ||
| # dependency and the matching downstream artifact. | ||
| printf 'lib-one\n' >lib.txt | ||
| rm -rf lib-dist app-dist | ||
| assert_contains "mise run app 2>&1" "restored outputs from cache" | ||
| assert "wc -l < lib-runs.txt | tr -d ' '" "2" | ||
| assert "wc -l < app-runs.txt | tr -d ' '" "2" | ||
| assert "cat app-dist/result.txt" $'lib-one\napp' | ||
|
|
||
| # A dependency that executes without a stable cache identity still forces | ||
| # conservative downstream execution. | ||
| mise run consume | ||
| assert "wc -l < prepare-runs.txt | tr -d ' '" "1" | ||
| assert "wc -l < consume-runs.txt | tr -d ' '" "1" | ||
| printf 'prepare-two\n' >prepare.txt | ||
| mise run consume | ||
| assert "wc -l < prepare-runs.txt | tr -d ' '" "2" | ||
| assert "wc -l < consume-runs.txt | tr -d ' '" "2" | ||
| assert "cat consume-dist/result.txt" $'prepare-two\nconsume' |
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
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.
Uh oh!
There was an error while loading. Please reload this page.