Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1 """
borlanic 0:380207fcb5c1 2 mbed SDK
borlanic 0:380207fcb5c1 3 Copyright (c) 2011-2013 ARM Limited
borlanic 0:380207fcb5c1 4
borlanic 0:380207fcb5c1 5 Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:380207fcb5c1 6 you may not use this file except in compliance with the License.
borlanic 0:380207fcb5c1 7 You may obtain a copy of the License at
borlanic 0:380207fcb5c1 8
borlanic 0:380207fcb5c1 9 http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:380207fcb5c1 10
borlanic 0:380207fcb5c1 11 Unless required by applicable law or agreed to in writing, software
borlanic 0:380207fcb5c1 12 distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:380207fcb5c1 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:380207fcb5c1 14 See the License for the specific language governing permissions and
borlanic 0:380207fcb5c1 15 limitations under the License.
borlanic 0:380207fcb5c1 16 """
borlanic 0:380207fcb5c1 17 import sys
borlanic 0:380207fcb5c1 18 import argparse
borlanic 0:380207fcb5c1 19 import xml.etree.ElementTree as ET
borlanic 0:380207fcb5c1 20 import requests
borlanic 0:380207fcb5c1 21 import urlparse
borlanic 0:380207fcb5c1 22
borlanic 0:380207fcb5c1 23 def create_headers(args):
borlanic 0:380207fcb5c1 24 return { 'X-Api-Key': args.api_key }
borlanic 0:380207fcb5c1 25
borlanic 0:380207fcb5c1 26 def finish_command(command, response):
borlanic 0:380207fcb5c1 27 print(command, response.status_code, response.reason)
borlanic 0:380207fcb5c1 28 print(response.text)
borlanic 0:380207fcb5c1 29
borlanic 0:380207fcb5c1 30 if response.status_code < 400:
borlanic 0:380207fcb5c1 31 sys.exit(0)
borlanic 0:380207fcb5c1 32 else:
borlanic 0:380207fcb5c1 33 sys.exit(2)
borlanic 0:380207fcb5c1 34
borlanic 0:380207fcb5c1 35 def create_build(args):
borlanic 0:380207fcb5c1 36 build = {}
borlanic 0:380207fcb5c1 37 build['buildType'] = args.build_type
borlanic 0:380207fcb5c1 38 build['number'] = args.build_number
borlanic 0:380207fcb5c1 39 build['source'] = args.build_source
borlanic 0:380207fcb5c1 40 build['status'] = 'running'
borlanic 0:380207fcb5c1 41
borlanic 0:380207fcb5c1 42 r = requests.post(urlparse.urljoin(args.url, "api/builds"), headers=create_headers(args), json=build)
borlanic 0:380207fcb5c1 43
borlanic 0:380207fcb5c1 44 if r.status_code < 400:
borlanic 0:380207fcb5c1 45 if args.property_file_format:
borlanic 0:380207fcb5c1 46 print("MBED_BUILD_ID=" + r.text)
borlanic 0:380207fcb5c1 47 else:
borlanic 0:380207fcb5c1 48 print(r.text)
borlanic 0:380207fcb5c1 49
borlanic 0:380207fcb5c1 50 sys.exit(0)
borlanic 0:380207fcb5c1 51 else:
borlanic 0:380207fcb5c1 52 sys.exit(2)
borlanic 0:380207fcb5c1 53
borlanic 0:380207fcb5c1 54 def finish_build(args):
borlanic 0:380207fcb5c1 55 data = {}
borlanic 0:380207fcb5c1 56 data['status'] = 'completed'
borlanic 0:380207fcb5c1 57
borlanic 0:380207fcb5c1 58 r = requests.put(urlparse.urljoin(args.url, "api/builds/" + args.build_id), headers=create_headers(args), json=data)
borlanic 0:380207fcb5c1 59 finish_command('finish-build', r)
borlanic 0:380207fcb5c1 60
borlanic 0:380207fcb5c1 61 def promote_build(args):
borlanic 0:380207fcb5c1 62 data = {}
borlanic 0:380207fcb5c1 63 data['buildType'] = 'Release'
borlanic 0:380207fcb5c1 64
borlanic 0:380207fcb5c1 65 r = requests.put(urlparse.urljoin(args.url, "api/builds/" + args.build_id), headers=create_headers(args), json=data)
borlanic 0:380207fcb5c1 66 finish_command('promote-build', r)
borlanic 0:380207fcb5c1 67
borlanic 0:380207fcb5c1 68 def abort_build(args):
borlanic 0:380207fcb5c1 69 data = {}
borlanic 0:380207fcb5c1 70 data['status'] = 'aborted'
borlanic 0:380207fcb5c1 71
borlanic 0:380207fcb5c1 72 r = requests.put(urlparse.urljoin(args.url, "api/builds/" + args.build_id), headers=create_headers(args), json=data)
borlanic 0:380207fcb5c1 73 finish_command('abort-build', r)
borlanic 0:380207fcb5c1 74
borlanic 0:380207fcb5c1 75 def add_project_runs(args):
borlanic 0:380207fcb5c1 76 '''
borlanic 0:380207fcb5c1 77 -------------------------------------
borlanic 0:380207fcb5c1 78 Notes on 'project_run_data' structure:
borlanic 0:380207fcb5c1 79 --------------------------------------
borlanic 0:380207fcb5c1 80 'projectRuns' - Tree structure used to keep track of what projects have
borlanic 0:380207fcb5c1 81 been logged in different report files. The tree is organized as follows:
borlanic 0:380207fcb5c1 82
borlanic 0:380207fcb5c1 83 'projectRuns': { - Root element of tree
borlanic 0:380207fcb5c1 84
borlanic 0:380207fcb5c1 85 'hostOs': { - Host OS on which project was built/tested
borlanic 0:380207fcb5c1 86 - ex. windows, linux, or mac
borlanic 0:380207fcb5c1 87
borlanic 0:380207fcb5c1 88 'platform': { - Platform for which project was built/tested
borlanic 0:380207fcb5c1 89 (Corresponds to platform names in targets.py)
borlanic 0:380207fcb5c1 90 - ex. K64F, LPC1768, NRF51822, etc.
borlanic 0:380207fcb5c1 91
borlanic 0:380207fcb5c1 92 'toolchain': { - Toolchain with which project was built/tested
borlanic 0:380207fcb5c1 93 (Corresponds to TOOLCHAIN_CLASSES names in toolchains/__init__.py)
borlanic 0:380207fcb5c1 94 - ex. ARM, uARM, GCC_ARM, etc.
borlanic 0:380207fcb5c1 95
borlanic 0:380207fcb5c1 96 'project': { - Project that was build/tested
borlanic 0:380207fcb5c1 97 (Corresponds to test id in tests.py or library id in libraries.py)
borlanic 0:380207fcb5c1 98 - For tests, ex. MBED_A1, MBED_11, DTCT_1 etc.
borlanic 0:380207fcb5c1 99 - For libraries, ex. MBED, RTX, RTOS, etc.
borlanic 0:380207fcb5c1 100
borlanic 0:380207fcb5c1 101 },
borlanic 0:380207fcb5c1 102 ...
borlanic 0:380207fcb5c1 103 },
borlanic 0:380207fcb5c1 104 ...
borlanic 0:380207fcb5c1 105 },
borlanic 0:380207fcb5c1 106 ...
borlanic 0:380207fcb5c1 107 }
borlanic 0:380207fcb5c1 108 }
borlanic 0:380207fcb5c1 109
borlanic 0:380207fcb5c1 110 'platforms_set' - Set of all the platform names mentioned in the given report files
borlanic 0:380207fcb5c1 111
borlanic 0:380207fcb5c1 112 'toolchains_set' - Set of all the toolchain names mentioned in the given report files
borlanic 0:380207fcb5c1 113
borlanic 0:380207fcb5c1 114 'names_set' - Set of all the project names mentioned in the given report files
borlanic 0:380207fcb5c1 115
borlanic 0:380207fcb5c1 116 'hostOses_set' - Set of all the host names given (only given by the command line arguments)
borlanic 0:380207fcb5c1 117 '''
borlanic 0:380207fcb5c1 118
borlanic 0:380207fcb5c1 119 project_run_data = {}
borlanic 0:380207fcb5c1 120 project_run_data['projectRuns'] = {}
borlanic 0:380207fcb5c1 121 project_run_data['platforms_set'] = set()
borlanic 0:380207fcb5c1 122 project_run_data['vendors_set'] = set()
borlanic 0:380207fcb5c1 123 project_run_data['toolchains_set'] = set()
borlanic 0:380207fcb5c1 124 project_run_data['names_set'] = set()
borlanic 0:380207fcb5c1 125 project_run_data['hostOses_set'] = set()
borlanic 0:380207fcb5c1 126 project_run_data['hostOses_set'].add(args.host_os)
borlanic 0:380207fcb5c1 127
borlanic 0:380207fcb5c1 128 if args.build_report:
borlanic 0:380207fcb5c1 129 add_report(project_run_data, args.build_report, True, args.build_id, args.host_os)
borlanic 0:380207fcb5c1 130
borlanic 0:380207fcb5c1 131 if args.test_report:
borlanic 0:380207fcb5c1 132 add_report(project_run_data, args.test_report, False, args.build_id, args.host_os)
borlanic 0:380207fcb5c1 133
borlanic 0:380207fcb5c1 134 ts_data = format_project_run_data(project_run_data, args.limit)
borlanic 0:380207fcb5c1 135 total_result = True
borlanic 0:380207fcb5c1 136
borlanic 0:380207fcb5c1 137 total_parts = len(ts_data)
borlanic 0:380207fcb5c1 138 print "Uploading project runs in %d parts" % total_parts
borlanic 0:380207fcb5c1 139
borlanic 0:380207fcb5c1 140 for index, data in enumerate(ts_data):
borlanic 0:380207fcb5c1 141 r = requests.post(urlparse.urljoin(args.url, "api/projectRuns"), headers=create_headers(args), json=data)
borlanic 0:380207fcb5c1 142 print("add-project-runs part %d/%d" % (index + 1, total_parts), r.status_code, r.reason)
borlanic 0:380207fcb5c1 143 print(r.text)
borlanic 0:380207fcb5c1 144
borlanic 0:380207fcb5c1 145 if r.status_code >= 400:
borlanic 0:380207fcb5c1 146 total_result = False
borlanic 0:380207fcb5c1 147
borlanic 0:380207fcb5c1 148 if total_result:
borlanic 0:380207fcb5c1 149 print "'add-project-runs' completed successfully"
borlanic 0:380207fcb5c1 150 sys.exit(0)
borlanic 0:380207fcb5c1 151 else:
borlanic 0:380207fcb5c1 152 print "'add-project-runs' failed"
borlanic 0:380207fcb5c1 153 sys.exit(2)
borlanic 0:380207fcb5c1 154
borlanic 0:380207fcb5c1 155 def prep_ts_data():
borlanic 0:380207fcb5c1 156 ts_data = {}
borlanic 0:380207fcb5c1 157 ts_data['projectRuns'] = []
borlanic 0:380207fcb5c1 158 ts_data['platforms'] = set()
borlanic 0:380207fcb5c1 159 ts_data['vendors'] = set()
borlanic 0:380207fcb5c1 160 ts_data['toolchains'] = set()
borlanic 0:380207fcb5c1 161 ts_data['names'] = set()
borlanic 0:380207fcb5c1 162 ts_data['hostOses'] = set()
borlanic 0:380207fcb5c1 163 return ts_data
borlanic 0:380207fcb5c1 164
borlanic 0:380207fcb5c1 165 def finish_ts_data(ts_data, project_run_data):
borlanic 0:380207fcb5c1 166 ts_data['platforms'] = list(ts_data['platforms'])
borlanic 0:380207fcb5c1 167 ts_data['vendors'] = list(ts_data['vendors'])
borlanic 0:380207fcb5c1 168 ts_data['toolchains'] = list(ts_data['toolchains'])
borlanic 0:380207fcb5c1 169 ts_data['names'] = list(ts_data['names'])
borlanic 0:380207fcb5c1 170 ts_data['hostOses'] = list(ts_data['hostOses'])
borlanic 0:380207fcb5c1 171
borlanic 0:380207fcb5c1 172 # Add all vendors to every projectRun submission
borlanic 0:380207fcb5c1 173 # TODO Either add "vendor" to the "project_run_data"
borlanic 0:380207fcb5c1 174 # or remove "vendor" entirely from the viewer
borlanic 0:380207fcb5c1 175 ts_data['vendors'] = list(project_run_data['vendors_set'])
borlanic 0:380207fcb5c1 176
borlanic 0:380207fcb5c1 177 def format_project_run_data(project_run_data, limit):
borlanic 0:380207fcb5c1 178 all_ts_data = []
borlanic 0:380207fcb5c1 179 current_limit_count = 0
borlanic 0:380207fcb5c1 180
borlanic 0:380207fcb5c1 181 ts_data = prep_ts_data()
borlanic 0:380207fcb5c1 182 ts_data['projectRuns'] = []
borlanic 0:380207fcb5c1 183
borlanic 0:380207fcb5c1 184 for hostOs_name, hostOs in project_run_data['projectRuns'].items():
borlanic 0:380207fcb5c1 185 for platform_name, platform in hostOs.items():
borlanic 0:380207fcb5c1 186 for toolchain_name, toolchain in platform.items():
borlanic 0:380207fcb5c1 187 for project_name, project in toolchain.items():
borlanic 0:380207fcb5c1 188 if current_limit_count >= limit:
borlanic 0:380207fcb5c1 189 finish_ts_data(ts_data, project_run_data)
borlanic 0:380207fcb5c1 190 all_ts_data.append(ts_data)
borlanic 0:380207fcb5c1 191 ts_data = prep_ts_data()
borlanic 0:380207fcb5c1 192 current_limit_count = 0
borlanic 0:380207fcb5c1 193
borlanic 0:380207fcb5c1 194 ts_data['projectRuns'].append(project)
borlanic 0:380207fcb5c1 195 ts_data['platforms'].add(platform_name)
borlanic 0:380207fcb5c1 196 ts_data['toolchains'].add(toolchain_name)
borlanic 0:380207fcb5c1 197 ts_data['names'].add(project_name)
borlanic 0:380207fcb5c1 198 ts_data['hostOses'].add(hostOs_name)
borlanic 0:380207fcb5c1 199 current_limit_count += 1
borlanic 0:380207fcb5c1 200
borlanic 0:380207fcb5c1 201 if current_limit_count > 0:
borlanic 0:380207fcb5c1 202 finish_ts_data(ts_data, project_run_data)
borlanic 0:380207fcb5c1 203 all_ts_data.append(ts_data)
borlanic 0:380207fcb5c1 204
borlanic 0:380207fcb5c1 205 return all_ts_data
borlanic 0:380207fcb5c1 206
borlanic 0:380207fcb5c1 207 def find_project_run(projectRuns, project):
borlanic 0:380207fcb5c1 208 keys = ['hostOs', 'platform', 'toolchain', 'project']
borlanic 0:380207fcb5c1 209
borlanic 0:380207fcb5c1 210 elem = projectRuns
borlanic 0:380207fcb5c1 211
borlanic 0:380207fcb5c1 212 for key in keys:
borlanic 0:380207fcb5c1 213 if not project[key] in elem:
borlanic 0:380207fcb5c1 214 return None
borlanic 0:380207fcb5c1 215
borlanic 0:380207fcb5c1 216 elem = elem[project[key]]
borlanic 0:380207fcb5c1 217
borlanic 0:380207fcb5c1 218 return elem
borlanic 0:380207fcb5c1 219
borlanic 0:380207fcb5c1 220 def add_project_run(projectRuns, project):
borlanic 0:380207fcb5c1 221 keys = ['hostOs', 'platform', 'toolchain']
borlanic 0:380207fcb5c1 222
borlanic 0:380207fcb5c1 223 elem = projectRuns
borlanic 0:380207fcb5c1 224
borlanic 0:380207fcb5c1 225 for key in keys:
borlanic 0:380207fcb5c1 226 if not project[key] in elem:
borlanic 0:380207fcb5c1 227 elem[project[key]] = {}
borlanic 0:380207fcb5c1 228
borlanic 0:380207fcb5c1 229 elem = elem[project[key]]
borlanic 0:380207fcb5c1 230
borlanic 0:380207fcb5c1 231 elem[project['project']] = project
borlanic 0:380207fcb5c1 232
borlanic 0:380207fcb5c1 233 def update_project_run_results(project_to_update, project, is_build):
borlanic 0:380207fcb5c1 234 if is_build:
borlanic 0:380207fcb5c1 235 project_to_update['buildPass'] = project['buildPass']
borlanic 0:380207fcb5c1 236 project_to_update['buildResult'] = project['buildResult']
borlanic 0:380207fcb5c1 237 project_to_update['buildOutput'] = project['buildOutput']
borlanic 0:380207fcb5c1 238 else:
borlanic 0:380207fcb5c1 239 project_to_update['testPass'] = project['testPass']
borlanic 0:380207fcb5c1 240 project_to_update['testResult'] = project['testResult']
borlanic 0:380207fcb5c1 241 project_to_update['testOutput'] = project['testOutput']
borlanic 0:380207fcb5c1 242
borlanic 0:380207fcb5c1 243 def update_project_run(projectRuns, project, is_build):
borlanic 0:380207fcb5c1 244 found_project = find_project_run(projectRuns, project)
borlanic 0:380207fcb5c1 245 if found_project:
borlanic 0:380207fcb5c1 246 update_project_run_results(found_project, project, is_build)
borlanic 0:380207fcb5c1 247 else:
borlanic 0:380207fcb5c1 248 add_project_run(projectRuns, project)
borlanic 0:380207fcb5c1 249
borlanic 0:380207fcb5c1 250 def add_report(project_run_data, report_file, is_build, build_id, host_os):
borlanic 0:380207fcb5c1 251 tree = None
borlanic 0:380207fcb5c1 252
borlanic 0:380207fcb5c1 253 try:
borlanic 0:380207fcb5c1 254 tree = ET.parse(report_file)
borlanic 0:380207fcb5c1 255 except:
borlanic 0:380207fcb5c1 256 print(sys.exc_info()[0])
borlanic 0:380207fcb5c1 257 print('Invalid path to report: %s', report_file)
borlanic 0:380207fcb5c1 258 sys.exit(1)
borlanic 0:380207fcb5c1 259
borlanic 0:380207fcb5c1 260 test_suites = tree.getroot()
borlanic 0:380207fcb5c1 261
borlanic 0:380207fcb5c1 262 for test_suite in test_suites:
borlanic 0:380207fcb5c1 263 platform = ""
borlanic 0:380207fcb5c1 264 toolchain = ""
borlanic 0:380207fcb5c1 265 vendor = ""
borlanic 0:380207fcb5c1 266 for properties in test_suite.findall('properties'):
borlanic 0:380207fcb5c1 267 for property in properties.findall('property'):
borlanic 0:380207fcb5c1 268 if property.attrib['name'] == 'target':
borlanic 0:380207fcb5c1 269 platform = property.attrib['value']
borlanic 0:380207fcb5c1 270 project_run_data['platforms_set'].add(platform)
borlanic 0:380207fcb5c1 271 elif property.attrib['name'] == 'toolchain':
borlanic 0:380207fcb5c1 272 toolchain = property.attrib['value']
borlanic 0:380207fcb5c1 273 project_run_data['toolchains_set'].add(toolchain)
borlanic 0:380207fcb5c1 274 elif property.attrib['name'] == 'vendor':
borlanic 0:380207fcb5c1 275 vendor = property.attrib['value']
borlanic 0:380207fcb5c1 276 project_run_data['vendors_set'].add(vendor)
borlanic 0:380207fcb5c1 277
borlanic 0:380207fcb5c1 278 for test_case in test_suite.findall('testcase'):
borlanic 0:380207fcb5c1 279 projectRun = {}
borlanic 0:380207fcb5c1 280 projectRun['build'] = build_id
borlanic 0:380207fcb5c1 281 projectRun['hostOs'] = host_os
borlanic 0:380207fcb5c1 282 projectRun['platform'] = platform
borlanic 0:380207fcb5c1 283 projectRun['toolchain'] = toolchain
borlanic 0:380207fcb5c1 284 projectRun['project'] = test_case.attrib['classname'].split('.')[-1]
borlanic 0:380207fcb5c1 285 projectRun['vendor'] = vendor
borlanic 0:380207fcb5c1 286
borlanic 0:380207fcb5c1 287 project_run_data['names_set'].add(projectRun['project'])
borlanic 0:380207fcb5c1 288
borlanic 0:380207fcb5c1 289 should_skip = False
borlanic 0:380207fcb5c1 290 skips = test_case.findall('skipped')
borlanic 0:380207fcb5c1 291
borlanic 0:380207fcb5c1 292 if skips:
borlanic 0:380207fcb5c1 293 should_skip = skips[0].attrib['message'] == 'SKIP'
borlanic 0:380207fcb5c1 294
borlanic 0:380207fcb5c1 295 if not should_skip:
borlanic 0:380207fcb5c1 296 system_outs = test_case.findall('system-out')
borlanic 0:380207fcb5c1 297
borlanic 0:380207fcb5c1 298 output = ""
borlanic 0:380207fcb5c1 299 if system_outs:
borlanic 0:380207fcb5c1 300 output = system_outs[0].text
borlanic 0:380207fcb5c1 301
borlanic 0:380207fcb5c1 302 if is_build:
borlanic 0:380207fcb5c1 303 projectRun['buildOutput'] = output
borlanic 0:380207fcb5c1 304 else:
borlanic 0:380207fcb5c1 305 projectRun['testOutput'] = output
borlanic 0:380207fcb5c1 306
borlanic 0:380207fcb5c1 307 errors = test_case.findall('error')
borlanic 0:380207fcb5c1 308 failures = test_case.findall('failure')
borlanic 0:380207fcb5c1 309 projectRunPass = None
borlanic 0:380207fcb5c1 310 result = None
borlanic 0:380207fcb5c1 311
borlanic 0:380207fcb5c1 312 if errors:
borlanic 0:380207fcb5c1 313 projectRunPass = False
borlanic 0:380207fcb5c1 314 result = errors[0].attrib['message']
borlanic 0:380207fcb5c1 315 elif failures:
borlanic 0:380207fcb5c1 316 projectRunPass = False
borlanic 0:380207fcb5c1 317 result = failures[0].attrib['message']
borlanic 0:380207fcb5c1 318 elif skips:
borlanic 0:380207fcb5c1 319 projectRunPass = True
borlanic 0:380207fcb5c1 320 result = skips[0].attrib['message']
borlanic 0:380207fcb5c1 321 else:
borlanic 0:380207fcb5c1 322 projectRunPass = True
borlanic 0:380207fcb5c1 323 result = 'OK'
borlanic 0:380207fcb5c1 324
borlanic 0:380207fcb5c1 325 if is_build:
borlanic 0:380207fcb5c1 326 projectRun['buildPass'] = projectRunPass
borlanic 0:380207fcb5c1 327 projectRun['buildResult'] = result
borlanic 0:380207fcb5c1 328 else:
borlanic 0:380207fcb5c1 329 projectRun['testPass'] = projectRunPass
borlanic 0:380207fcb5c1 330 projectRun['testResult'] = result
borlanic 0:380207fcb5c1 331
borlanic 0:380207fcb5c1 332 update_project_run(project_run_data['projectRuns'], projectRun, is_build)
borlanic 0:380207fcb5c1 333
borlanic 0:380207fcb5c1 334 def main(arguments):
borlanic 0:380207fcb5c1 335 # Register and parse command line arguments
borlanic 0:380207fcb5c1 336 parser = argparse.ArgumentParser()
borlanic 0:380207fcb5c1 337 parser.add_argument('-u', '--url', required=True, help='url to ci site')
borlanic 0:380207fcb5c1 338 parser.add_argument('-k', '--api-key', required=True, help='api-key for posting data')
borlanic 0:380207fcb5c1 339
borlanic 0:380207fcb5c1 340 subparsers = parser.add_subparsers(help='subcommand help')
borlanic 0:380207fcb5c1 341
borlanic 0:380207fcb5c1 342 create_build_parser = subparsers.add_parser('create-build', help='create a new build')
borlanic 0:380207fcb5c1 343 create_build_parser.add_argument('-b', '--build-number', required=True, help='build number')
borlanic 0:380207fcb5c1 344 create_build_parser.add_argument('-T', '--build-type', choices=['Nightly', 'Limited', 'Pull_Request', 'Release_Candidate'], required=True, help='type of build')
borlanic 0:380207fcb5c1 345 create_build_parser.add_argument('-s', '--build-source', required=True, help='url to source of build')
borlanic 0:380207fcb5c1 346 create_build_parser.add_argument('-p', '--property-file-format', action='store_true', help='print result in the property file format')
borlanic 0:380207fcb5c1 347 create_build_parser.set_defaults(func=create_build)
borlanic 0:380207fcb5c1 348
borlanic 0:380207fcb5c1 349 finish_build_parser = subparsers.add_parser('finish-build', help='finish a running build')
borlanic 0:380207fcb5c1 350 finish_build_parser.add_argument('-b', '--build-id', required=True, help='build id')
borlanic 0:380207fcb5c1 351 finish_build_parser.set_defaults(func=finish_build)
borlanic 0:380207fcb5c1 352
borlanic 0:380207fcb5c1 353 finish_build_parser = subparsers.add_parser('promote-build', help='promote a build to a release')
borlanic 0:380207fcb5c1 354 finish_build_parser.add_argument('-b', '--build-id', required=True, help='build id')
borlanic 0:380207fcb5c1 355 finish_build_parser.set_defaults(func=promote_build)
borlanic 0:380207fcb5c1 356
borlanic 0:380207fcb5c1 357 abort_build_parser = subparsers.add_parser('abort-build', help='abort a running build')
borlanic 0:380207fcb5c1 358 abort_build_parser.add_argument('-b', '--build-id', required=True, help='build id')
borlanic 0:380207fcb5c1 359 abort_build_parser.set_defaults(func=abort_build)
borlanic 0:380207fcb5c1 360
borlanic 0:380207fcb5c1 361 add_project_runs_parser = subparsers.add_parser('add-project-runs', help='add project runs to a build')
borlanic 0:380207fcb5c1 362 add_project_runs_parser.add_argument('-b', '--build-id', required=True, help='build id')
borlanic 0:380207fcb5c1 363 add_project_runs_parser.add_argument('-r', '--build-report', required=False, help='path to junit xml build report')
borlanic 0:380207fcb5c1 364 add_project_runs_parser.add_argument('-t', '--test-report', required=False, help='path to junit xml test report')
borlanic 0:380207fcb5c1 365 add_project_runs_parser.add_argument('-o', '--host-os', required=True, help='host os on which test was run')
borlanic 0:380207fcb5c1 366 add_project_runs_parser.add_argument('-l', '--limit', required=False, type=int, default=1000, help='Limit the number of project runs sent at a time to avoid HTTP errors (default is 1000)')
borlanic 0:380207fcb5c1 367 add_project_runs_parser.set_defaults(func=add_project_runs)
borlanic 0:380207fcb5c1 368
borlanic 0:380207fcb5c1 369 args = parser.parse_args(arguments)
borlanic 0:380207fcb5c1 370 args.func(args)
borlanic 0:380207fcb5c1 371
borlanic 0:380207fcb5c1 372 if __name__ == '__main__':
borlanic 0:380207fcb5c1 373 main(sys.argv[1:])