Skip to content

Commit a3c894d

Browse files
committed
matrix attribute on command steps
1 parent 0f50173 commit a3c894d

File tree

3 files changed

+155
-0
lines changed

3 files changed

+155
-0
lines changed

schema.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@
406406
]
407407
}
408408
},
409+
"matrixElement": {
410+
"oneOf": [
411+
{"type": "string"},
412+
{"type": "integer"},
413+
{"type": "boolean"}
414+
]
415+
},
409416
"prompt": {
410417
"type": "string",
411418
"description": "The instructional message displayed in the dialog box when the unblock step is activated",
@@ -659,6 +666,98 @@
659666
"label": {
660667
"$ref": "#/definitions/commonOptions/label"
661668
},
669+
"matrix": {
670+
"oneOf": [
671+
{
672+
"type": "array",
673+
"description": "List of elements for simple single-dimension Build Matrix",
674+
"items": { "$ref": "#/definitions/commonOptions/matrixElement" },
675+
"examples": [
676+
["linux", "freebsd"]
677+
]
678+
},
679+
{
680+
"type": "object",
681+
"description": "Configuration for multi-dimension Build Matrix",
682+
"properties": {
683+
"setup": {
684+
"oneOf": [
685+
{
686+
"type": "array",
687+
"description": "List of elements for single-dimension Build Matrix",
688+
"items": { "$ref": "#/definitions/commonOptions/matrixElement" },
689+
"examples": [
690+
["linux", "freebsd"]
691+
]
692+
},
693+
{
694+
"type": "object",
695+
"description": "Mapping of Build Matrix dimension names to their lists of elements",
696+
"propertyNames": {
697+
"type": "string",
698+
"description": "Build Matrix dimension name",
699+
"pattern": "^[a-zA-Z0-9_]+$"
700+
},
701+
"additionalProperties": {
702+
"type": "array",
703+
"description": "List of elements for this Build Matrix dimension",
704+
"items": { "$ref": "#/definitions/commonOptions/matrixElement" }
705+
},
706+
"examples": [
707+
{
708+
"os": ["linux", "freebsd"],
709+
"arch": ["arm64", "riscv"]
710+
}
711+
]
712+
}
713+
]
714+
},
715+
"adjustments": {
716+
"type": "array",
717+
"description": "List of Build Matrix adjustments",
718+
"items": {
719+
"type": "object",
720+
"description": "An adjustment to a Build Matrix",
721+
"properties": {
722+
"with": {
723+
"oneOf": [
724+
{
725+
"type": "array",
726+
"description": "List of existing or new elements for single-dimension Build Matrix",
727+
"items": { "$ref": "#/definitions/commonOptions/matrixElement" }
728+
},
729+
{
730+
"type": "object",
731+
"description": "Specification of a new or existing Build Matrix combination",
732+
"propertyNames": {
733+
"type": "string",
734+
"description": "Build Matrix dimension name"
735+
},
736+
"additionalProperties": {
737+
"type": "string",
738+
"description": "Build Matrix dimension element"
739+
},
740+
"examples": [
741+
{ "os": "linux", "arch": "arm64" }
742+
]
743+
}
744+
]
745+
},
746+
"skip": {
747+
"$ref": "#/definitions/commonOptions/skip"
748+
},
749+
"soft_fail": {
750+
"$ref": "#/definitions/commonOptions/softFail"
751+
}
752+
},
753+
"required": ["with"]
754+
}
755+
}
756+
},
757+
"required": ["setup"]
758+
}
759+
]
760+
},
662761
"name": {
663762
"$ref": "#/definitions/commonOptions/label"
664763
},

test/schema.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ describe('schema.json', function() {
4646
it('should validate notify', function() {
4747
validate('notify.yml')
4848
})
49+
it('should validate matrix', function() {
50+
validate('matrix.yml')
51+
})
4952
})

test/valid-pipelines/matrix.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
steps:
2+
- command: "echo {{matrix}}"
3+
label: "{{matrix}}"
4+
matrix:
5+
- one
6+
- two
7+
8+
- command: "echo {{matrix}}"
9+
label: "{{matrix}}"
10+
matrix:
11+
setup:
12+
- one
13+
- two
14+
adjustments:
15+
- with: ["three"]
16+
skip: true
17+
18+
- command: "echo {{matrix.color}} {{matrix.shape}}"
19+
label: "{{matrix.color}} {{matrix.shape}}"
20+
matrix:
21+
setup:
22+
color:
23+
- green
24+
- blue
25+
shape:
26+
- triangle
27+
- hexagon
28+
adjustments:
29+
- with: {color: blue, shape: triangle}
30+
skip: true
31+
- with: {color: green, shape: triangle}
32+
skip: "look, hexagons are just better"
33+
- with: {color: purple, shape: octagon}
34+
35+
36+
- group: matrices
37+
steps:
38+
- command: "echo {{matrix}}"
39+
label: "{{matrix}}"
40+
matrix:
41+
- one
42+
- two
43+
44+
- command: "echo {{matrix.color}} {{matrix.shape}}"
45+
label: "{{matrix.color}} {{matrix.shape}}"
46+
matrix:
47+
setup:
48+
color:
49+
- green
50+
- blue
51+
shape:
52+
- triangle
53+
- hexagon

0 commit comments

Comments
 (0)