Skip to content

fix(task): render task config includes#10225

Merged
jdx merged 5 commits into
jdx:mainfrom
risu729:codex-20260604-092743-8567ab
Jun 6, 2026
Merged

fix(task): render task config includes#10225
jdx merged 5 commits into
jdx:mainfrom
risu729:codex-20260604-092743-8567ab

Conversation

@risu729

@risu729 risu729 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • render task_config.includes entries with the config-file Tera context before resolving local task include paths or git:: task sources
  • expand ~/ for local task include paths and globs before deciding whether they are absolute or config-root-relative
  • add an e2e regression for {{ config_root }}, {{ env.HOME }}, and ~/ includes

Addresses discussion #10209.

Tilde support

I checked the nearby path-like config behavior before adding this. ~/ is already supported for task execution paths such as task dir, task file, and task sandbox allow_read / allow_write, plus env path directives that resolve config paths such as env._.file, env._.source, and env._.python.venv.

task_config.includes is also a config-provided local path/glob list, so this PR follows the existing local-path convention and expands only leading ~/ for local includes. Remote git:: includes are still treated as remote source strings after template rendering.

Template context

task_config.includes is rendered while task files are being discovered, before any specific task exists. The available context is therefore the config-file context, not the task runtime context.

Available values include:

  • env: the pristine process environment plus plain key/value entries from the same config file's [env]
  • config_root: the root directory for the config file that defines task_config.includes
  • cwd: the current working directory captured in the base Tera context
  • mise/base fields from the shared template context, such as mise_bin, mise_pid, mise_env, and the XDG home paths
  • standard mise Tera functions and filters

Task-only values such as usage, a concrete task object, task-level vars/env, and resolved tool information are not available here because includes decide which tasks are loaded.

Tests

  • cargo fmt --check
  • git diff --check
  • bash -n e2e/tasks/test_task_config_includes_templates
  • mise --cd /tmp x shellcheck -- shellcheck -x /home/risu/.worktrunk/risu729/mise/mise.codex-20260604-092743-8567ab/e2e/tasks/test_task_config_includes_templates

Not completed locally:

  • cargo check --all-targets was queued behind existing machine-level Cargo jobs for over 20 minutes, so I stopped only my queued check rather than bypassing the Cargo wrapper.
  • mise run test:e2e e2e/tasks/test_task_config_includes_templates depends on build, so it would have hit the same Cargo queue.

Summary by CodeRabbit

  • New Features

    • Task includes now support template expansion (e.g., {{ config_root }}, ~, {{ env.HOME }}).
  • Bug Fixes

    • Improved error handling and propagation when resolving task includes.
  • Tests

    • Added end-to-end test validating task include template expansion and file globbing.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a0ae8b8a-521e-4956-9e41-46ab21910649

📥 Commits

Reviewing files that changed from the base of the PR and between bb100fb and e104043.

📒 Files selected for processing (7)
  • e2e/tasks/test_task_config_includes_templates
  • src/cli/tasks/ls.rs
  • src/config/config_file/mise_toml.rs
  • src/config/config_file/mod.rs
  • src/config/mod.rs
  • src/task/mod.rs
  • src/task/task_list.rs

📝 Walkthrough

Walkthrough

The PR adds template expansion and error propagation for task include patterns. A new trait method ConfigFile::task_config_includes returns Result<Option<Vec<String>>>, with MiseToml implementation applying template rendering. The core function task_includes_for_dir changes signature to return Result, enabling error handling. Path patterns are normalized via file::replace_path before glob matching. All call sites adapt via explicit error handling or propagation.

Changes

Task Include Template Expansion and Error Propagation

Layer / File(s) Summary
Trait contract and template rendering
src/config/config_file/mod.rs, src/config/config_file/mise_toml.rs
ConfigFile trait gains task_config_includes() returning Result<Option<Vec<String>>>. MiseToml implementation maps include entries through parse_template to render {{ config_root }}, ~, and {{ env.HOME }} templates.
Include resolution and path normalization
src/config/mod.rs
task_includes_for_dir signature changes to Result<Vec<PathBuf>>. expand_task_include applies file::replace_path to normalize patterns before glob matching. load_file_tasks and load_tasks_in_dir use task_config_includes() with error handling via ? and transpose().
Monorepo subdirectory discovery
src/config/mod.rs
Monorepo subdirectory loading calls task_includes_for_dir(...) with ?, propagating errors from the new Result-based signature.
Call site error handling
src/task/mod.rs, src/cli/tasks/ls.rs, src/task/task_list.rs
Task::task_dir explicitly handles Err by logging warning and using empty Vec. TasksLs::run and err_no_task paths propagate errors via ? operator.
E2E test for template expansion
e2e/tasks/test_task_config_includes_templates
Validates template expansion in task_config.includes using {{ config_root }}, ~, and {{ env.HOME }}. Asserts fixture discovery and task execution success.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • jdx/mise#10191: Modifies include-order precedence in load_tasks_in_dir and task_config.includes handling, directly intersecting with this PR's template-expansion and error-propagation changes.

Poem

🐰 Templates bloom in task includes, replacing paths with grace,
{{ config_root }} expands now, ~ and env.HOME find their place,
Errors surface, no more silent failures in the night,
Result types bring clear answers—tasks discover and run right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(task): render task config includes' directly and specifically describes the main change—rendering task config includes with template expansion—which is the primary objective across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Tera template rendering and ~/ expansion for task_config.includes entries, so patterns like {{ config_root }}/tasks/*.toml and ~/home-tasks/*.toml now resolve correctly when task files are being discovered.

  • Introduces task_config_includes() as a new ConfigFile trait method; MiseToml overrides it to run each include string through parse_template before returning, while the default falls back to the raw string list.
  • expand_task_include gains a file::replace_path call before glob/literal resolution, enabling leading ~/ expansion for all local include paths and globs.
  • task_includes_for_dir signature is changed from infallible to Result<Vec<PathBuf>>, and all call sites are updated to propagate or gracefully handle the error; an e2e test covers all three template styles.

Confidence Score: 5/5

Safe to merge — the change is well-scoped, error paths are correctly handled at every call site, and the new behaviour is covered by an e2e regression test.

Template rendering is added only in task_config_includes() and runs against the existing parse_template path already used by all other MiseToml fields. Tilde expansion delegates to the already-tested file::replace_path. The signature change to task_includes_for_dir is mechanical and every call site is updated. No pre-existing infallible code path is silently swallowed.

No files require special attention.

Important Files Changed

Filename Overview
e2e/tasks/test_task_config_includes_templates New e2e regression test covering {{ config_root }}, ~/tilde, and {{ env.HOME }} include patterns; straightforward and passes shellcheck per PR description.
src/config/config_file/mod.rs Adds default trait method task_config_includes() that returns raw includes; MiseToml overrides it with template rendering.
src/config/config_file/mise_toml.rs Implements task_config_includes() override that renders each include string through parse_template using the config-file Tera context before returning.
src/config/mod.rs Plumbs task_config_includes() through load_file_tasks, task_includes_for_dir, and load_tasks_in_dir; adds file::replace_path tilde expansion in expand_task_include; changes task_includes_for_dir signature to return Result.
src/task/mod.rs task_dir() now handles the new Result return from task_includes_for_dir by logging a warning and falling back to the default directory on error.
src/task/task_list.rs Two call sites of task_includes_for_dir updated to propagate the new Result return with ?.
src/cli/tasks/ls.rs Single call site of task_includes_for_dir updated to propagate Result with ?.

Reviews (5): Last reviewed commit: "docs(task): remove task include template..." | Re-trigger Greptile

Comment thread src/task/mod.rs Outdated
@risu729

This comment was marked as outdated.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

This PR currently has failing checks. If this continues for 7 days, it will be closed automatically.

This is warning day 1 of 7.

Please update the PR when you have a chance. Feel free to reopen or create a new PR if it is closed and you'd like to continue working on it.

This comment was generated by an automated workflow.

@risu729 risu729 marked this pull request as ready for review June 5, 2026 18:31
@jdx jdx merged commit bf80b07 into jdx:main Jun 6, 2026
33 checks passed
@risu729 risu729 deleted the codex-20260604-092743-8567ab branch June 6, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants