|
| 1 | +import cimodel.data.simple.util.branch_filters as branch_filters |
| 2 | +from cimodel.data.simple.util.docker_constants import ( |
| 3 | + DOCKER_IMAGE_NDK, DOCKER_REQUIREMENT_NDK |
| 4 | +) |
| 5 | + |
| 6 | + |
| 7 | +class AndroidJob: |
| 8 | + def __init__(self, |
| 9 | + variant, |
| 10 | + template_name, |
| 11 | + is_master_only=True): |
| 12 | + |
| 13 | + self.variant = variant |
| 14 | + self.template_name = template_name |
| 15 | + self.is_master_only = is_master_only |
| 16 | + |
| 17 | + def gen_tree(self): |
| 18 | + |
| 19 | + base_name_parts = [ |
| 20 | + "pytorch", |
| 21 | + "linux", |
| 22 | + "xenial", |
| 23 | + "py3", |
| 24 | + "clang5", |
| 25 | + "android", |
| 26 | + "ndk", |
| 27 | + "r19c", |
| 28 | + ] + self.variant + [ |
| 29 | + "build", |
| 30 | + ] |
| 31 | + |
| 32 | + full_job_name = "_".join(base_name_parts) |
| 33 | + build_env_name = "-".join(base_name_parts) |
| 34 | + |
| 35 | + props_dict = { |
| 36 | + "name": full_job_name, |
| 37 | + "build_environment": "\"{}\"".format(build_env_name), |
| 38 | + "docker_image": "\"{}\"".format(DOCKER_IMAGE_NDK), |
| 39 | + "requires": [DOCKER_REQUIREMENT_NDK] |
| 40 | + } |
| 41 | + |
| 42 | + if self.is_master_only: |
| 43 | + props_dict["filters"] = branch_filters.gen_filter_dict(branch_filters.NON_PR_BRANCH_LIST) |
| 44 | + |
| 45 | + return [{self.template_name: props_dict}] |
| 46 | + |
| 47 | + |
| 48 | +class AndroidGradleJob: |
| 49 | + def __init__(self, |
| 50 | + job_name, |
| 51 | + template_name, |
| 52 | + dependencies, |
| 53 | + is_master_only=True, |
| 54 | + is_pr_only=False, |
| 55 | + extra_props=tuple()): |
| 56 | + |
| 57 | + self.job_name = job_name |
| 58 | + self.template_name = template_name |
| 59 | + self.dependencies = dependencies |
| 60 | + self.is_master_only = is_master_only |
| 61 | + self.is_pr_only = is_pr_only |
| 62 | + self.extra_props = dict(extra_props) |
| 63 | + |
| 64 | + def gen_tree(self): |
| 65 | + |
| 66 | + props_dict = { |
| 67 | + "name": self.job_name, |
| 68 | + "requires": self.dependencies, |
| 69 | + } |
| 70 | + |
| 71 | + if self.is_master_only: |
| 72 | + props_dict["filters"] = branch_filters.gen_filter_dict(branch_filters.NON_PR_BRANCH_LIST) |
| 73 | + elif self.is_pr_only: |
| 74 | + props_dict["filters"] = branch_filters.gen_filter_dict(branch_filters.PR_BRANCH_LIST) |
| 75 | + if self.extra_props: |
| 76 | + props_dict.update(self.extra_props) |
| 77 | + |
| 78 | + return [{self.template_name: props_dict}] |
| 79 | + |
| 80 | + |
| 81 | +WORKFLOW_DATA = [ |
| 82 | + AndroidJob(["x86_32"], "pytorch_linux_build", is_master_only=False), |
| 83 | + AndroidJob(["x86_64"], "pytorch_linux_build"), |
| 84 | + AndroidJob(["arm", "v7a"], "pytorch_linux_build"), |
| 85 | + AndroidJob(["arm", "v8a"], "pytorch_linux_build"), |
| 86 | + AndroidGradleJob( |
| 87 | + "pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-build-x86_32", |
| 88 | + "pytorch_android_gradle_build-x86_32", |
| 89 | + ["pytorch_linux_xenial_py3_clang5_android_ndk_r19c_x86_32_build"], |
| 90 | + is_master_only=False, |
| 91 | + is_pr_only=True), |
| 92 | + AndroidGradleJob( |
| 93 | + "pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-build", |
| 94 | + "pytorch_android_gradle_build", |
| 95 | + ["pytorch_linux_xenial_py3_clang5_android_ndk_r19c_x86_32_build", |
| 96 | + "pytorch_linux_xenial_py3_clang5_android_ndk_r19c_x86_64_build", |
| 97 | + "pytorch_linux_xenial_py3_clang5_android_ndk_r19c_arm_v7a_build", |
| 98 | + "pytorch_linux_xenial_py3_clang5_android_ndk_r19c_arm_v8a_build"]), |
| 99 | +] |
| 100 | + |
| 101 | + |
| 102 | +def get_workflow_jobs(): |
| 103 | + return [item.gen_tree() for item in WORKFLOW_DATA] |
0 commit comments