Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 53 additions & 19 deletions zorg/buildbot/builders/annotated/premerge/dispatch_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,82 @@

import kubernetes

PLATFORM_TO_NAMESPACE = {"Linux": "llvm-premerge-linux-buildbot"}
PLATFORM_TO_NAMESPACE = {
"Linux": "llvm-premerge-linux-buildbot",
"Windows": "llvm-premerge-windows-buildbot",
}
LOG_SECONDS_TO_QUERY = 10
SECONDS_QUERY_LOGS_EVERY = 5


def start_build_linux(commit_sha: str, k8s_client) -> str:
"""Spawns a pod to build/test LLVM at the specified SHA.
def start_build(k8s_client, pod_name: str, namespace: str, commands: list[str]) -> None:
"""Spawns a pod to run the specified commands.

Args:
commit_sha: The commit SHA to build/run the tests at.
k8s_client: The kubernetes client instance to use for spawning the pod.

Returns:
A string containing the name of the pod.
pod_name: The name of the pod to start.
namespace: The namespace to launch the pod in.
commands: The commands to run upon pod start.
"""
pod_name = f"build-{commit_sha}"
commands = [
"git clone --depth 100 https://github.com/llvm/llvm-project",
"cd llvm-project",
f"git checkout ${commit_sha}",
"export CC=clang",
"export CXX=clang++",
'./.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"'
"echo BUILD FINISHED",
]
pod_definition = {
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": pod_name,
"namespace": PLATFORM_TO_NAMESPACE["Linux"],
"namespace": namespace,
},
"spec": {
"containers": [
{
"name": "build",
"image": "ghcr.io/llvm/ci-ubuntu-24.04",
"command": ["/bin/bash", "-c", ";".join(commands)],
"commands": commands,
}
],
"restartPolicy": "Never",
},
}
kubernetes.utils.create_from_dict(k8s_client, pod_definition)


def start_build_linux(commit_sha: str, k8s_client) -> str:
"""Starts a pod to build/test on Linux at the specified SHA."""
pod_name = f"build-{commit_sha}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. I kept them as one liners as these functions should be reasonably self documenting.

commands = [
"git clone --depth 100 https://github.com/llvm/llvm-project",
"cd llvm-project",
f"git checkout ${commit_sha}",
"export CC=clang",
"export CXX=clang++",
'./.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"'
"echo BUILD FINISHED",
]
start_build(
k8s_client,
pod_name,
PLATFORM_TO_NAMESPACE["Linux"],
["/bin/bash", "-c", ";".join(commands)],
)
return pod_name


def start_build_windows(commit_sha: str, k8s_client):
"""Starts a pod to build/test on Windows at the specified SHA."""
pod_name = f"build-{commit_sha}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

bash_commands = [
"git clone --depth 100 https://github.com/llvm/llvm-project",
"cd llvm-project",
f"git checkout ${commit_sha}",
'.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"',
"echo BUILD FINISHED",
]
commands = [
"call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64",
"bash",
"-c",
";".join(bash_commands),
]
start_build(k8s_client, pod_name, PLATFORM_TO_NAMESPACE["Windows"], commands)
return pod_name


Expand Down Expand Up @@ -150,6 +182,8 @@ def main(commit_sha: str, platform: str):
k8s_client = kubernetes.client.ApiClient()
if platform == "Linux":
pod_name = start_build_linux(commit_sha, k8s_client)
elif platform == "Windows":
pod_name = start_build_windows(commit_sha, k8s_client)
else:
raise ValueError("Unrecognized platform.")
namespace = PLATFORM_TO_NAMESPACE[platform]
Expand Down