Skip to content

run: once not working with hierarchies of includes #1864

@postlund

Description

@postlund
  • Task version: Task version: v3.39.2 (h1:Zt7KXHmMNq5xWZ1ihphDb+n2zYLCo4BdRe09AnMMIgA=)
  • Operating system: WSL2 (5.15.153.1-microsoft-standard-WSL2)
  • Experiments enabled: none

This is an extension of #1498. It is more or less the same case where I have software components, e.g, libs, depending on a "tool". The tool Taskfile.yaml will download and set itself up automatically, but should only be run once no matter how many libraries that are using/including it. My difference is that I have a Taskfile.yaml file in the lib directory that forwards tasks to each library, so I can tell task to for instance build/test/lint just all apps or libraries and move includes closer to where each component lives (instead of including everything from the main taskfile). An example looks like this:

./tools/Compiler.yaml
version: "3"

tasks:
  setup:
    run: once
    sources:
      - ./input
    generates:
      - ./output
    cmds:
      - touch output
 
./lib/a/Taskfile.yaml
version: "3"

includes:
  compiler:
    taskfile: ../../tools/Compiler.yaml
    dir: ../../tools
    internal: true

tasks:
  build:
    deps:
      - compiler:setup
    cmds:
      - touch a
 
./lib/b/Taskfile.yaml
version: "3"

includes:
  compiler:
    taskfile: ../../tools/Compiler.yaml
    dir: ../../tools
    internal: true

tasks:
  build:
    deps:
      - compiler:setup
    cmds:
      - touch b

./lib/Taskfile.yaml     # <--- THIS FILE IS NEW HERE
version: "3"

includes:
  a:
    taskfile: a
    dir: ./a
  b:
    taskfile: b
    dir: ./b

tasks:
  build:
    deps: [a:build, b:build]

./Taskfile.yaml
version: "3"

includes:
  lib:
    taskfile: ./lib/
    dir: ./lib/

tasks:
  build:
    deps: [lib:build]

Running this setup looks like this:

$ ../.work/task build
task: [lib:b:compiler:setup] touch output
task: [lib:a:compiler:setup] touch output
task: [lib:b:build] touch b
task: [lib:a:build] touch a

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