Skip to content

Commit b5873c3

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. Pull Request: llvm#540
1 parent 82e0982 commit b5873c3

File tree

1 file changed

+48
-17
lines changed

1 file changed

+48
-17
lines changed

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

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,79 @@
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:
28+
def start_build(k8s_client, pod_name: str, namespace: str, commands: list[str]) -> None:
2629
"""Spawns a pod to build/test LLVM at the specified SHA.
2730
2831
Args:
2932
commit_sha: The commit SHA to build/run the tests at.
3033
k8s_client: The kubernetes client instance to use for spawning the pod.
31-
32-
Returns:
33-
A string containing the name of the pod.
34+
commands: The commands to run upon pod start.
3435
"""
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-
]
4536
pod_definition = {
4637
"apiVersion": "v1",
4738
"kind": "Pod",
4839
"metadata": {
4940
"name": pod_name,
50-
"namespace": PLATFORM_TO_NAMESPACE["Linux"],
41+
"namespace": namespace,
5142
},
5243
"spec": {
5344
"containers": [
5445
{
5546
"name": "build",
5647
"image": "ghcr.io/llvm/ci-ubuntu-24.04",
57-
"command": ["/bin/bash", "-c", ";".join(commands)],
48+
"commands": commands,
5849
}
5950
],
6051
"restartPolicy": "Never",
6152
},
6253
}
6354
kubernetes.utils.create_from_dict(k8s_client, pod_definition)
55+
56+
57+
def start_build_linux(commit_sha: str, k8s_client) -> str:
58+
pod_name = f"build-{commit_sha}"
59+
commands = [
60+
"git clone --depth 100 https://github.com/llvm/llvm-project",
61+
"cd llvm-project",
62+
f"git checkout ${commit_sha}",
63+
"export CC=clang",
64+
"export CXX=clang++",
65+
'./.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"'
66+
"echo BUILD FINISHED",
67+
]
68+
start_build(
69+
k8s_client,
70+
pod_name,
71+
PLATFORM_TO_NAMESPACE["Linux"],
72+
["/bin/bash", "-c", ";".join(commands)],
73+
)
74+
return pod_name
75+
76+
77+
def start_build_windows(commit_sha: str, k8s_client):
78+
pod_name = f"build-{commit_sha}"
79+
bash_commands = [
80+
"git clone --depth 100 https://github.com/llvm/llvm-project",
81+
"cd llvm-project",
82+
f"git checkout ${commit_sha}",
83+
'.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"',
84+
"echo BUILD FINISHED",
85+
]
86+
commands = [
87+
"call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64",
88+
"bash",
89+
"-c",
90+
";".join(bash_commands),
91+
]
92+
start_build(k8s_client, pod_name, PLATFORM_TO_NAMESPACE["Windows"], commands)
6493
return pod_name
6594

6695

@@ -150,6 +179,8 @@ def main(commit_sha: str, platform: str):
150179
k8s_client = kubernetes.client.ApiClient()
151180
if platform == "Linux":
152181
pod_name = start_build_linux(commit_sha, k8s_client)
182+
elif platform == "Windows":
183+
pod_name = start_build_windows(commit_sha, k8s_client)
153184
else:
154185
raise ValueError("Unrecognized platform.")
155186
namespace = PLATFORM_TO_NAMESPACE[platform]

0 commit comments

Comments
 (0)