summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2019-07-15 10:33:12 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2019-07-15 10:33:12 +0100
commita61084f342e5940ea550f43786c4ca780a8e3989 (patch)
tree5948adeb9181408caf7560422f4ad472e9297164
parent8391293c92150dcedac5acb3d4f7f04a61b98bdc (diff)
fix qa-reports submission
Change-Id: Ief7677610bf4ab04a5fac9b0119e8c12d7148322 Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
-rw-r--r--post-build-report.py45
1 files changed, 25 insertions, 20 deletions
diff --git a/post-build-report.py b/post-build-report.py
index 12594af..12700a9 100644
--- a/post-build-report.py
+++ b/post-build-report.py
@@ -14,7 +14,7 @@ from StringIO import StringIO
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
-httplib.HTTPConnection.debuglevel = 1
+httplib.HTTPConnection.debuglevel = 0
RESULT_ENDPOINT = "/api/result/"
@@ -46,7 +46,6 @@ def encode_multipart_formdata(fields, files):
L.append('')
L.append(value)
for key, values in files.iteritems():
- print key
if type(values) is not list:
values = [values]
for value in values:
@@ -79,7 +78,7 @@ def _push_object(auth_pw, backend_url, endpoint, params, files):
conn = httplib.HTTPS(usplit.netloc)
if conn is None:
- print "Unknown scheme: %s" % usplit.scheme
+ logger.info("Unknown scheme: %s" % usplit.scheme)
sys.exit(1)
content_type, body = encode_multipart_formdata(params, files)
@@ -108,11 +107,11 @@ def _push_object(auth_pw, backend_url, endpoint, params, files):
def _get_manifest(workspace_path):
manifest_path = os.path.join(workspace_path, "pinned-manifest.xml")
- print "Searching for: %s" % manifest_path
+ logger.info("Searching for: %s" % manifest_path)
if os.path.exists(manifest_path):
with open(manifest_path, "r") as manifest_file:
return manifest_file.read()
- print "Manifest not found"
+ logger.warning("Manifest not found")
return None
@@ -122,7 +121,7 @@ def _get_files(workspace_path):
for result_file_name in filenames:
if result_file_name.endswith(".json"):
statinfo = os.stat(os.path.join(dirpath, result_file_name))
- print("adding %s [%s]" % (result_file_name, statinfo.st_size))
+ logger.info("adding %s [%s]" % (result_file_name, statinfo.st_size))
files_dict.update({result_file_name: (result_file_name, open(os.path.join(dirpath, result_file_name), 'rb'))})
return files_dict
@@ -157,7 +156,7 @@ def _results(workspace_path):
for benchmark, subscores in benchmarks.items():
for subscore in subscores:
path = os.path.join(workspace_path, subscore)
- print path, os.path.exists(path)
+ logger.debug(path, os.path.exists(path))
if os.path.exists(path):
raw = open(path, 'r').read().strip()
measurement = float(raw.replace("YVALUE=", ""))
@@ -177,7 +176,7 @@ def _results(workspace_path):
return val
-if __name__ == '__main__':
+def main():
jenkins_project_name = os.environ.get("SOURCE_PROJECT_NAME")
jenkins_build_number = os.environ.get("SOURCE_BUILD_NUMBER")
@@ -206,22 +205,22 @@ if __name__ == '__main__':
results = _results("./artifacts")
if jenkins_build_number is None:
- print "Build number not set. Exiting!"
+ logger.error("Build number not set. Exiting!")
sys.exit(1)
if jenkins_project_name is None:
- print "Project name not set. Exiting!"
+ logger.error("Project name not set. Exiting!")
sys.exit(1)
if jenkins_build_url is None:
- print "Build URL not set. Exiting!"
+ logger.error("Build URL not set. Exiting!")
sys.exit(1)
if art_token is None:
- print "ART token not set. Exiting!"
+ logger.error("ART token not set. Exiting!")
sys.exit(1)
if not manifest:
- print "Manifest missing. Exiting!"
+ logger.error("Manifest missing. Exiting!")
sys.exit(1)
- print "Registered test jobs: %s" % test_jobs
+ logger.info("Registered test jobs: %s" % test_jobs)
params = {
'name': jenkins_project_name,
@@ -242,6 +241,9 @@ if __name__ == '__main__':
"results": results
}
+ #jenkins_created_at = os.environ.get("CREATED_AT", None)
+ #if jenkins_created_at is not None:
+ # params.update({'created_at': jenkins_created_at})
if not results:
params.pop("results")
@@ -251,15 +253,15 @@ if __name__ == '__main__':
files = _get_files("./artifacts")
_push_object(art_token, art_url, RESULT_ENDPOINT, params, files)
params.pop('manifest')
- print params
+ logger.debug(params)
# submit to QA reports
if qa_reports_url is None:
- sys.exit(0)
+ return
if qa_reports_token is None:
- print("Token for QA reports missing. Exiting")
- sys.exit(1)
+ logger.error("Token for QA reports missing. Exiting")
+ return
# produce reduced manifest hash
doc = ET.fromstring(manifest)
@@ -277,7 +279,7 @@ if __name__ == '__main__':
# endpoint comes in format team/project/build/environment
# there should 'baseline' and 'patch' projects for each branch
project_name = "%s" % (branch_name)
- if os.environ.get("SOURCE_GERRIT_CHANGE_NUMBER", "") is not None:
+ if os.environ.get("SOURCE_GERRIT_CHANGE_NUMBER", ""):
project_name = project_name + "-patch"
else:
project_name = project_name + "-baseline"
@@ -295,7 +297,7 @@ if __name__ == '__main__':
file_contents.seek(0)
metrics_data_raw = json.load(file_contents)
metrics_data = metrics_data_raw['benchmarks']
- transcode_results_dict(metrics_data, metrics_data_raw['compilation statistics'])
+ transcode_results_dict(metrics_data, metrics_data_raw.get('compilation statistics', {}))
json.dump(metrics_data, metrics)
result_files = {
"metadata": ("metadata.json", squad_params),
@@ -303,3 +305,6 @@ if __name__ == '__main__':
"metrics": ("results.json", metrics)
}
_push_object(qa_reports_token, qa_reports_url, qa_reports_endpoint, {}, result_files)
+
+if __name__ == '__main__':
+ main()