-
-
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
feat: prefer remote taskfiles over cached ones #1345
Conversation
The way I try to frame stuff like this cli-args thing is to consider how both myself and the engineers that I work with would either pass or fail the principle-of-least-astonishment (POLA). In this example, if I were to look at the following syntax in a taskfile,
my gut-reaction before any thinking occurs is that the system is going to download that Taskfile.yml. In other words, my personal POLA is that URLs are not much different than filesystems. I point to a thing and it just gets it. Caching, given the above, is an implementation detail to me as the user; it's invisible. If it works, yay. If it doesn't work, something seems a little slow, but the system still got my file...I wonder why slow...who cares, yay. The above is what I also seem to have been able to grok from my colleagues. So in this regard, my 2c, is that the Happy to hear others opinions. |
Thanks @caphrim007. Really appreciate your thoughts :) I've had a bit more time to think about this. I think the main reasons for the
To extend on point 1. If we kept the So maybe all we need to do is:
|
I think I would want this to behave a bit like dependencies...
I think this is mostly the same as the "always download and cache" with a configurable timeout. But presented in a different way. At least I'm more used to think in terms of dependencies management that in terms of cache/timeout. |
I like @blackjid's idea! For my context, I am wanting to use these 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 I like the idea of having the user force a new download to overwrite the cached files. The auto-update-ttl idea is also great. It would allow users to have the fast latency of not fetching every task run, but also allow automatic updates in a soft manner. Another suggestion, would be to have these as options as keys inside the includes:
my-remote-namespace: https://raw.githubusercontent.com/my-org/my-repo/main/Taskfile.yml
offline: true
auto-update-ttl: weekly Thanks! |
16647a8
to
8d19e59
Compare
Hey all. Thanks for the comments and sorry for the lack of progress on the experiment lately. It's been a busy month or so for me! I've pushed the changes discussed in previous comments and I believe this is ready for a review when @andreynering has some time. @c-ameron I like the idea of a cache TTL, but I'm going to leave this as out-of-scope for now. I don't think this addition will affect the API and could be easily added later. The same goes for adding the flags as keys in the file. The schema is a bit harder to amend for an experiment if we were to change our minds on anything, so I'd like to concentrate on the fundamentals for now (so that we can deliver this experiment quicker) and then revisit these bits later. That said, please feel free to open issues for these features so that they aren't forgotten. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏
any calls to remote sources. | ||
Whenever you run a remote Taskfile, the latest copy will be downloaded from the | ||
internet and cached locally. If for whatever reason, you lose access to the | ||
internet, you will still be able to run your tasks by specifying the `--offline` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we talked on Discord, it'd be interesting to have an offline: true
setting and a TASK_OFFLINE=1
env to allow users to set this once and have it always enabled.
Can be on another PR if you prefer, no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I also created it is an issue as requested :)
#1403
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the functionality here is ready, so let's get this merged. I'll work on the schema/env options in another PR as suggested.
@c-ameron Thanks for creating the issues. I've added them to the TODO list in the experiment issue so they're not forgotten.
of trying to download it. You are able to use the `--download` flag to update | ||
the cached version of the remote files without running any tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are able to use the
--download
flag to update the cached version of the remote files without running any tasks.
Yes, that's the idea 👍
3fb260c
to
dd0ec73
Compare
As per discussion in #1152 (comment), this PR changes the Remote Taskfiles experiment to prefer remote files over locally cached ones.
Previously, if a user used the
--download
flag to cache a file, this file would be automatically preferred over the remote copy. The only way to get a newer version of that file was to delete the cached version entirely.The new behaviour always prefers the remote copy and will always attempt to fetch and use it unless the user specifies the
--offline
flag (in which case Task will search for a cached version).In addition to this, if the network times out, when trying to fetch a remote copy, Task will now search for a cached version and use that instead.
My question now is... Do we need
--download
at all? I would argue that we can now make--download
the default behaviour. i.e. we always cache the file when we download it. If we don't do this, then there is a risk that the cached copy will slowly diverge (if a user doesn't remember to use--download
periodically when the remote copy changes). I think it's safer to assume that the user always wants the latest version of the file cached.I'm also considering a
--timeout
flag. I have set the default to 10 seconds (which seems reasonable to me), but I can see CI/script users wanting to adjust this for various reasons.