go-task / task

A task runner / simpler Make alternative written in Go
https://taskfile.dev
MIT License
11.43k stars 617 forks source link

Feature Request: Have an auto update ttl for downloaded taskfiles #1402

Open c-ameron opened 12 months ago

c-ameron commented 12 months ago

As discussed here, it would be great to have an auto-cache-ttl setting for downloaded taskfiles.

Context: I am wanting to use the remote features to have a standard set of taskfile includes across my org.

For me, I would like it to download first, then by default always use the cache. I run taskfile a lot, (multiple times a minute if I'm running a debugging command like task test -- feature/a ), so having extra network overhead wouldn't be useful. I understand that there is work on on offline flag, but using that would mean my taskfiles would need manual updating. Having some kind of auto-update-ttl would allow users to have the fast latency of not fetching every task run, but also allow automatic updates in a soft manner.

Thanks for all your hard work on this great tool!

jlucktay commented 4 months ago

Hihi, I'm wondering if I can take a shot at implementing something here to help out. The remote taskfiles feature would be of great use in my current role. Would this else branch be the right place to start?

@andreynering @pd93 any notes? 🙏

pd93 commented 4 months ago

Hihi, I'm wondering if I can take a shot at implementing something here to help out. The remote taskfiles feature would be of great use in my current role. Would this else branch be the right place to start?

@andreynering @pd93 any notes? 🙏

Hi @jlucktay. You're welcome to give this a go. This should probably be implemented in the Taskfile cache. Adding a TTL to that struct and then checking the files last modified time. or possibly adding a timestamp to the cached filename? --remote-cache-ttl should be a CLI flag and we might want a TASK_REMOTE_CACHE_TTL env var too.

The OP says that they'd like to change the default behaviour to use the cache first (instead of using the remote first). However I think this is outside the scope of the TTL work and is a separate decision that needs to be made before remote Taskfiles are made generally available. I don't think that setting a TTL by itself should modify this behaviour.

jlucktay commented 4 months ago

Thanks for the steer! I sketched out a flowchart on my fork's branch and will see how I go getting something built.