Skip to content

run: when_changed not deduping properly in some cases #2508

@bennieswart

Description

@bennieswart

Description

Consider the following files in which the reusable task is included from multiple locations.

# Taskfile.yml

version: '3'

includes:
  lib:
    taskfile: Taskfile.lib.yml
  other:
    taskfile: Taskfile.other.yml

tasks:
  all:
    deps:
      # Both run for same vars
      - task: lib:reusable
        vars:
          V: x
      - task: other:lib:reusable
        vars:
          V: x

      # Both run for same vars
      - task: lib:reusable
        vars:
          V: y
      - task: other:lib:reusable
        vars:
          V: y

      # These don't run; properly deduped.
      - task: lib:reusable
        vars:
          V: x
      - task: other:lib:reusable
        vars:
          V: x
      - task: lib:reusable
        vars:
          V: y
      - task: other:lib:reusable
        vars:
          V: y
# Taskfile.other.yml

version: '3'

includes:
  lib:
    taskfile: Taskfile.lib.yml
# Taskfile.lib.yml

version: '3'

tasks:
  reusable:
    cmd: echo running reusable with V={{.V}}
    run: when_changed
    # label has no effect
    label: reusable-{{.V}}

Running this gives the following output:

$ task all
task: [reusable-x] echo running reusable with V=x
task: [reusable-x] echo running reusable with V=x
task: [reusable-y] echo running reusable with V=y
task: [reusable-y] echo running reusable with V=y
running reusable with V=x
running reusable with V=y
running reusable with V=x
running reusable with V=y

The expected output is:

$ task all
task: [reusable-x] echo running reusable with V=x
task: [reusable-y] echo running reusable with V=y
running reusable with V=x
running reusable with V=y

This minimal(ish) example is distilled from a part of my setup where I have a reusable task to install dependencies (node/python etc) in a directory. The path is given with a variable and the expectation is that the task only runs once per directory. I'm pretty sure that run: when_changed shouldn't behave differently based on the way it was included (main -> lib vs main -> other -> lib).

Version

3.45.4

Operating system

ubuntu:24.04 (docker container)

Experiments Enabled

No response

Example Taskfile

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