fix: refresh for-loop commands after deps#2802
fix: refresh for-loop commands after deps#2802lawrence3699 wants to merge 1 commit intogo-task:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes an execution-order bug where tasks using cmds: - for: sources / for: generates could compile to an empty command list on the first run when those files are produced by dependencies. The PR refreshes the compiled command list after deps complete so loop expansion sees newly created files before fingerprinting/up-to-date checks.
Changes:
- Refactors command compilation into a reusable
compileCmdshelper. - Recompiles
t.CmdsafterrunDepsto refreshfor:loop expansion oversources/generates. - Adds a regression test covering “deps create sources used by
for: sources”.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
variables.go |
Extracts compileCmds and reuses it during task compilation. |
task.go |
Rebuilds compiled command list after dependencies finish running. |
executor_test.go |
Adds regression test to ensure for: sources expands after deps materialize files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
PR #2711 is a variant of the same general issue. If a dep changes something, should the Task be recompiled? What are the somethings?
So a recompile triggered by either of those only would keep the performance hit limited to when you actually want it. Can we trigger only if sources are changed? I think it might be better to just recompile the entire task? So that any templated values get updated, with the idea that this PR gets combined with #2711. |
Fixes #1494
When a task uses
for: sourcesand the matching files are created by a dependency, the first run can skip the task because the command list is compiled before the deps materialize those sources.The issue in #1494 looks like a fingerprint ordering bug at first, but the stale piece is actually the compiled
cmdslist.depsalready run before fingerprinting; the missing step is refreshing commands that loop oversourcesorgeneratesafter those deps finish.This patch keeps the fix scoped to that command-refresh step. It rebuilds the compiled command list after deps complete, so
for: sources/for: generatesloops see newly created files without re-running dynamicsh:vars.Reproduction
Before this change, a clean run only executed
create_deps, anduse_depscould then be treated as up to date because its compiled command list was still empty.After this change, the same first run executes the expanded
use_depscommands and prints all three generated files.Testing
go test ./... -run '^TestForCmdsRecompileAfterDeps$'go test ./...go run ./cmd/task -d /tmp/task1494-repro use_deps