-
-
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: check and cache the task definition, variables, status #1401
base: main
Are you sure you want to change the base?
Conversation
bfe40d2
to
e2449fe
Compare
@andreynering Would you take a look at this pull request? |
Hi @aminya! First of all, thanks for your contribution! After a quick look, the code itself seems to go in the right direction. As said in comments like #548 (comment), #455 (comment) and #455 (comment), enabling this could add some unintended side-effects. Also, it would be a breaking change (although a relatively small one). In other words: this needs a bit more thought. I think this could maybe be enabled via a global setting in the Taskfile. /cc @pd93 (just in case you have any thoughts) |
Hey both, just adding some
More specifically, it appears that you went with the second option that I outlined which I think has some flaws. Mainly that I don't think changing a Task's Additionally, I'm not convinced that enabling this new behaviour by default is the correct decision. Sometimes running a task can be destructive and this is why we write status checks - to ensure that a task will not run depending on the state of the system. Overwriting this behaviour when a task's definition changes will absolutely trip someone up at some point. Especially given that a task's command could change entirely and still have the same outcome as before. One way or another, we have to accept one of two fates. Either:
We have a responsibility to ensure that Task users have confidence in the outcome of their commands when they run them and I think the second option goes against this. Particularly when you consider that the first problem can be quickly solved by intuitively adding the If there is a desire from the community/other maintainers to continue with this change then I would like to entertain some ways that we can make it clearer to the user that a task's cache is invalidated when the definition changes. A couple of ideas that I haven't given much thought:
|
@pd93 I think instead of making things complicated and keeping the current buggy behaviour, we can do this:
Doing this will solve your concerns regarding destructive tasks, but will also fix the current buggy behaviour where sometimes tasks do not run although the environment variables have changed. I also want to mention that the current buggy behaviour is also dangerous. For example, I expect the task to run again when a variable changes, but currently
This pull request fixes this case, which is the main pain point of using caching with Task If you want this to be configurable, we can add a
|
439d09c
to
8ae936e
Compare
I have updated the approach to be configurable. Now, by default If desirable, Rebased the branch and added tests to check and support the addition. |
Is there any reason why this was not merged? Fixing conflicts takes time every time. I appreciate some feedback @andreynering |
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
I have rebased this branch again. Could you take a look? @andreynering @pd93 |
For those waiting on this essential feature: I ended up forking In GitHub Actions, I have something like this to patch task via these binaries: Details - name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
task: true
- name: Patch Task
run: |
cd ~/task
curl -LJO https://github.com/aminya/task/releases/download/v3.18.0/task_linux_amd64.tar.gz
tar -xvf task_linux_amd64.tar.gz
chmod +x ./task
rm task_linux_amd64.tar.gz
task --version |
Hi @aminya, I'm sorry for the wait! I know many months have passed. The thing is just that this project demands more work than we actually have to dedicate to it, so we advance in the speed we can. Thanks for your patience! Hopefully I'll be able to review this soon. I want to try this feature to have a clearer opinion on how this should behave. |
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.The approach is configurable through
check_definition
. Now, by default ("auto"
), the definition is considered when the sources are defined and not the status checks. If desirable,check_definition
can be set to"always"
to always consider the definition of the task. It can be also disabled via"never"
altogether regardless of other conditions.Fixes #548
Fixes #455