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