Skip to content

Commit 1d70063

Browse files
pb8obchalios
authored andcommitted
Add a script to generate the Buildkite pipeline
Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent ef5bc9e commit 1d70063

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.buildkite/pipeline_pr.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""Generate Buildkite pipelines dynamically"""
6+
7+
import json
8+
9+
INSTANCES = [
10+
"m5d.metal",
11+
"m6i.metal",
12+
"m6a.metal",
13+
"m6gd.metal",
14+
]
15+
16+
KERNELS = ["4.14", "5.10"]
17+
18+
19+
def group(group_name, command, agent_tags=None, priority=0, timeout=30):
20+
"""
21+
Generate a group step with specified parameters, for each instance+kernel
22+
combination
23+
24+
https://buildkite.com/docs/pipelines/group-step
25+
"""
26+
if agent_tags is None:
27+
agent_tags = []
28+
# Use the 1st character of the group name (should be an emoji)
29+
label1 = group_name[0]
30+
steps = []
31+
for instance in INSTANCES:
32+
for kv in KERNELS:
33+
agents = [
34+
f"type={instance}",
35+
f"kv={kv}",
36+
]
37+
agents.extend(agent_tags)
38+
step = {
39+
"command": command,
40+
"label": f"{label1} {instance} kv={kv}",
41+
"priority": priority,
42+
"timeout": timeout,
43+
"agents": agents,
44+
}
45+
steps.append(step)
46+
47+
return {"group": group_name, "steps": steps}
48+
49+
50+
step_block_unless_maintainer = {
51+
"block": "Waiting for approval to run",
52+
"if": '(build.creator.teams includes "prod-compute-capsule") == false',
53+
}
54+
55+
step_style = {
56+
"command": "./tools/devtool -y test -- ../tests/integration_tests/style/",
57+
"label": "🪶 Style",
58+
# no agent tags, it doesn't matter where this runs
59+
}
60+
61+
build_grp = group(
62+
"📦 Build",
63+
"./tools/devtool -y test -- ../tests/integration_tests/build/",
64+
priority=1,
65+
)
66+
67+
functional_1_grp = group(
68+
"⚙ Functional [a-n]",
69+
"./tools/devtool -y test -- `cd tests; ls integration_tests/functional/test_[a-n]*.py`",
70+
priority=1,
71+
)
72+
73+
functional_2_grp = group(
74+
"⚙ Functional [o-z]",
75+
"./tools/devtool -y test -- `cd tests; ls integration_tests/functional/test_[o-z]*.py`",
76+
priority=1,
77+
)
78+
79+
security_grp = group(
80+
"🔒 Security",
81+
"./tools/devtool -y test -- ../tests/integration_tests/security/",
82+
priority=1,
83+
)
84+
85+
performance_grp = group(
86+
"⏱ Performance",
87+
"./tools/devtool -y test -- ../tests/integration_tests/performance/",
88+
priority=1,
89+
agent_tags=["ag=1"],
90+
)
91+
92+
pipeline = {
93+
"agents": {"queue": "default"},
94+
"steps": [
95+
step_block_unless_maintainer,
96+
step_style,
97+
build_grp,
98+
functional_1_grp,
99+
functional_2_grp,
100+
security_grp,
101+
performance_grp,
102+
],
103+
}
104+
105+
print(json.dumps(pipeline, indent=4, sort_keys=True, ensure_ascii=False))

0 commit comments

Comments
 (0)