|
17 | 17 |
|
18 | 18 | import kubernetes
|
19 | 19 |
|
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 | +} |
21 | 24 | LOG_SECONDS_TO_QUERY = 10
|
22 | 25 | SECONDS_QUERY_LOGS_EVERY = 5
|
23 | 26 |
|
24 | 27 |
|
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. |
27 | 30 |
|
28 | 31 | Args:
|
29 |
| - commit_sha: The commit SHA to build/run the tests at. |
30 | 32 | 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. |
34 | 36 | """
|
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 |
| - ] |
45 | 37 | pod_definition = {
|
46 | 38 | "apiVersion": "v1",
|
47 | 39 | "kind": "Pod",
|
48 | 40 | "metadata": {
|
49 | 41 | "name": pod_name,
|
50 |
| - "namespace": PLATFORM_TO_NAMESPACE["Linux"], |
| 42 | + "namespace": namespace, |
51 | 43 | },
|
52 | 44 | "spec": {
|
53 | 45 | "containers": [
|
54 | 46 | {
|
55 | 47 | "name": "build",
|
56 | 48 | "image": "ghcr.io/llvm/ci-ubuntu-24.04",
|
57 |
| - "command": ["/bin/bash", "-c", ";".join(commands)], |
| 49 | + "commands": commands, |
58 | 50 | }
|
59 | 51 | ],
|
60 | 52 | "restartPolicy": "Never",
|
61 | 53 | },
|
62 | 54 | }
|
63 | 55 | 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) |
64 | 96 | return pod_name
|
65 | 97 |
|
66 | 98 |
|
@@ -150,6 +182,8 @@ def main(commit_sha: str, platform: str):
|
150 | 182 | k8s_client = kubernetes.client.ApiClient()
|
151 | 183 | if platform == "Linux":
|
152 | 184 | pod_name = start_build_linux(commit_sha, k8s_client)
|
| 185 | + elif platform == "Windows": |
| 186 | + pod_name = start_build_windows(commit_sha, k8s_client) |
153 | 187 | else:
|
154 | 188 | raise ValueError("Unrecognized platform.")
|
155 | 189 | namespace = PLATFORM_TO_NAMESPACE[platform]
|
|
0 commit comments