|  | 
| 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: | 
|  | 28 | +def start_build(k8s_client, pod_name: str, namespace: str, commands: list[str]) -> None: | 
| 26 | 29 |     """Spawns a pod to build/test LLVM at the specified SHA. | 
| 27 | 30 | 
 | 
| 28 | 31 |     Args: | 
| 29 | 32 |       commit_sha: The commit SHA to build/run the tests at. | 
| 30 | 33 |       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. | 
| 34 | 35 |     """ | 
| 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 | 36 |     pod_definition = { | 
| 46 | 37 |         "apiVersion": "v1", | 
| 47 | 38 |         "kind": "Pod", | 
| 48 | 39 |         "metadata": { | 
| 49 | 40 |             "name": pod_name, | 
| 50 |  | -            "namespace": PLATFORM_TO_NAMESPACE["Linux"], | 
|  | 41 | +            "namespace": namespace, | 
| 51 | 42 |         }, | 
| 52 | 43 |         "spec": { | 
| 53 | 44 |             "containers": [ | 
| 54 | 45 |                 { | 
| 55 | 46 |                     "name": "build", | 
| 56 | 47 |                     "image": "ghcr.io/llvm/ci-ubuntu-24.04", | 
| 57 |  | -                    "command": ["/bin/bash", "-c", ";".join(commands)], | 
|  | 48 | +                    "commands": commands, | 
| 58 | 49 |                 } | 
| 59 | 50 |             ], | 
| 60 | 51 |             "restartPolicy": "Never", | 
| 61 | 52 |         }, | 
| 62 | 53 |     } | 
| 63 | 54 |     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) | 
| 64 | 93 |     return pod_name | 
| 65 | 94 | 
 | 
| 66 | 95 | 
 | 
| @@ -150,6 +179,8 @@ def main(commit_sha: str, platform: str): | 
| 150 | 179 |     k8s_client = kubernetes.client.ApiClient() | 
| 151 | 180 |     if platform == "Linux": | 
| 152 | 181 |         pod_name = start_build_linux(commit_sha, k8s_client) | 
|  | 182 | +    elif platform == "Windows": | 
|  | 183 | +        pod_name = start_build_windows(commit_sha, k8s_client) | 
| 153 | 184 |     else: | 
| 154 | 185 |         raise ValueError("Unrecognized platform.") | 
| 155 | 186 |     namespace = PLATFORM_TO_NAMESPACE[platform] | 
|  | 
0 commit comments