mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-26 17:37:33 +00:00
feat(test): add option to send to slack thread (#5673)
This commit is contained in:
parent
9da6f12c18
commit
2ba80f0418
@ -1,7 +1,5 @@
|
||||
from slack_sdk import WebClient
|
||||
import os
|
||||
import asyncio
|
||||
from datahub.upgrade.upgrade import retrieve_version_stats
|
||||
|
||||
|
||||
datahub_stats = {}
|
||||
@ -14,6 +12,7 @@ def add_datahub_stats(stat_name, stat_val):
|
||||
def send_to_slack(passed: str):
|
||||
slack_api_token = os.getenv('SLACK_API_TOKEN')
|
||||
slack_channel = os.getenv('SLACK_CHANNEL')
|
||||
slack_thread_ts = os.getenv('SLACK_THREAD_TS')
|
||||
test_identifier = os.getenv('TEST_IDENTIFIER', 'LOCAL_TEST')
|
||||
if slack_api_token is None or slack_channel is None:
|
||||
return
|
||||
@ -26,7 +25,10 @@ def send_to_slack(passed: str):
|
||||
entity_type = key.replace("num-", "")
|
||||
message += f"Num {entity_type} is {val}\n"
|
||||
|
||||
client.chat_postMessage(channel=slack_channel, text=f'{test_identifier} Status - {passed}\n{message}')
|
||||
if slack_thread_ts is None:
|
||||
client.chat_postMessage(channel=slack_channel, text=f'{test_identifier} Status - {passed}\n{message}')
|
||||
else:
|
||||
client.chat_postMessage(channel=slack_channel, text=f'{test_identifier} Status - {passed}\n{message}', thread_ts=slack_thread_ts)
|
||||
|
||||
|
||||
def send_message(exitstatus):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user