267 Commits

Author SHA1 Message Date
Valentin Maerten
2810c267dd feat(scoped): refactor compiler, add nested includes, document flatten
Refactor compiler.go for better maintainability:
- Extract isScopedMode() helper function
- Split getVariables() into getScopedVariables() and getLegacyVariables()
- Fix directory resolution: parent chain env/vars now resolve from their
  own directory instead of the current task's directory

Add nested includes support and tests:
- Add testdata/scoped_taskfiles/inc_a/nested/Taskfile.yml (3 levels deep)
- Add test case for nested include inheritance (root → a → nested)
- Verify nested includes inherit vars from full parent chain

Fix flaky tests:
- Remove VAR from print tasks (defined in both inc_a and inc_b)
- Test only unique variables (UNIQUE_A, UNIQUE_B, ROOT_VAR)

Document flatten: true escape hatch:
- Add migration guide step for using flatten: true
- Add new section explaining flatten bypasses scoping
- Include example and usage recommendations
2026-01-25 19:54:04 +01:00
Valentin Maerten
a57a16efca fix(compiler): add call.Vars support in scoped mode
When calling a task with vars (e.g., `task: name` with `vars:`),
those vars were not being applied in scoped mode. This fix adds
call.Vars to the variable resolution chain.

Variable priority (lowest to highest):
1. Root Taskfile vars
2. Include Taskfile vars
3. Include passthrough vars
4. Task vars
5. Call vars (NEW)
6. CLI vars
2026-01-25 19:54:04 +01:00
Valentin Maerten
e05c9f7793 fix(compiler): CLI vars have highest priority in scoped mode
In scoped mode, CLI vars (e.g., `task foo VAR=value`) now correctly
override task-level vars. This is achieved by:

1. Adding a `CLIVars` field to the Compiler struct
2. Storing CLI globals in this field after parsing
3. Applying CLI vars last in scoped mode to ensure they override everything

The order of variable resolution in scoped mode is now:
1. OS env → {{.env.XXX}}
2. Root taskfile env → {{.env.XXX}}
3. Root taskfile vars → {{.VAR}}
4. Include taskfile env/vars (if applicable)
5. IncludeVars (vars passed via includes: section)
6. Task-level vars
7. CLI vars (highest priority)

Legacy mode behavior is unchanged.
2026-01-25 19:54:04 +01:00
Valentin Maerten
edee501b6b feat(experiments): rename SCOPED_INCLUDES to SCOPED_TASKFILES and add env namespace
Rename the experiment from SCOPED_INCLUDES to SCOPED_TASKFILES to better
reflect its expanded scope. This experiment now provides:

1. Variable scoping (existing): includes see only their own vars + parent vars
2. Environment namespace (new): env vars accessible via {{.env.XXX}}

With TASK_X_SCOPED_TASKFILES=1:
- {{.VAR}} accesses vars only (scoped per include)
- {{.env.VAR}} accesses env (OS + Taskfile env:, inherited)
- {{.TASK}} and other special vars remain at root level

