Skip to content

Variable with list of namespace names for included files #1862

@postlund

Description

@postlund

I quite often end up in this situation when building monorepos using task:

version: "3"

includes:
  app1: ./app1
  app2: ./app2
  app3: ./app3
  app4: ./app4

vars:
  APPS:
    - app1
    - app2
    - app3
    - app4

tasks:
  build:
    deps:
      - for: { var:  APPS }
        task: "{{ .ITEM }}:build"

  clean:
    deps:
      - for: { var:  APPS }
        task: "{{ .ITEM }}:clean"

  test:
    deps:
      - for: { var:  APPS }
        task: "{{ .ITEM }}:test"

The same kind of pattern might exist in multiple places within a repository (e.g. for applications, libraries, test tools, etc.). It's OK syntax as it's quite easy to add new entries by just updating (in this case) APPS. But it would be very convenient with a variable containing the namespace name of all includes in the current file. So I basically could write something like this:

version: "3"

includes:
  app1: ./app1
  app2: ./app2
  app3: ./app3
  app4: ./app4

tasks:
  build:
    deps:
      - for: { var:  INCLUDE_NAMESPACES }
        task: "{{ .ITEM }}:build"

  clean:
    deps:
      - for: { var:  INCLUDE_NAMESPACES }
        task: "{{ .ITEM }}:clean"

  test:
    deps:
      - for: { var:  INCLUDE_NAMESPACES }
        task: "{{ .ITEM }}:test"

In the long run, it would also be convenient to have some kind of wildcard support for includes as well (to make this situation even more automagic). But that's out of scope for this request.

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