T
Task2mo ago
nck

Working out why a task with sources and generates is considered up to date

I have a task that looks something like:
zip_foo:
deps: [update_target]
sources:
- "{{ .TARGET_DIR }}/**"
generates:
- foo.zip
cmds:
- zip -r foo.zip {{ .TARGET_DIR }}
zip_foo:
deps: [update_target]
sources:
- "{{ .TARGET_DIR }}/**"
generates:
- foo.zip
cmds:
- zip -r foo.zip {{ .TARGET_DIR }}
After the first time I run the task, it always claims that it is up to date, even though the update_target task runs and changes the contents of the target directory. I'm stuck trying to work out why it isn't updating. Is there a way to check what is being hashed and why it isn't consided out of date?
2 Replies
pd93
pd932mo ago
The generated hash is stored in the .task directory. However, there is no way to see which files this hash represents. The behaviour that you're describing shouldn't be happening though. I created a full example similar to yours that seems to work fine
version: '3'

vars:
TARGET_DIR: ./asdf

tasks:
default:
deps: [update_target]
sources:
- "{{ .TARGET_DIR }}/**"
generates:
- foo.zip
cmds:
- zip -r foo.zip {{ .TARGET_DIR }}

update_target:
cmds:
- echo $(date) > {{ .TARGET_DIR }}/source.txt
version: '3'

vars:
TARGET_DIR: ./asdf

tasks:
default:
deps: [update_target]
sources:
- "{{ .TARGET_DIR }}/**"
generates:
- foo.zip
cmds:
- zip -r foo.zip {{ .TARGET_DIR }}

update_target:
cmds:
- echo $(date) > {{ .TARGET_DIR }}/source.txt
nck
nck2mo ago
I got it working with a change to sources to glob {{ .TARGET_DIR }}/**/*, then it behaves as expected. Having some way to find out what it's really hashing would probably have made that obvious.