Skip to content

feat(tasks): monorepo vars and per-task vars#8248

Merged
jdx merged 1 commit intojdx:mainfrom
halms:fix/expose-vars-in-toml-file-tasks
Mar 2, 2026
Merged

feat(tasks): monorepo vars and per-task vars#8248
jdx merged 1 commit intojdx:mainfrom
halms:fix/expose-vars-in-toml-file-tasks

Conversation

@halms
Copy link
Contributor

@halms halms commented Feb 18, 2026

Technically partially a fix and partially a new feature, but since it touches similar code, I put it into a single PR.

Currently vars (unlike env) are not correctly inherited for monorepo tasks.
So vars defined in monorepo child are not available for it's tasks when called from monorepo root.

Also: adding vars key to toml task definition so that we can specify per-task variables. This especially becomes useful with the new task templates.

Copilot AI review requested due to automatic review settings February 18, 2026 21:32
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @halms, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances variable management within the task system. It resolves a previous issue where vars were not properly inherited in monorepo setups, thereby ensuring consistent variable access across different configuration levels. Furthermore, it introduces a new feature that allows users to define variables directly within task definitions, providing fine-grained control and improved adaptability for task configurations and templating.

Highlights

  • Monorepo Variable Inheritance: The system now correctly inherits vars in monorepo tasks, ensuring that variables defined in child configurations are accessible when running subdirectory tasks from the monorepo root.
  • Per-Task Variables: Introduced the capability to define vars directly within individual task definitions in toml files, allowing for task-specific variable overrides and greater flexibility, especially with task templates.
Changelog
  • docs/tasks/monorepo.md
    • Updated the "Tool and Environment Layering" section to explicitly include vars layering.
    • Added a note clarifying that vars follow the same hierarchical layering for task templating in monorepos.
  • docs/tasks/task-configuration.md
    • Added a new section demonstrating how tasks can define task-local vars to override global or inherited configuration variables.
    • Included mise-toml examples illustrating the definition and usage of task-local vars.
    • Updated an existing example to showcase vars being defined directly within a task.
  • schema/mise-task.json
    • Added a vars property to the task definition within the schema, referencing the #/defs/vars definition.
  • schema/mise.json
    • Added a vars property to the task definition within the main mise configuration schema, referencing #/defs/vars.
  • src/config/mod.rs
    • Added a new asynchronous test, test_load_task_file_supports_per_task_vars, to verify that task files correctly load and apply per-task variables.
  • src/task/mod.rs
    • Introduced TASK_VARS_CACHE for caching resolved task variables to optimize performance.
    • Added a vars field to the Task struct, enabling tasks to hold their own specific variables.
    • Modified the tera_ctx method to resolve and incorporate both base (monorepo inherited) and task-specific variables into the Tera context.
    • Implemented resolve_base_vars to manage variable inheritance across monorepo configurations.
    • Implemented resolve_task_vars to process and resolve variables defined directly within a task.
    • Updated the Default implementation for Task to properly initialize the new vars field.
  • src/task/task_template.rs
    • Added a vars field to the TaskTemplate struct.
    • Modified the merge_template method to correctly deep-merge vars from a template into a task, ensuring local overrides are prioritized.
    • Included a test, test_merge_template_vars_deep_merge, to confirm the expected behavior of vars merging.
Activity
  • No human activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for vars in monorepo tasks and per-task vars, which is a great enhancement for task configuration and templating. The changes correctly handle vars inheritance in monorepos and allow overriding them at the task level. The documentation and schema updates are also comprehensive.

I've added one suggestion for a potential refactoring to reduce code duplication, which could improve long-term maintainability. Overall, this is a solid contribution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for per-task variables and fixes monorepo vars inheritance. Tasks can now define local vars that override config-level vars, and monorepo child config vars are properly inherited when tasks are called from the root.

Changes:

  • Added vars field to Task and TaskTemplate structs with deep merge semantics (template vars + task vars, task overrides)
  • Implemented vars resolution for monorepo tasks by loading the full config hierarchy from the task's directory
  • Added caching for resolved monorepo vars to improve performance

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/task/task_template.rs Adds vars field to TaskTemplate with deep merge logic and test
src/task/mod.rs Adds vars field to Task, implements resolve_base_vars and resolve_task_vars methods with caching
src/config/mod.rs Adds test validating per-task vars are resolved in task descriptions
schema/mise.json Adds vars schema reference to task definitions
schema/mise-task.json Adds vars schema reference to task definitions
docs/tasks/task-configuration.md Documents task-local vars with examples
docs/tasks/monorepo.md Documents vars layering behavior in monorepo contexts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@halms halms force-pushed the fix/expose-vars-in-toml-file-tasks branch 2 times, most recently from 1f32bb7 to 50f7a31 Compare February 18, 2026 22:10
@halms halms requested a review from Copilot February 18, 2026 22:15
@halms
Copy link
Contributor Author

