task
task copied to clipboard
Feature request: Add command to mark task as up-to-date without running / executing
Hello! Huge fan of this tool, and I'd like to propose a new feature that I often wish existed when working with "expensive" tasks (that take a long time to run and/or use a lot of resources) - a way to mark a task as up-to-date without actually running it.
Something like task --mark-up-to-date MY_TASK, which does not execute any of the commands or has any side-effect other than updating the fingerprint / hash in .task/checksum as if it had actually ran.
This is almost like an inverse command of
--force
Use Case
The use-case here is that sometimes I have tasks where I perform an action that updates its dependencies outside of task, and I know that the given task is now up-to-date, but task doesn't.
This most often comes up when dealing with package management / installing dependencies. For example, let's say I have a full-stack web-app with Python and some sort of JS framework. I might have some tasks that look like this:
version: "3"
tasks:
# Keep JS packages up-to-date
install:js:
sources:
- package*..json
cmd: npm ci
# Keep Python packages up-to-date
install:py:
sources:
- requirements.txt
cmd: pip install -r requirements.txt
# Running `task build` will auto re-install packages if there are changes
build:
- task: install:js
- task: intall:py
- npm run build
Most of the time, this feels magical: if I checkout someone else's branch who has changed packages / required modules, and run task build, I don't have to remember to manually update my local deps to match. However, if I manually do something like npm install {some-random-package}, the next time I run task build it is going to detect that package-lock.json has changed and completely rebuild node_modules, even though it is up to date.
This is where a task --mark-up-to-date install:js option would be wonderful.
There are ways around this (e.g., npm ci is not the fastest way to update deps, although it is the "cleanest"), so I want to make it clear this isn't the only use case. Pretty much any task that takes a long time to run and potentially is already-up-to-date due to user actions outside of a task is a prime candidate.
Other Notes / Wrap-up
I wanted this badly enough that I slapped together a somewhat-hacky workaround (here) that clones an existing task entry, but without the command(s) / side-effects, runs it, and then writes over the fingerprint hash file. It works, but obviously I'd prefer this functionality just be built into the application natively.
Is this something that there are already any plans to implement? Or something that y'all would be open to?
Hi @joshuatz,
This is an interesting idea, indeed! Shouldn't be difficult to implement.