Skip to content
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

Feature request: Add command to mark task as up-to-date without running / executing #1496

Open
joshuatz opened this issue Feb 6, 2024 · 1 comment
Labels
area: fingerprinting Changes related to checksums and caching.

Comments

@joshuatz
Copy link
Contributor

joshuatz commented Feb 6, 2024

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?

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Feb 6, 2024
@andreynering andreynering added type: feature A new feature or functionality. area: fingerprinting Changes related to checksums and caching. and removed state: needs triage Waiting to be triaged by a maintainer. labels Feb 6, 2024
@andreynering
Copy link
Member

Hi @joshuatz,

This is an interesting idea, indeed! Shouldn't be difficult to implement.

@pd93 pd93 removed the type: feature A new feature or functionality. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: fingerprinting Changes related to checksums and caching.
Projects
None yet
Development

No branches or pull requests

4 participants