Skip to content

Commit ecfc37b

Browse files
[CI] Add support for windows to dispatch_job.py
This patch adds in windows functionality to dispatch_job.py. Some minor refactoring was done around the start_build function so that the core functionality can be reused between Linux and Windows. Reviewers: cmtice, gburgessiv, lnihlen, dschuff, Keenuts Reviewed By: cmtice Pull Request: #540
1 parent 61310d3 commit ecfc37b

File tree

1 file changed

+53
-19
lines changed

1 file changed

+53
-19
lines changed

zorg/buildbot/builders/annotated/premerge/dispatch_job.py

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,82 @@
1717

1818
import kubernetes
1919

20-
PLATFORM_TO_NAMESPACE = {"Linux": "llvm-premerge-linux-buildbot"}
20+
PLATFORM_TO_NAMESPACE = {
21+
"Linux": "llvm-premerge-linux-buildbot",
22+
"Windows": "llvm-premerge-windows-buildbot",
23+
}
2124
LOG_SECONDS_TO_QUERY = 10
2225
SECONDS_QUERY_LOGS_EVERY = 5
2326

2427

25-
def start_build_linux(commit_sha: str, k8s_client) -> str:
26-
"""Spawns a pod to build/test LLVM at the specified SHA.
28+
def start_build(k8s_client, pod_name: str, namespace: str, commands: list[str]) -> None:
29+
"""Spawns a pod to run the specified commands.
2730
2831
Args:
29-
commit_sha: The commit SHA to build/run the tests at.
3032
k8s_client: The kubernetes client instance to use for spawning the pod.
31-
32-
Returns:
33-
A string containing the name of the pod.
33+
pod_name: The name of the pod to start.
34+
namespace: The namespace to launch the pod in.
35+
commands: The commands to run upon pod start.
3436
"""
35-
pod_name = f"build-{commit_sha}"
36-
commands = [
37-
"git clone --depth 100 https://github.com/llvm/llvm-project",
38-
"cd llvm-project",
39-
f"git checkout ${commit_sha}",
40-
"export CC=clang",
41-
"export CXX=clang++",
42-
'./.ci/monolithic-linux.sh "bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly" "check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly" "compiler-rt;libc;libcxx;libcxxabi;libunwind" "check-compiler-rt check-libc" "check-cxx check-cxxabi check-unwind" "OFF"'
43-
"echo BUILD FINISHED",
44-
]
4537
pod_definition = {
4638
"apiVersion": "v1",
4739
"kind": "Pod",
4840
"metadata": {
4941
"name": pod_name,
50-
"namespace": PLATFORM_TO_NAMESPACE["Linux"],
42+
"namespace": namespace,
5143
},
5244
"spec": {
5345
"containers": [
5446
{
5547
"name": "build",
5648
"image": "ghcr.io/llvm/ci-ubuntu-24.04",
57-
"command": ["/bin/bash", "-c", ";".join(commands)],
49+
"commands": commands,
5850
}
5951
],
6052
"restartPolicy": "Never",
6153
},
6254
}
6355
kubernetes.utils.create_from_dict(k8s_client, pod_definition)
56+
57+
58+
def start_build_linux(commit_sha: str, k8s_client) -> str:
59+
"""Starts a pod to build/test on Linux at the specified SHA."""
60+
pod_name = f"build-{commit_sha}"
61+
commands = [
62+
"git clone --depth 100 https://github.com/llvm/llvm-project",
63+
"cd llvm-project",
64+
f"git checkout ${commit_sha}",
65+
"export CC=clang",
66+
"export CXX=clang++",
67+
'./.ci/monolithic-linux.sh "bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly" "check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly" "compiler-rt;libc;libcxx;libcxxabi;libunwind" "check-compiler-rt check-libc" "check-cxx check-cxxabi check-unwind" "OFF"'
68+
"echo BUILD FINISHED",
69+
]
70+
start_build(
71+
k8s_client,
72+
pod_name,
73+
PLATFORM_TO_NAMESPACE["Linux"],
74+
["/bin/bash", "-c", ";".join(commands)],
75+
)
76+
return pod_name
77+
78+
79+
def start_build_windows(commit_sha: str, k8s_client):
80+
"""Starts a pod to build/test on Windows at the specified SHA."""
81+
pod_name = f"build-{commit_sha}"
82+
bash_commands = [
83+
"git clone --depth 100 https://github.com/llvm/llvm-project",
84+
"cd llvm-project",
85+
f"git checkout ${commit_sha}",
86+
'.ci/monolithic-windows.sh "clang;clang-tools-extra;libclc;lld;llvm;mlir;polly" "check-clang check-clang-cir check-clang-tools check-lld check-llvm check-mlir check-polly"',
87+
"echo BUILD FINISHED",
88+
]
89+
commands = [
90+
"call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64",
91+
"bash",
92+
"-c",
93+
";".join(bash_commands),
94+
]
95+
start_build(k8s_client, pod_name, PLATFORM_TO_NAMESPACE["Windows"], commands)
6496
return pod_name
6597

6698

@@ -150,6 +182,8 @@ def main(commit_sha: str, platform: str):
150182
k8s_client = kubernetes.client.ApiClient()
151183
if platform == "Linux":
152184
pod_name = start_build_linux(commit_sha, k8s_client)
185+
elif platform == "Windows":
186+
pod_name = start_build_windows(commit_sha, k8s_client)
153187
else:
154188
raise ValueError("Unrecognized platform.")
155189
namespace = PLATFORM_TO_NAMESPACE[platform]

0 commit comments

Comments
 (0)