Repository navigation
fix(task): deduplicate equivalent task sources #11204
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 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f4c17ec
fix(task): deduplicate global tasks by source
risu729 94f9ea2
fix(task): compare task sources safely
risu729 2666e90
test(task): cover resolved global task sources
risu729 0c15e4c
fix(task): avoid duplicate source rendering
risu729 421d7cd
refactor(file): centralize resolved path comparisons
risu729 b98a084
refactor(task): reduce task loader arguments
risu729 6895327
Merge branch 'main' into agent/task-source-dedup
risu729 ea750ab
test(task): fail when source listing errors
risu729 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| mkdir -p "$HOME/global-config" | ||
|
|
||
| marker="$MISE_TMP_DIR/global-config-render-count" | ||
| : >"$marker" | ||
| cat >"$HOME/global-config/config.toml" <<EOF | ||
| [tasks.render-once] | ||
| description = "{{ exec(command='echo rendered >> $marker') }}" | ||
| run = "echo render-once" | ||
| EOF | ||
|
|
||
| # A path listed as both user-global and system config is one physical config and | ||
| # must render once. Task rendering can execute templates, so duplicate loading | ||
| # is observable even when the final task map deduplicates the name. | ||
| MISE_GLOBAL_CONFIG_FILE="$HOME/global-config/config.toml" \ | ||
| MISE_SYSTEM_CONFIG_FILE="$HOME/global-config/config.toml" \ | ||
| mise tasks >/dev/null | ||
| assert "wc -l < '$marker' | tr -d ' '" "1" | ||
|
|
||
| linked_marker="$MISE_TMP_DIR/linked-global-config-render-count" | ||
| : >"$linked_marker" | ||
| cat >"$HOME/global-config/linked-config.toml" <<EOF | ||
| [tasks.render-linked-once] | ||
| description = "{{ exec(command='echo rendered >> $linked_marker') }}" | ||
| run = "echo render-linked-once" | ||
| EOF | ||
| ln -s "linked-config.toml" "$HOME/global-config/config-link.toml" | ||
| MISE_GLOBAL_CONFIG_FILE="$HOME/global-config/linked-config.toml" \ | ||
| MISE_SYSTEM_CONFIG_FILE="$HOME/global-config/config-link.toml" \ | ||
| mise tasks >/dev/null | ||
| assert "wc -l < '$linked_marker' | tr -d ' '" "1" | ||
|
|
||
| shared_marker="$MISE_TMP_DIR/shared-global-task-render-count" | ||
| : >"$shared_marker" | ||
| shared_toml_marker="$MISE_TMP_DIR/shared-global-toml-render-count" | ||
| : >"$shared_toml_marker" | ||
| mkdir -p "$HOME/shared-global-tasks" | ||
| cat >"$HOME/shared-global-tasks/render-shared-once" <<EOF | ||
| #!/usr/bin/env bash | ||
| #MISE description="{{ exec(command='echo rendered >> $shared_marker') }}" | ||
| echo render-shared-once | ||
| EOF | ||
| chmod +x "$HOME/shared-global-tasks/render-shared-once" | ||
| cat >"$HOME/shared-global-tasks/shared.toml" <<EOF | ||
| [render-shared-toml-once] | ||
| description = "{{ exec(command='echo rendered >> $shared_toml_marker') }}" | ||
| run = "echo render-shared-toml-once" | ||
| EOF | ||
| ln -s "shared-global-tasks" "$HOME/shared-global-tasks-link" | ||
| cat >"$HOME/global-config/user.toml" <<EOF | ||
| [task_config] | ||
| includes = ["$HOME/shared-global-tasks"] | ||
| EOF | ||
| cat >"$HOME/global-config/system.toml" <<EOF | ||
| [task_config] | ||
| includes = ["$HOME/shared-global-tasks-link"] | ||
| EOF | ||
|
|
||
| # Distinct global configs may reach the same physical script or TOML task file | ||
| # through different path spellings. Reuse the higher-precedence rendered tasks | ||
| # instead of evaluating either template again. | ||
| MISE_GLOBAL_CONFIG_FILE="$HOME/global-config/user.toml" \ | ||
| MISE_SYSTEM_CONFIG_FILE="$HOME/global-config/system.toml" \ | ||
| mise tasks >/dev/null | ||
| assert "wc -l < '$shared_marker' | tr -d ' '" "1" | ||
| assert "wc -l < '$shared_toml_marker' | tr -d ' '" "1" | ||
|
|
||
| mkdir -p "$HOME/include-order-tasks" | ||
| cat >"$HOME/include-order-tasks/include-winner" <<'EOF' | ||
| #!/usr/bin/env bash | ||
| echo "$MISE_TASK_FILE" | ||
| EOF | ||
| chmod +x "$HOME/include-order-tasks/include-winner" | ||
| ln -s "include-order-tasks" "$HOME/first-global-tasks" | ||
| ln -s "include-order-tasks" "$HOME/second-global-tasks" | ||
| cat >"$HOME/global-config/include-order.toml" <<EOF | ||
| [task_config] | ||
| includes = ["$HOME/first-global-tasks", "$HOME/second-global-tasks"] | ||
| EOF | ||
|
|
||
| # Reuse is limited to earlier global config units. Within one config the | ||
| # documented later-include-wins rule still controls the task's source context. | ||
| assert \ | ||
| "MISE_GLOBAL_CONFIG_FILE='$HOME/global-config/include-order.toml' MISE_SYSTEM_CONFIG_FILE='$HOME/global-config/missing.toml' mise run include-winner" \ | ||
| "$HOME/second-global-tasks/include-winner" |
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,23 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| export MISE_EXPERIMENTAL=1 | ||
|
|
||
| marker="$MISE_TMP_DIR/monorepo-config-render-count" | ||
| mkdir -p apps/example | ||
|
|
||
| cat <<'EOF' >mise.toml | ||
| monorepo_root = true | ||
|
|
||
| [monorepo] | ||
| config_roots = ["apps/*"] | ||
| EOF | ||
|
|
||
| cat >apps/example/mise.toml <<EOF | ||
| [tasks.render-once] | ||
| description = "{{ exec(command='echo rendered >> $marker') }}" | ||
| run = "echo render-once" | ||
| EOF | ||
| ln -s mise.toml apps/example/mise.local.toml | ||
|
|
||
| mise tasks --all >/dev/null | ||
| assert "wc -l < '$marker' | tr -d ' '" "1" |
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,63 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| mkdir -p "$HOME/.config/mise/conf.d" "$HOME/.config/mise/tasks" | ||
|
|
||
| marker="$MISE_TMP_DIR/source-comparison-exec-marker" | ||
| script="$HOME/.config/mise/tasks/same" | ||
|
|
||
| cat <<'EOF' >"$script" | ||
| #!/usr/bin/env bash | ||
| echo same-script | ||
| EOF | ||
| chmod +x "$script" | ||
| cat <<'EOF' >"$HOME/.config/mise/tasks/same-hash" | ||
| #!/usr/bin/env bash | ||
| echo same-hash-script | ||
| EOF | ||
| chmod +x "$HOME/.config/mise/tasks/same-hash" | ||
| cat <<'EOF' >"$HOME/.config/mise/tasks/same-vars" | ||
| #!/usr/bin/env bash | ||
| echo "LOWER_OVERLAY=${LOWER_OVERLAY:-<unset>}" | ||
| EOF | ||
| chmod +x "$HOME/.config/mise/tasks/same-vars" | ||
| cat <<'EOF' >"$HOME/other-vars-script" | ||
| #!/usr/bin/env bash | ||
| echo other-vars-script | ||
| EOF | ||
| chmod +x "$HOME/other-vars-script" | ||
|
|
||
| cat >"$HOME/.config/mise/config.toml" <<EOF | ||
| [task_config] | ||
| includes = [".config/mise/tasks"] | ||
|
|
||
| [vars] | ||
| comparison_path = "$HOME/.config/mise/tasks/same-vars" | ||
| EOF | ||
|
|
||
| cat >"$HOME/.config/mise/conf.d/lower.toml" <<EOF | ||
| [task_config] | ||
| includes = ["empty-global-tasks"] | ||
|
|
||
| [tasks.same] | ||
| file = "{{ exec(command='printf $script; printf x >> $marker') }}" | ||
| env = { LOWER_OVERLAY = "must-not-render-for-comparison" } | ||
| vars = { SIDE_EFFECT = "{{ exec(command='printf y >> $marker') }}" } | ||
|
|
||
| [tasks.same-hash] | ||
| file = "{{ '/definitely/missing' | hash_file }}" | ||
|
|
||
| [tasks.same-vars] | ||
| file = "{{ vars.comparison_path }}" | ||
| vars = { comparison_path = "$HOME/other-vars-script" } | ||
| env = { LOWER_OVERLAY = "must-not-apply" } | ||
| EOF | ||
|
|
||
| mise tasks >/dev/null | ||
| if [[ -e $marker ]]; then | ||
| fail "task source comparison executed a deferred file template" | ||
| fi | ||
|
|
||
| # The active config's vars must not resolve a different task's deferred file | ||
| # path. The task-local value points elsewhere, so treating this as the same | ||
| # source would incorrectly apply the lower overlay to the discovered script. | ||
| assert "mise run same-vars" "LOWER_OVERLAY=<unset>" | ||
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.