-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
Task "generates" not working as expected #1741
Comments
I'm experiencing this same issue.
|
Hello ! # https://taskfile.dev/
version: '3'
silent: true
vars:
GREETING: Hello, World!
tasks:
default:
cmds:
- echo "{{.GREETING}}" > ./test.txt
sources:
- ./test.txt
generates:
- ./test.txt
Note As you are modifying the file in the cmds and the checksum is calculated before cmds are run, you will always get an extra run :
|
Hi @vmaerten. Thank you for the response. May i ask what is the purpose of "generates" currently? |
@ameergituser it's used to split "sources" and "binary generated"
You can find an example showing this usecase directly in our codebase : Lines 81 to 88 in 51c569e
That being said, in your example Does my message answer your question ? |
Hi @vmaerten. Thank you for the explanation. Perhaps an update of the documentation is needed to better explain the behavior? My understanding was as follows:The Why add a
|
Hi, I was also surprised by the current behaviour since in my opinion we also would like to run the task if the binary does not match the one that were last generated with the current set of sources... Duplicating the "generates" to the "sources" allows somewhat to work around this issue but it would be nice to have it handled automatically and properly by the task tool if possible. It shouldn't be very hard to keep track of this, by simply also keeping track of the generated fingerprint after the build... @vmaerten would you be open to such a change ? |
not having checksums for the generated output files can be dangerous. let's say we have checked in generated files (from protobuf for instance) and someone forgot to check in the sources to generate the files, but checked in the generated files and some extra code that depends on the changed proto files (via the generated files). This would cause taskfile to incorrectly think everything is fine and up to date. if I then do changes to the proto files (because I don't know someone forgot to check in the changed source file) new code would be generated but with missing changes, which would most likely cause build failures in subsequent tasks that depends on the generated files. |
According to the documentation for the method attribute on the task:
https://taskfile.dev/reference/schema/#task It clearly says that the checksum is compared for both the sources and the generated files so this is clearly a bug in the current implementation. |
I've got it sort-of working by switching to checksum: tasks:
build:
cmds:
- npx tsc --project .
run: when_changed
sources:
- "**/*.mts"
- "dist/**/*" but, after wiping |
Seems like a bug in the tasks:
build:
cmds:
- npx tsc --project .
run: when_changed
sources:
- "**/*.mts"
- exclude: "dist/**/*"
generates:
- "dist/**/*" but with If this is intended behavior... why does (This is my first time trying Task, so this has been pretty confusing!) |
Hi @andreynering, This issue seems to either be a bug in the application, or a bug in the spec. It is a pain point, and factor on whether to use task or not for newcomers. It is NOT okay to run twice, this can be very expensive and is unnecessary. From my understanding and from what i wrote above, i believe that the sources and generates should operate as follows: Sources
Generates
It would be great to get some feedback on this issue. Thank you. |
Adding this case to document that this current behavior causes confusion. Case #1945 |
No fingerprinting for files listed in "generates" and hence it does not affect when the task executes the "cmds".
Example:
Steps to reproduce:
task
for the first time. It generates the test.txt filetask
again. It always executes thecmds
Am i misunderstanding the
generates
feature? I assumed that files in thegenerates
would be fingerprinted and when these files are changed, then thecmds
would then execute?The text was updated successfully, but these errors were encountered: