2 # Copyright 2016 gRPC authors.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 """Definition of targets to build distribution packages."""
20 sys.path.insert(0, os.path.abspath('..'))
21 import python_utils.jobset as jobset
24 def create_docker_jobspec(name,
30 """Creates jobspec for a task running under docker."""
31 environ = environ.copy()
32 environ['RUN_COMMAND'] = shell_command
35 for k, v in environ.items():
36 docker_args += ['-e', '%s=%s' % (k, v)]
38 'DOCKERFILE_DIR': dockerfile_dir,
39 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh',
40 'OUTPUT_DIR': 'artifacts'
42 jobspec = jobset.JobSpec(
43 cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] +
46 shortname='build_package.%s' % (name),
47 timeout_seconds=30 * 60,
48 flake_retries=flake_retries,
49 timeout_retries=timeout_retries)
53 def create_jobspec(name,
61 """Creates jobspec."""
62 jobspec = jobset.JobSpec(cmdline=cmdline,
65 shortname='build_package.%s' % (name),
66 timeout_seconds=10 * 60,
67 flake_retries=flake_retries,
68 timeout_retries=timeout_retries,
75 """Builds C# packages."""
77 def __init__(self, unity=False):
79 self.labels = ['package', 'csharp', 'windows']
81 self.name = 'csharp_package_unity_windows'
82 self.labels += ['unity']
84 self.name = 'csharp_package_nuget_windows'
85 self.labels += ['nuget']
87 def pre_build_jobspecs(self):
90 def build_jobspec(self):
92 # use very high CPU cost to avoid running nuget package build
93 # and unity build concurrently
94 return create_jobspec(self.name, ['build_unitypackage.bat'],
99 return create_jobspec(self.name, ['build_packages_dotnetcli.bat'],
108 """Collects ruby gems created in the artifact phase"""
111 self.name = 'ruby_package'
112 self.labels = ['package', 'ruby', 'linux']
114 def pre_build_jobspecs(self):
117 def build_jobspec(self):
118 return create_docker_jobspec(
119 self.name, 'tools/dockerfile/grpc_artifact_linux_x64',
120 'tools/run_tests/artifacts/build_package_ruby.sh')
124 """Collects python eggs and wheels created in the artifact phase"""
127 self.name = 'python_package'
128 self.labels = ['package', 'python', 'linux']
130 def pre_build_jobspecs(self):
133 def build_jobspec(self):
134 return create_docker_jobspec(
135 self.name, 'tools/dockerfile/grpc_artifact_linux_x64',
136 'tools/run_tests/artifacts/build_package_python.sh')
140 """Copy PHP PECL package artifact"""
143 self.name = 'php_package'
144 self.labels = ['package', 'php', 'linux']
146 def pre_build_jobspecs(self):
149 def build_jobspec(self):
150 return create_docker_jobspec(
151 self.name, 'tools/dockerfile/grpc_artifact_linux_x64',
152 'tools/run_tests/artifacts/build_package_php.sh')
156 """Gets list of supported targets"""
159 CSharpPackage(unity=True),