Skip to content

Commit

Permalink
pushing test reports to api
Browse files Browse the repository at this point in the history
  • Loading branch information
ric03uec committed Feb 4, 2016
1 parent e7e26d7 commit 39b1a4b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
Binary file modified bin/reports
Binary file not shown.
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self):
self['LOG_LEVEL'] = 'INFO'
else:
self['LOG_LEVEL'] = 'DEBUG'
self['LOG_LEVEL'] = 'DEBUG'

self['SHIPPABLE_API_URL'] = os.getenv('SHIPPABLE_API_URL', '')
self['SHIPPABLE_VORTEX_URL'] = "{0}/vortex".format(self['SHIPPABLE_API_URL'])
Expand All @@ -35,6 +36,7 @@ def __init__(self):
self['MESSAGE_JSON_NAME'] = os.getenv('MESSAGE_JSON_NAME', 'message.json')
self['WHO'] = os.getenv('WHO', 'cexec')
self['SSH_DIR'] = os.getenv('SSH_DIR', '/tmp/ssh')
self['ARTIFACTS_DIR'] = os.getenv('ARTIFACTS_DIR', '/shippableci')

for k, v in self.iteritems():
if v == '':
Expand Down
Binary file modified dist/main/main
Binary file not shown.
24 changes: 24 additions & 0 deletions execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def __init__(self):
self.builder_api_token = None
self.job_id = None
self.parsed_message = None
self.test_results_file = 'testresults.json'
self.coverage_results_file = 'coverageresults.json'
self.__validate_message()
self.shippable_adapter = ShippableAdapter(self.builder_api_token)

Expand Down Expand Up @@ -109,8 +111,30 @@ def run(self):
else:
break

self._push_test_results()

return exit_code

def _push_test_results(self):
self.log.debug('Inside _push_test_reports')
test_results_file = '{0}/testresults/{1}'.format(
self.config['ARTIFACTS_DIR'],
self.test_results_file)
if os.path.exists(test_results_file):
self.log.debug('Test results exist, reading file')

test_results = ''
with open(test_results_file, 'r') as results_file:
test_results = results_file.read()

self.log.debug('Successfully read test results, parsing')
test_results = json.loads(test_results)
test_results['jobId'] = self.job_id
self.shippable_adapter.post_test_results(test_results)

def _push_coverage_results(self):
self.log.debug('Inside _push_coverage_results')

def _report_step_status(self, step_id, step_status):
self.log.debug('Inside report_job_status')
err, job = self.shippable_adapter.get_job_by_id(self.job_id)
Expand Down
8 changes: 8 additions & 0 deletions shippable_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ def get_job_by_id(self, job_id):
def put_job_by_id(self, job_id, job):
url = '{0}/jobs/{1}'.format(self.api_url, job_id)
self.__put(url, job)

def post_test_results(self, body):
url = '{0}/jobTestReports'.format(self.api_url)
self.__post(url, body)

def post_coverage_results(self, body):
url = '{0}/jobTestReports'.format(self.api_url)
self.__post(url, body)

0 comments on commit 39b1a4b

Please sign in to comment.