Nathaniel Manista | cbf21da | 2016-02-02 22:17:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python2.7 |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 2 | # Copyright 2016, Google Inc. |
| 3 | # All rights reserved. |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are |
| 7 | # met: |
| 8 | # |
| 9 | # * Redistributions of source code must retain the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer. |
| 11 | # * Redistributions in binary form must reproduce the above |
| 12 | # copyright notice, this list of conditions and the following disclaimer |
| 13 | # in the documentation and/or other materials provided with the |
| 14 | # distribution. |
| 15 | # * Neither the name of Google Inc. nor the names of its |
| 16 | # contributors may be used to endorse or promote products derived from |
| 17 | # this software without specific prior written permission. |
| 18 | # |
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | """Definition of targets to build distribution packages.""" |
| 32 | |
| 33 | import jobset |
| 34 | |
murgatroid99 | dc3b4a4 | 2016-02-03 12:57:49 -0800 | [diff] [blame] | 35 | def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={}, |
| 36 | flake_retries=0, timeout_retries=0): |
| 37 | """Creates jobspec for a task running under docker.""" |
| 38 | environ = environ.copy() |
| 39 | environ['RUN_COMMAND'] = shell_command |
| 40 | |
| 41 | docker_args=[] |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 42 | for k,v in environ.items(): |
murgatroid99 | dc3b4a4 | 2016-02-03 12:57:49 -0800 | [diff] [blame] | 43 | docker_args += ['-e', '%s=%s' % (k, v)] |
| 44 | docker_env = {'DOCKERFILE_DIR': dockerfile_dir, |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 45 | 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh', |
murgatroid99 | dc3b4a4 | 2016-02-03 12:57:49 -0800 | [diff] [blame] | 46 | 'OUTPUT_DIR': 'artifacts'} |
| 47 | jobspec = jobset.JobSpec( |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 48 | cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args, |
murgatroid99 | dc3b4a4 | 2016-02-03 12:57:49 -0800 | [diff] [blame] | 49 | environ=docker_env, |
murgatroid99 | 3c3e58e | 2016-02-03 13:43:29 -0800 | [diff] [blame] | 50 | shortname='build_package.%s' % (name), |
murgatroid99 | dc3b4a4 | 2016-02-03 12:57:49 -0800 | [diff] [blame] | 51 | timeout_seconds=30*60, |
| 52 | flake_retries=flake_retries, |
| 53 | timeout_retries=timeout_retries) |
| 54 | return jobspec |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 55 | |
| 56 | def create_jobspec(name, cmdline, environ=None, cwd=None, shell=False, |
| 57 | flake_retries=0, timeout_retries=0): |
| 58 | """Creates jobspec.""" |
| 59 | jobspec = jobset.JobSpec( |
| 60 | cmdline=cmdline, |
| 61 | environ=environ, |
| 62 | cwd=cwd, |
| 63 | shortname='build_package.%s' % (name), |
| 64 | timeout_seconds=10*60, |
| 65 | flake_retries=flake_retries, |
| 66 | timeout_retries=timeout_retries, |
| 67 | shell=shell) |
| 68 | return jobspec |
| 69 | |
| 70 | |
Jan Tattermusch | 3c60392 | 2016-02-05 18:17:55 -0800 | [diff] [blame] | 71 | class CSharpPackage: |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 72 | """Builds C# nuget packages.""" |
| 73 | |
Jan Tattermusch | 2c084ee | 2016-06-28 16:54:17 -0700 | [diff] [blame] | 74 | def __init__(self, use_coreclr=False): |
| 75 | self.use_coreclr = use_coreclr |
| 76 | self.name = 'csharp_package_coreclr' if use_coreclr else 'csharp_package' |
| 77 | self.labels = ['package', 'csharp'] |
| 78 | if use_coreclr: |
| 79 | self.labels += ['linux'] |
| 80 | else: |
| 81 | self.labels += ['windows'] |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 82 | |
| 83 | def pre_build_jobspecs(self): |
| 84 | return [] |
| 85 | |
| 86 | def build_jobspec(self): |
Jan Tattermusch | 2c084ee | 2016-06-28 16:54:17 -0700 | [diff] [blame] | 87 | if self.use_coreclr: |
| 88 | return create_docker_jobspec( |
| 89 | self.name, |
| 90 | 'tools/dockerfile/test/csharp_coreclr_x64', |
| 91 | 'tools/run_tests/build_package_csharp_coreclr.sh') |
| 92 | else: |
| 93 | return create_jobspec(self.name, |
| 94 | ['build_packages.bat'], |
| 95 | cwd='src\\csharp', |
| 96 | shell=True) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 97 | |
| 98 | def __str__(self): |
| 99 | return self.name |
| 100 | |
Jan Tattermusch | 3c60392 | 2016-02-05 18:17:55 -0800 | [diff] [blame] | 101 | |
| 102 | class NodePackage: |
| 103 | """Builds Node NPM package and collects precompiled binaries""" |
murgatroid99 | dc3b4a4 | 2016-02-03 12:57:49 -0800 | [diff] [blame] | 104 | |
| 105 | def __init__(self): |
Jan Tattermusch | 3c60392 | 2016-02-05 18:17:55 -0800 | [diff] [blame] | 106 | self.name = 'node_package' |
murgatroid99 | 3c3e58e | 2016-02-03 13:43:29 -0800 | [diff] [blame] | 107 | self.labels = ['package', 'node', 'linux'] |
murgatroid99 | dc3b4a4 | 2016-02-03 12:57:49 -0800 | [diff] [blame] | 108 | |
| 109 | def pre_build_jobspecs(self): |
| 110 | return [] |
| 111 | |
| 112 | def build_jobspec(self): |
| 113 | return create_docker_jobspec( |
| 114 | self.name, |
| 115 | 'tools/dockerfile/grpc_artifact_linux_x64', |
| 116 | 'tools/run_tests/build_package_node.sh') |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 117 | |
Jan Tattermusch | 3c60392 | 2016-02-05 18:17:55 -0800 | [diff] [blame] | 118 | |
| 119 | class RubyPackage: |
| 120 | """Collects ruby gems created in the artifact phase""" |
| 121 | |
| 122 | def __init__(self): |
| 123 | self.name = 'ruby_package' |
| 124 | self.labels = ['package', 'ruby', 'linux'] |
| 125 | |
| 126 | def pre_build_jobspecs(self): |
| 127 | return [] |
| 128 | |
| 129 | def build_jobspec(self): |
| 130 | return create_docker_jobspec( |
| 131 | self.name, |
| 132 | 'tools/dockerfile/grpc_artifact_linux_x64', |
| 133 | 'tools/run_tests/build_package_ruby.sh') |
| 134 | |
| 135 | |
| 136 | class PythonPackage: |
| 137 | """Collects python eggs and wheels created in the artifact phase""" |
| 138 | |
| 139 | def __init__(self): |
| 140 | self.name = 'python_package' |
| 141 | self.labels = ['package', 'python', 'linux'] |
| 142 | |
| 143 | def pre_build_jobspecs(self): |
| 144 | return [] |
| 145 | |
| 146 | def build_jobspec(self): |
| 147 | return create_docker_jobspec( |
| 148 | self.name, |
| 149 | 'tools/dockerfile/grpc_artifact_linux_x64', |
| 150 | 'tools/run_tests/build_package_python.sh') |
| 151 | |
| 152 | |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 153 | class PHPPackage: |
Stanley Cheung | bf74d69 | 2016-02-23 22:39:25 -0800 | [diff] [blame] | 154 | """Copy PHP PECL package artifact""" |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 155 | |
| 156 | def __init__(self): |
| 157 | self.name = 'php_package' |
| 158 | self.labels = ['package', 'php', 'linux'] |
| 159 | |
| 160 | def pre_build_jobspecs(self): |
| 161 | return [] |
| 162 | |
| 163 | def build_jobspec(self): |
| 164 | return create_docker_jobspec( |
| 165 | self.name, |
| 166 | 'tools/dockerfile/grpc_artifact_linux_x64', |
| 167 | 'tools/run_tests/build_package_php.sh') |
| 168 | |
| 169 | |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 170 | def targets(): |
| 171 | """Gets list of supported targets""" |
Jan Tattermusch | 3c60392 | 2016-02-05 18:17:55 -0800 | [diff] [blame] | 172 | return [CSharpPackage(), |
Jan Tattermusch | 2c084ee | 2016-06-28 16:54:17 -0700 | [diff] [blame] | 173 | CSharpPackage(use_coreclr=True), |
Jan Tattermusch | 3c60392 | 2016-02-05 18:17:55 -0800 | [diff] [blame] | 174 | NodePackage(), |
| 175 | RubyPackage(), |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 176 | PythonPackage(), |
| 177 | PHPPackage()] |