Skip to content

Commit 9d1f70f

Browse files
authored
Merge pull request #33 from buildkite/matrix
Build Matrix support
2 parents eabd8d8 + a3c894d commit 9d1f70f

File tree

3 files changed

+188
-30
lines changed

3 files changed

+188
-30
lines changed

schema.json

Lines changed: 132 additions & 30 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",
@@ -424,6 +431,38 @@
424431
false,
425432
"My reason"
426433
]
434+
},
435+
"softFail": {
436+
"description": "The conditions for marking the step as a soft-fail.",
437+
"anyOf": [
438+
{
439+
"type": "boolean"
440+
},
441+
{
442+
"type": "array",
443+
"items": {
444+
"anyOf": [
445+
{
446+
"type": "object",
447+
"properties": {
448+
"exit_status": {
449+
"description": "The exit status number that will cause this job to soft-fail",
450+
"anyOf": [
451+
{
452+
"type": "string",
453+
"enum": [ "*" ]
454+
},
455+
{
456+
"type": "number"
457+
}
458+
]
459+
}
460+
}
461+
}
462+
]
463+
}
464+
}
465+
]
427466
}
428467
},
429468
"blockStep": {
@@ -627,6 +666,98 @@
627666
"label": {
628667
"$ref": "#/definitions/commonOptions/label"
629668
},
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+
},
630761
"name": {
631762
"$ref": "#/definitions/commonOptions/label"
632763
},
@@ -754,36 +885,7 @@
754885
]
755886
},
756887
"soft_fail": {
757-
"description": "The conditions for marking the step as a soft-fail.",
758-
"anyOf": [
759-
{
760-
"type": "boolean"
761-
},
762-
{
763-
"type": "array",
764-
"items": {
765-
"anyOf": [
766-
{
767-
"type": "object",
768-
"properties": {
769-
"exit_status": {
770-
"description": "The exit status number that will cause this job to soft-fail",
771-
"anyOf": [
772-
{
773-
"type": "string",
774-
"enum": [ "*" ]
775-
},
776-
{
777-
"type": "number"
778-
}
779-
]
780-
}
781-
}
782-
}
783-
]
784-
}
785-
}
786-
]
888+
"$ref": "#/definitions/commonOptions/softFail"
787889
},
788890
"retry": {
789891
"type": "object",

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)