Skip to content

Commit 9bb5217

Browse files
committed
[add] Further logging on API. Using PULL_REQUEST_TRIGGER_LABEL env var to decide uppon which PR label to use for trigger automation
1 parent 29dfb4e commit 9bb5217

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

redis_benchmarks_specification/__api__/app.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import logging
32

43
from flask import jsonify
54
import redis
@@ -10,6 +9,7 @@
109
from redis_benchmarks_specification.__common__.builder_schema import (
1110
commit_schema_to_stream,
1211
)
12+
from redis_benchmarks_specification.__common__.env import PULL_REQUEST_TRIGGER_LABEL
1313

1414
SIG_HEADER = "X-Hub-Signature"
1515

@@ -60,7 +60,7 @@ def base():
6060
event_type = "Ignored event from webhook"
6161
use_event = False
6262
# Pull request labeled
63-
trigger_label = "trigger-benchmark"
63+
trigger_label = PULL_REQUEST_TRIGGER_LABEL
6464
if "pull_request" in request_data:
6565
action = request_data["action"]
6666
if "labeled" == action:
@@ -98,22 +98,24 @@ def base():
9898

9999
if use_event is True:
100100
fields = {"git_hash": sha, "ref_label": ref_label, "ref": ref}
101-
logging.info(
101+
app.logger.info(
102102
"Using event {} to trigger benchmark. final fields: {}".format(
103103
event_type, fields
104104
)
105105
)
106106
result, response_data, err_message = commit_schema_to_stream(
107107
fields, conn, gh_org, gh_repo
108108
)
109-
logging.info(
109+
app.logger.info(
110110
"Using event {} to trigger benchmark. final fields: {}".format(
111111
event_type, response_data
112112
)
113113
)
114114

115115
else:
116-
logging.info("{}. input json was: {}".format(event_type, request_data))
116+
app.logger.info(
117+
"{}. input json was: {}".format(event_type, request_data)
118+
)
117119
response_data = {"message": event_type}
118120

119121
# Send data back as JSON

redis_benchmarks_specification/__common__/env.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
REDIS_SOCKET_TIMEOUT = int(os.getenv("REDIS_SOCKET_TIMEOUT", "300"))
5151

5252
# environment variables
53+
PULL_REQUEST_TRIGGER_LABEL = os.getenv(
54+
"PULL_REQUEST_TRIGGER_LABEL", "trigger-benchmark"
55+
)
5356
DATASINK_RTS_PUSH = bool(os.getenv("DATASINK_PUSH_RTS", False))
5457
DATASINK_RTS_AUTH = os.getenv("DATASINK_RTS_AUTH", None)
5558
DATASINK_RTS_USER = os.getenv("DATASINK_RTS_USER", None)

utils/tests/test_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_commit_schema_to_stream_then_build():
5656
},
5757
conn,
5858
"redis",
59-
"redis"
59+
"redis",
6060
)
6161
assert result == True
6262
assert error_msg == None

0 commit comments

Comments
 (0)