aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests
diff options
context:
space:
mode:
authorGravatar Lidi Zheng <lidiz@google.com>2018-12-17 18:14:58 -0800
committerGravatar Lidi Zheng <lidiz@google.com>2018-12-17 18:14:58 -0800
commiteafb1d527d8fc1f367215429fde9421aac876ef2 (patch)
tree0698389d7d13e60f18016cd4cfa6a4e1136de89b /tools/run_tests
parent6692429f31dc715e55fe37d95837b773494fcd99 (diff)
Reorgnize dependencies and variables
Diffstat (limited to 'tools/run_tests')
-rw-r--r--tools/run_tests/python_utils/check_on_pr.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/tools/run_tests/python_utils/check_on_pr.py b/tools/run_tests/python_utils/check_on_pr.py
index 78f1dca817..d59f99b252 100644
--- a/tools/run_tests/python_utils/check_on_pr.py
+++ b/tools/run_tests/python_utils/check_on_pr.py
@@ -25,21 +25,21 @@ _GITHUB_API_PREFIX = 'https://api.github.com'
_GITHUB_REPO = 'grpc/grpc'
_GITHUB_APP_ID = 22338
_INSTALLATION_ID = 519109
-_GITHUB_APP_KEY = open(
- os.path.join(os.environ['KOKORO_KEYSTORE_DIR'], '73836_grpc_checks_private_key'),
- 'rb').read()
_ACCESS_TOKEN_CACHE = None
def _jwt_token():
+ github_app_key = open(
+ os.path.join(os.environ['KOKORO_KEYSTORE_DIR'],
+ '73836_grpc_checks_private_key'), 'rb').read()
return jwt.encode(
{
'iat': int(time.time()),
'exp': int(time.time() + 60 * 10), # expire in 10 minutes
'iss': _GITHUB_APP_ID,
},
- _GITHUB_APP_KEY,
+ github_app_key,
algorithm='RS256')
@@ -90,25 +90,26 @@ def check_on_pr(name, summary, success=True):
summary: A str in Markdown to be used as the detail information of the check.
success: A bool indicates whether the check is succeed or not.
"""
+ if 'KOKORO_GIT_COMMIT' not in os.environ:
+ print('Missing KOKORO_GIT_COMMIT env var: not checking')
+ return
+ if 'KOKORO_KEYSTORE_DIR' not in os.environ:
+ print('Missing KOKORO_KEYSTORE_DIR env var: not checking')
+ return
if 'ghprbPullId' not in os.environ:
- print('Missing ghprbPullId env var: not commenting')
+ print('Missing ghprbPullId env var: not checking')
return
- commit = _latest_commit()
+ completion_time = str(
+ datetime.datetime.utcnow().replace(microsecond=0).isoformat()) + 'Z'
resp = _call(
'/repos/%s/check-runs' % _GITHUB_REPO,
method='POST',
json={
- 'name':
- name,
- 'head_sha':
- commit['sha'],
- 'status':
- 'completed',
- 'completed_at':
- '%sZ' %
- datetime.datetime.utcnow().replace(microsecond=0).isoformat(),
- 'conclusion':
- 'success' if success else 'failure',
+ 'name': name,
+ 'head_sha': os.environ['KOKORO_GIT_COMMIT'],
+ 'status': 'completed',
+ 'completed_at': completion_time,
+ 'conclusion': 'success' if success else 'failure',
'output': {
'title': name,
'summary': summary,