This is a breaking change for the experimental feature:
- {{.PATH}} no longer works, use {{.env.PATH}} instead
- Env vars are no longer at root level in templates
2026-01-25 19:54:04 +01:00
Valentin Maerten
efaea39503 test(scoped-includes): add tests for variable isolation
Tests verify:
- Legacy mode: vars merged globally (A sees B's VAR, can access UNIQUE_B)
- Scoped mode: vars isolated (A sees own VAR, cannot access UNIQUE_B)
- Inheritance: includes can still access root vars (ROOT_VAR)

Test structure:
- testdata/scoped_includes/ with main Taskfile and two includes
- inc_a and inc_b both define VAR with different values
- Cross-include test shows A trying to access B's UNIQUE_B
2026-01-25 19:53:38 +01:00
Timothy Rule
f6720760b4 fix(includes): propagate silent mode from included Taskfiles to tasks (#2640) 2026-01-25 16:33:52 +01:00
Timothy Rule
1bd5aa6bd5 fix: correct the value of ROOT_TASKFILE when no entrypoint (#2635) 2026-01-25 16:06:13 +01:00
Valentin Maerten
6dedcafd7d feat(vars): add interactive prompting for required variables (#2579) 2026-01-22 21:20:45 +01:00
Valentin Maerten
9bc1efbc47 feat: add conditional execution for tasks and commands (#2564) 2026-01-21 23:05:40 +01:00
Valentin Maerten
618cd8956f feat: wildcard match aliases (#2234) 2026-01-18 19:05:29 +01:00
Timothy Rule
d5f071c096 fix: print prefix when task is up-to-date and output-style is prefixed (#2633) 2026-01-18 08:42:18 -03:00
Valentin Maerten
9b95e758f4 fix: cli variables should take priority over aaskfile defaults (#2589)
When using `task FOO=bar` with a Taskfile containing
`FOO: '{{.FOO | default "foo"}}'`, the CLI value was being
overwritten by the Taskfile default.

Split the variable merging into two steps:
1. Merge CLI variables (FOO=bar) first so they override Taskfile vars
2. ReverseMerge special variables (CLI_ARGS, CLI_FORCE, etc.) so
   they're available for templating in Taskfile vars

Fixes regression introduced in #2403.

Co-authored-by: Timothy Rule <timothy.rule@gmail.com>
2025-12-18 17:50:00 -03:00
Andrey Nering
9b99866224 feat: add --failfast and failtest: true to control dependencies (#2525) 2025-12-07 17:23:08 -03:00
Valentin Maerten
4ab1958df1 feat(summary): add vars, env, and requires display (#2524) 2025-11-29 11:14:20 +01:00
Timothy Rule
386dcbc1a0 fix: adjust run: when_changed to work correctly with imported tasks (#2511) 2025-11-22 17:17:13 -03:00
Graham Dennis
94f82cbc5a fix: make task failure errors include stack of running tasks (#2286)
Previously if a task was run as a dependency of another task,
the error message simply reported something like:

    exit status 1

It is desirable instead to name the root task and all child tasks in the tree
to the failing task.

After this PR, the error message will read:

    task: Failed to run task "root": task: Failed to run task "failing-task": exit status 1
2025-11-11 16:40:40 -03:00
Valentin Maerten
48039be12c feat: improve fingerprint, run and output with wildcard (#1808) 2025-09-11 19:33:53 +02:00
Pete Davison
1c6d686356 chore: replace PPRemoveAbsolutePaths with generic fixture template data (#2265)
* chore: replace PPRemoveAbsolutePaths with generic fixture template data

* chore: update to goldie v2.7.1
2025-07-23 21:57:25 +01:00
Max Mizikar
fe2da74ea3 fix: don't suggest internal tasks (#2323)
Co-authored-by: Max Mizikar <maxmzkr@gmail.com>
2025-07-09 18:36:40 +01:00
Pete Davison
71eb8cdeea feat: checksum pinning (#2223) 2025-05-24 14:00:02 +01:00
Aleksander Sh.
bb5b045293 feat: add task name to json output (#2256) 2025-05-20 21:37:57 +01:00
Pete Davison
c12ed49acb chore: remove unused any2 testdata 2025-04-28 21:04:24 +00:00
Valentin Maerten
a33544101a fix: fuzzy model was not instanciated (#2200)
* fix: fuzzy model was not instanciated

* add test

* add test
2025-04-28 00:00:54 +01:00
Pete Davison
8162b05f59 Revert "feat: process variables in include vars (#2113)"
This reverts commit f0414f162d.
2025-04-27 22:15:49 +00:00
Valentin Maerten
7169bf6434 fix: interpolate vars in defer (#2173) 2025-04-21 13:43:20 -03:00
Artem Sedykh
6f0f38b8d9 feat: support for loops with generates (#2151) 2025-04-05 23:55:43 +01:00
Pete Davison
f0414f162d feat: process variables in include vars (#2113)
* feat: process variables in include vars

* feat: add test for include variables
2025-04-05 23:12:54 +01:00
Pete Davison
55790be6ad feat: better versioning (#2131) 2025-04-05 23:09:27 +01:00
Pete Davison
4736bc2734 refactor: unify how executor tests are written (#2042)
* feat: use TaskTest for executor tests

* feat: more tests

* feat: separate tests for executing and formatting with new functional options that work for both test types

* feat: formatter tests

* refactor: more tests
2025-03-31 17:53:58 +01:00
Andrey Nering
0d5f2b5dab feat(watcher): migrate to fsnotify (#2048) 2025-03-22 20:06:16 -03:00
Valentin Maerten
c23c46e326 fix: include with dynamic vars (#2092) 2025-02-26 17:49:05 +01:00
Pete Davison
d6234af49a feat: allow variable references in a matrix (#2069) 2025-02-23 18:13:56 +00:00
Valentin Maerten
35ea4e0460 feat: display allowed values when vars are not provided (#2052) 2025-02-20 20:08:14 +01:00
Valentin Maerten
c995fe6d11 fix(checker): use only one checker at the same time to improve perf (#2031)
* fix(checker): use only one checker at the same time to improve performance

* refactor

* fix test
2025-02-08 17:34:04 +01:00
Valentin Maerten
80f96d67da fix: requires allowed values works with dynamic var (#2033) 2025-02-08 17:29:36 +01:00
Pete Davison
b5b1524d3a feat: variable inheritance tests (#2038) 2025-02-05 19:51:52 +00:00
rohm1
24a830e384 fix: forward env to RunCommand when evaluating sh vars (#1869)
* forward env to RunCommand when evaluating sh vars. fixes #1742

* feat: added tests

* fix: test

---------

Co-authored-by: Pete Davison <pd93.uk@outlook.com>
2025-01-02 20:07:25 +00:00
Niklas Rousset
c1e14c461b feat: make CHECKSUM and TIMESTAMP vars available in cmds commands (#1872) 2024-12-31 16:04:42 +01:00
Valentin Maerten
da40aabcc7 fix: task level vars are not ignored in requires (#1960)
Co-authored-by: MOKEKO <Anthurium.1605@gmail.com>
2024-12-30 19:11:27 +01:00
Valentin Maerten
9d8c4ba7e6 feat: add TASK_DIR special variable (#1961)
Co-authored-by: Pete Davison <pd93.uk@outlook.com>
2024-12-30 11:45:25 +01:00
Valentin Maerten
d64df3f9d7 fix: evaluate requires before compiled task (#1962) 2024-12-30 10:15:17 +01:00
Valentin Maerten
5f1d46c770 feat: can exclude task from being included (#1859) 2024-12-30 10:09:28 +01:00
Danilo Bürger
4595c1e32a feat: add silent for defer (#1879)
Co-authored-by: Valentin Maerten <maerten.valentin@gmail.com>
2024-12-07 16:16:27 +01:00
Oleksandr Redko
390220ec9c fix: typos in docs, changelog, testdata, comments (#1910) 2024-11-07 13:25:59 -03:00
Matheus Mina
5581954fb1 feat: allow providing single or multi prompts (#1866)
* Add new type to handle single or multi prompts

* update docs

* apply review
2024-10-29 13:37:03 +00:00
Valentin Maerten
a35910429c feat: option to ensure variable is within the list of values (#1827) 2024-10-18 18:16:57 +02:00
Paulo Bittencourt
8dd3f4b119 refactor: re-organize node loading code to make it easier to follow (#1771) 2024-10-18 18:13:25 +02:00
Paulo Bittencourt
a72e70b026 fix: inconsistent current directory resolution depending on include order (#1757) 2024-10-05 21:40:22 -03:00
Paulo Bittencourt
8d0f0b049c fix: Print dotenv file path when there is an error reading file (#1842) 2024-09-29 16:03:48 -04:00
Valentin Maerten
5eaf0b2dcd fix: interpolate dynamic vars in defer (#1818) 2024-09-19 08:22:39 -04:00