Skip to content

Instantly share code, notes, and snippets.

Last active February 17, 2023 21:35
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import os
import datetime
import requests
import orjson
def pytest_terminal_summary(terminalreporter, exitstatus, config):
token = os.environ.get('TINYBIRD_TOKEN')
commit = os.environ.get('CI_COMMIT_SHA')
job_id = os.environ.get('CI_JOB_ID')
if not commit or not job_id:
# Only get metrics about CI
now = str(
report = []
for k in terminalreporter.stats:
for test in terminalreporter.stats[k]:
'date': now,
'commit': commit,
'job_id': job_id,
'job_url': os.environ.get('CI_JOB_URL', ''),
'job_name': os.environ.get('CI_JOB_NAME', ''),
'test_nodeid': test.nodeid,
'test_name': test.head_line,
'test_part': test.when,
'duration': test.duration,
'outcome': test.outcome
except Exception:
data = b'\n'.join(orjson.dumps(x) for x in report)
response ='{token}', data=data)
if response.status_code != 202:
print("Error while uploading to tinybird")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment