Skip to content

Up-to-Date Check wrong when executing task in Subdirectory #2304

@deicon

Description

@deicon

Description

Problem

I do have a Taskfile with a number of common tasks, which should all be runnable within a mono repo directory structure.

monorepo
├── backend-one
│   ├── src
│   │   └── Main.c
│   └── target
├── backend-two
│   ├── src
│   │   └── Main.c
│   └── target
└── Taskfile.yml

For simplicity here are 2 backends, each having a Main.c. All Main.c Files are of course different and will produce different checksums.

To compile each backend I want to be able to

cd backend-one
task compile

to compile the Main.c and produce a Main.o

version: '3'

tasks:

  clean: 
    dir: "{{ .USER_WORKING_DIR }}"
    cmds:
      - rm -rf target/*
    

  compile:
    dir: "{{ .USER_WORKING_DIR }}"
    sources: 
      - "src/Main.c"
    generates:
      - "target/Main.o"
    cmd: gcc -c src/Main.c -o target/Main.o

Expected

Everytime I run

cd backend-[one|two|three]
task compile

I want the task to be executed, if not up to date.

Current Result

As the .task directory, storing the checksums is created next to the found Taskfile, this will result in wrong up-to-date checks.

tree monorepo
monorepo
├── backend-one
│   ├── src
│   │   └── Main.c
│   └── target
├── backend-two
│   ├── src
│   │   └── Main.c
│   └── target
└── Taskfile.yml

❯ cd monorepo/backend-one
❯ task compile
task: [compile] gcc -c src/Main.c -o target/Main.o
❯ cd ../backend-two
❯ task compile
task: [compile] gcc -c src/Main.c -o target/Main.o

tree -al ../../monorepo
../../monorepo
├── .task
│   └── checksum
│       └── compile
├── backend-one
│   ├── src
│   │   └── Main.c
│   └── target
│       └── Main.o
├── backend-two
│   ├── src
│   │   └── Main.c
│   └── target
│       └── Main.o
└── Taskfile.yml

So the Expected result for calling compile again in either one of the two backend directories would not execute the compile.

Current

But in fact, as the checksums are stored in the Top Level Directory next to the found Taskfile and are using the Tasks Name as Filename, this will execute in one backend folder.

> pwd
/monorepo/backend-two
❯ task compile
task: Task "compile" is up to date
❯ cd ../backend-one
❯ task compile
task: [compile] gcc -c src/Main.c -o target/Main.o

Version

3.44.0

Operating system

Darwin Macos 15.5 (24F74)

Experiments Enabled

No response

Example Taskfile

version: '3'

tasks:

  clean: 
    dir: "{{ .USER_WORKING_DIR }}"
    cmds:
      - rm -rf target/*
    

  compile:
    dir: "{{ .USER_WORKING_DIR }}"
    sources: 
      - "src/Main.c"
    generates:
      - "target/Main.o"
    cmd: gcc -c src/Main.c -o target/Main.o

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions