1
0
mirror of https://github.com/go-task/task.git synced 2025-07-17 01:43:07 +02:00

feat: allow variable references in a matrix (#2069)

This commit is contained in:
Pete Davison
2025-02-23 18:13:56 +00:00
committed by GitHub
parent a31f2cf4a8
commit d6234af49a
5 changed files with 185 additions and 39 deletions

View File

@ -1,5 +1,10 @@
version: "3"
vars:
OS_VAR: ["windows", "linux", "darwin"]
ARCH_VAR: ["amd64", "arm64"]
NOT_A_LIST: "not a list"
tasks:
# Loop over a list of values
loop-explicit:
@ -15,6 +20,26 @@ tasks:
ARCH: ["amd64", "arm64"]
cmd: echo "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
loop-matrix-ref:
cmds:
- for:
matrix:
OS:
ref: .OS_VAR
ARCH:
ref: .ARCH_VAR
cmd: echo "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
loop-matrix-ref-error:
cmds:
- for:
matrix:
OS:
ref: .OS_VAR
ARCH:
ref: .NOT_A_LIST
cmd: echo "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
# Loop over the task's sources
loop-sources:
sources:

View File

@ -1,5 +1,10 @@
version: "3"
vars:
OS_VAR: ["windows", "linux", "darwin"]
ARCH_VAR: ["amd64", "arm64"]
NOT_A_LIST: "not a list"
tasks:
# Loop over a list of values
loop-explicit:
@ -19,6 +24,30 @@ tasks:
vars:
TEXT: "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
loop-matrix-ref:
deps:
- for:
matrix:
OS:
ref: .OS_VAR
ARCH:
ref: .ARCH_VAR
task: echo
vars:
TEXT: "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
loop-matrix-ref-error:
deps:
- for:
matrix:
OS:
ref: .OS_VAR
ARCH:
ref: .NOT_A_LIST
task: echo
vars:
TEXT: "{{.ITEM.OS}}/{{.ITEM.ARCH}}"
# Loop over the task's sources
loop-sources:
sources: