- 
                Notifications
    
You must be signed in to change notification settings  - Fork 119
 
[CI] Add support for windows to dispatch_job.py #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
12a2cd6
              07ccbcc
              246b649
              131366d
              f2984b4
              f4eb5b2
              9006477
              db15a3f
              81cedbb
              8bb2afd
              e6948e8
              a552b04
              2e00dcc
              ee8ff6c
              3767ce5
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -13,53 +13,83 @@ | |
| import dateutil | ||
| import datetime | ||
| import json | ||
| import os | ||
| 
     | 
||
| 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: | ||
| def start_build(k8s_client, pod_name: str, namespace: str, commands: list[str]) -> None: | ||
| """Spawns a pod to build/test LLVM at the specified SHA. | ||
| 
     | 
||
| Args: | ||
| commit_sha: The commit SHA to build/run the tests at. | ||
                
      
                  boomanaiden154 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| k8s_client: The kubernetes client instance to use for spawning the pod. | ||
| 
     | 
||
| Returns: | ||
| A string containing the name of the pod. | ||
| commands: The commands to run upon pod start. | ||
                
      
                  boomanaiden154 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| """ | ||
| 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: | ||
| pod_name = f"build-{commit_sha}" | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function comments? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
| pod_name = f"build-{commit_sha}" | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function comments? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 
     | 
||
| 
     | 
||
| 
          
            
          
           | 
    @@ -149,11 +179,14 @@ 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] | ||
| latest_time = datetime.datetime.min | ||
| v1_api = kubernetes.client.CoreV1Api() | ||
| print("@@@BUILD_STEP Build/Test@@@") | ||
| while True: | ||
| try: | ||
| pod_finished, latest_time = print_logs( | ||
| 
        
          
        
         | 
    @@ -173,7 +206,10 @@ def main(commit_sha: str, platform: str): | |
| 
     | 
||
| 
     | 
||
| if __name__ == "__main__": | ||
| if len(sys.argv) != 3: | ||
| logging.fatal("Expected usage is dispatch_job.py {commit SHA} {platform}") | ||
| if len(sys.argv) != 2: | ||
| logging.fatal("Expected usage is dispatch_job.py {platform}") | ||
| sys.exit(1) | ||
| if "BUILDBOT_REVISION" not in os.environ: | ||
| logging.fatal("Expected to have BUILDBOT_REVISION environment variable set.") | ||
| sys.exit(1) | ||
| main(sys.argv[1], sys.argv[2]) | ||
| main(sys.argv[1], os.environ["BUILDBOT_REVISION"]) | ||
Uh oh!
There was an error while loading. Please reload this page.