task icon indicating copy to clipboard operation
task copied to clipboard

How to force task but not its dependencies

Open sheerun opened this issue 5 years ago • 7 comments

Hello,

I'm working on developing a task and I'd like to re-run just it even it's up to date, but I don't want its dependencies to run because they take long time to run and I already know they are correct.

Is there a way to force running just particular task and skip its dependencies other than commenting "deps" for this task in Taskfile?

sheerun avatar Mar 19 '19 12:03 sheerun

Hi @sheerun,

Today this still isn't possible, unless you edit the Taskfile as you said.

Maybe you could achieve that by refactoring your Taskfile. For example, having two tasks, one with deps and the other without. To share the code, you could have a third one that would be called by these two using task: foo.

(Not sure how much sense it makes since I don't know what you're trying to do).

Regarding allowing forcing a single task, we could add another flag for that (e.g. --force-task=foo as an alternative to --force). Does that makes sense?

andreynering avatar Mar 23 '19 19:03 andreynering

I think --force should force only explicitly listed tasks. For example if there are tasks A, B, C and A depends on B and B depends on C, then task A --force should force only task A and do B, C only if necessary, task A B --force should force tasks A, B and perform C if necessary. Maybe this could be on v3 wishlist :)

sheerun avatar Mar 24 '19 15:03 sheerun

If you do task A B C as described above, A->B->C, B->C, and C are started in parallel so that C is potentially run three times, B two times, and A once.

smyrman avatar Mar 24 '19 17:03 smyrman

Just stating how it currently works.

smyrman avatar Mar 24 '19 17:03 smyrman

In my example above the dependency is just A->B->C, sorry if wasn't clear enough

As for your example, running C 3 times is something to be improved as well for v3, IMO..

sheerun avatar Mar 24 '19 18:03 sheerun

@sheerun

I think --force should force only explicitly listed tasks.

That's a good point. But it's also a breaking change. And I'm sure there're users out there that'd expect that to work exactly how it works today: --force forces everything.

So ideally, we have to find a way to make both use cases possible.

As for your example, running C 3 times is something to be improved as well for v3, IMO..

There's a jurassic issue for that already: https://github.com/go-task/task/issues/53. That discussion is old, so don't expect our opinions to be the same nowadays. But sure, we should look into fixing that.

andreynering avatar Mar 25 '19 01:03 andreynering

I'm curious how you know the dependencies are up to date? Can you encode that information in the status of those dependencies?

ghostsquad avatar May 16 '22 00:05 ghostsquad

Closing in favor of #1200.

andreynering avatar Jun 03 '23 22:06 andreynering

@sheerun @smyrman and any others who have upvoted this issue. Just pinging to let you know that #1200 (the experiment that adds the functionality described here) is now in a period for final comments/adjustments before it is marked as stable ahead of a future major release.

Please do give it a try and let us know if you have any feedback/comments. Once this is marked as stable, it will be very unlikely to change again.

pd93 avatar Aug 01 '23 14:08 pd93