-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Interpolated variables should be factored into checksum #548
Comments
Also, ideally, the task itself would be checksummed somehow, so that if I change the commands it will re-run. |
Hi @Porges, It's currently possible to instruct Task to invalidate the checksum on specific variables changes by adding a version: '3'
tasks:
generate-file:
cmds:
- ...
label: 'generate-file-{{.VERSION}}' It's a valid discussion whether we should do that by default or not, as you suggested. I think it may be unexpected to some users. For example: if a variable isn't deterministic (a date/time or something) the task will always run and that may not always be the expected behavior. This makes me think that, if done, there should probably be a setting to choose the appropriate behavior. But maybe |
I found myself changing my task file, and later wondering how I was going to invalidate the cache automatically. It's not really just vars, it's actually the entire task definition. I imagine that you may want to checksum the output of I'm curious what people think about having the default behavior include the task definition itself (and variable values) as part of the checksum, with a flag to disable 1 or both of those? |
@ghostsquad: +1 for making the task definition part of the checksum (not sure about interpolations as a new user yet). I admit that I'm new to task, still the first thing I did was adding |
For now, I'm including Taskfile.yml itself in |
I know, and it wasn't fun. Next iteration was Current iteration: a small script that extracts each task from the
|
Hi @ahus1, Have you tried my suggestion done here? #548 (comment) I believe that's what you're are looking for. |
@andreynering - your suggestion will solve AFAIK the problem when a variable changes, as the labels changes with the variable. I don't know what will happen if the variable changes back to the old value: Would it then run again, or will the state with the old variable value / label name will be still there and it will not run? This thread evolved form interpolating variables to also include the body of the task definition, so that whenever the definition changes, the task should run again. The variable/label approach doesn't cover that, so I looked for something else. So I came up with the idea to split the taskfile by tasks, and then use that as a "sources" element. I did some iterations with that, and it looks ok for me. although a bit verbose. |
I think what is realistically needed is a "cache key". I don't know what else that |
I tried using |
#455 already exists where this is discussed. |
This adds a new checker for Task definitions, status, and any other variable that affect a task. The implementation hashes the task structure and writes it to `.task/definition`. In later runs, this is checked to make sure the definition is up-to-date. If the definition has changed (e.g. one of the variables has changed), the task will run again. Fixes go-task#548 Fixes go-task#455
This adds a new checker for Task definitions, status, and any other variable that affect a task. The implementation hashes the task structure and writes it to `.task/definition`. In later runs, this is checked to make sure the definition is up-to-date. If the definition has changed (e.g. one of the variables has changed), the task will run again. Fixes go-task#548 Fixes go-task#455
My workaround is to add a silent command that does nothing except reference the used variables: - cmd: 'true # /{{.WATCH}}/{{.RESTART}}/{{.MODE}}/{{.TEST}}/{{.NAME}}/{{.ARGS}}/'
silent: true So it seems like interpolated variables are factored in with 3.29.1? I think my issue was some of my other usages weren't factored in. Other usages - task: :watchman:client
vars:
WATCH: '{{.WATCH}}'
RESTART: '{{.RESTART}}'
MODE: executable
COMMAND: build/target/{{.MODE}}/intertwine-{{.NAME | trimSuffix "-rs"}}{{if eq .TEST "true"}}-test{{end}} {{.ARGS}} {{.CLI_ARGS}} |
I fixed this issue in It just needs addressing some comments otherwise it works as expected. |
This adds a new checker for Task definitions, status, and any other variable that affect a task. The implementation hashes the task structure and writes it to `.task/definition`. In later runs, this is checked to make sure the definition is up-to-date. If the definition has changed (e.g. one of the variables has changed), the task will run again. Fixes go-task#548 Fixes go-task#455
This adds a new checker for Task definitions, status, and any other variable that affect a task. The implementation hashes the task structure and writes it to `.task/definition`. In later runs, this is checked to make sure the definition is up-to-date. If the definition has changed (e.g. one of the variables has changed), the task will run again. Fixes go-task#548 Fixes go-task#455
This adds a new checker for Task definitions, status, and any other variable that affect a task. The implementation hashes the task structure and writes it to `.task/definition`. In later runs, this is checked to make sure the definition is up-to-date. If the definition has changed (e.g. one of the variables has changed), the task will run again. Fixes go-task#548 Fixes go-task#455
This adds a new checker for Task definitions, status, and any other variable that affect a task. The implementation hashes the task structure and writes it to `.task/definition`. In later runs, this is checked to make sure the definition is up-to-date. If the definition has changed (e.g. one of the variables has changed), the task will run again. Fixes go-task#548 Fixes go-task#455
FWIW: The docs say (emphasis mine):
As a newcomer, it was quite surprising to me that changes in The workaround with My workaround is to (always) write the values (resp. a checksum of theirs) to a file and include that as source: tasks:
init-submodules-status:
internal: true
silent: true
cmds:
- git submodule status --cached | sha256sum | cut -d' ' -f1 > .task/git-submodules-status
run: always
init-submodules:
deps:
- init-submodules-status
sources:
- .gitmodules
- .task/git-submodules-status
cmds:
- git submodule update --init
run: when_changed (Well, I need to re-run basd on changes in the output of a command, but I guess the approach carries over to writing the values of variables into files?) |
Example Taskfile showing the issue
When changing
VERSION
from1
to2
, this should causegenerate-file
to re-run. At the moment it doesn’t because interpolated variables are not incorporated into the checksum.The text was updated successfully, but these errors were encountered: