task icon indicating copy to clipboard operation
task copied to clipboard

Provide equivelent of make's `--touch`

Open danielrbradley opened this issue 2 years ago • 1 comments

Make's --touch option allows the explicit marking of a target and it's dependencies as up-to-date, even if their outputs don't exist. It would be helpful to have an equivilent function in task which works for both the timestamp and checksum methods of fingerprinting.

Use case

  • We define testing targets which depend on building a binary asset.
  • In our CI system we build the binary asset once before starting parallel jobs for each testing target.
  • When starting each testing target we restore the finary binary asset from the first stage, but not any intermediate assets, then mark the target as up-to-date with --touch.

Example task flow:

                          ┌─────► test suite A
                          │
prerequisite ────► build ─┼─────► test suite B
                          │
                          └─────► test suite C

Workarounds

  1. Rebuild the binary assets on each of testing jobs (not ideal)
  2. Remove the task dependencies between the test tasks and the binary asset (not ideal for local development)
  3. Create additional testing targets - one of each for local testing and one of each for CI.
  4. Create a manual touch task to manually create stub intermediate assets. This only works if using timestamp fingerprinting.

danielrbradley avatar May 30 '22 08:05 danielrbradley

Hi @danielrbradley, thanks for opening this issue!

I'd be happy to review a pull request for this!

Implementation tips:

  • For timestamp tasks, it's just a matter of updating the destination files timestamp. That's what Make do
    • Questions:
      • If destination files does not exist, should we create it as empty?
      • And what if a task only have a star glob (dir/**.go) in generates? We don't know how to name the file in that dir
  • For checksum tasks, we need to update the checksum file inside the .task dir while skipping everything else

https://github.com/go-task/task/blob/c9a582fbcc81aa86fe9e5b9b38fb8de10c342583/internal/status/checksum.go#L46-L49

andreynering avatar Jun 11 '22 23:06 andreynering