halms commented Feb 18, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for per-task variables (vars) and fixes an issue with vars inheritance in monorepos. The changes include updates to documentation, JSON schemas, and the core logic for task and configuration handling. Overall, the implementation is solid, but I've found a bug in how task-level variables are resolved which prevents them from referencing config-level variables. I've also noted a small improvement for consistency in lock handling.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@halms halms force-pushed the fix/expose-vars-in-toml-file-tasks branch 2 times, most recently from 8a44caf to 96e0d5d Compare February 19, 2026 11:41
Copy link
Owner

@jdx jdx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! The extraction of resolve_vars_from_config_files is clean and the template merge logic correctly mirrors the existing env pattern. A few observations:

E2E test coverage: There are unit tests for template merging and config-level rendering, but no E2E tests. An E2E test with a monorepo setup (child mise.toml defining vars + a task using {{vars.foo}}) would help catch integration issues.

Double tera_ctx.insert("vars", ...) in tera_ctx(): The two-phase insert (base vars first, then extend with task vars) is correct — it lets task-level var templates reference base vars. A brief comment explaining why it's done twice would help future readers.

resolve_task_vars calls ts.full_env() on every invocation: Since the result depends only on config + toolset, this could be passed in from the caller or cached if many tasks use per-task vars. Not blocking but worth noting.

Docs example at task-configuration.md ~line 625: The example now shows both config-level e2e_args = '--headless' and task-level vars = { e2e_args = '--headed' } but doesn't explicitly call out the override behavior. A one-liner like "The task-level var overrides the config-level value" would clarify.


This review was AI-generated by Claude Code

@halms
Copy link
Contributor Author

halms commented Mar 1, 2026

I'll look into the feedback the coming days.

@halms halms force-pushed the fix/expose-vars-in-toml-file-tasks branch 3 times, most recently from 360260d to addfa55 Compare March 2, 2026 00:19
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@halms halms force-pushed the fix/expose-vars-in-toml-file-tasks branch from addfa55 to bb12e02 Compare March 2, 2026 00:38
@jdx jdx merged commit 149e381 into jdx:main Mar 2, 2026
34 checks passed
jdx pushed a commit that referenced this pull request Mar 2, 2026
### 🚀 Features

- **(hooks)** add task references to hooks and watch_files by @jdx in
[#8400](#8400)
- **(prepare)** add git-submodule built-in provider by @jdx in
[#8407](#8407)
- **(prepare)** add human-readable stale reasons to prepare output by
@jdx in [#8408](#8408)
- **(prepare)** add dependency ordering to prepare steps by @jdx in
[#8401](#8401)
- **(prepare)** add --explain flag for provider diagnostics by @jdx in
[#8409](#8409)
- **(prepare)** add per-provider timeout support by @jdx in
[#8405](#8405)
- **(prepare)** add blake3 content-hash freshness checking by @jdx in
[#8404](#8404)
- **(tasks)** monorepo vars and per-task vars by @halms in
[#8248](#8248)

### 🐛 Bug Fixes

- **(aqua)** restore bin_paths disk cache with fresh_file invalidation
by @jdx in [#8398](#8398)
- **(idiomatic)** use generic parser for idiomatic files by @risu729 in
[#8171](#8171)
- **(install)** apply precompiled options to all platforms in lockfile
by @jdx in [#8396](#8396)
- **(install)** normalize "v" prefix when matching lockfile versions by
@jdx in [#8413](#8413)
- **(prepare)** improve git submodule parser and fix check_staleness
error handling by @jdx in [#8412](#8412)
- **(python)** respect precompiled settings in lock file generation by
@jdx in [#8399](#8399)
- **(python)** clarify uv_venv_auto docs + prevent uv shim recursion in
venv creation by @halms in
[#8402](#8402)
- **(task)** remove deprecated `# mise` task header syntax by @jdx in
[#8403](#8403)
- **(vfox)** avoid eager metadata loading during config file detection
by @jdx in [#8397](#8397)
- clarify GitHub attestations to be artifact ones by @scop in
[#8394](#8394)
- ignore comments in idiomatic version files by @iloveitaly in
[#7682](#7682)

### 🚜 Refactor

- unify archive detection by @risu729 in
[#8137](#8137)

### 📚 Documentation

- remove duplicated docs for npm.package_manager by @risu729 in
[#8414](#8414)
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.

3 participants