Unverified Commit 53639f4a authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[ci] Slightly optimize optional workflows checks (#3762)

* Update optional_checks.yml

* Update get_workflow_status.py
parent a15a3704
# coding: utf-8 # coding: utf-8
"""Get the most recent status of workflow for the current PR.""" """Get the most recent status of workflow for the current PR.
[usage]
python get_workflow_status.py TRIGGER_PHRASE
TRIGGER_PHRASE: Code phrase that triggers workflow.
"""
import json import json
from os import environ from os import environ
from sys import argv, exit from sys import argv, exit
...@@ -10,13 +16,13 @@ except ImportError: ...@@ -10,13 +16,13 @@ except ImportError:
import urllib2 as request import urllib2 as request
def get_runs(workflow_name): def get_runs(trigger_phrase):
"""Get all triggering workflow comments in the current PR. """Get all triggering workflow comments in the current PR.
Parameters Parameters
---------- ----------
workflow_name : string trigger_phrase : string
Name of the workflow. Code phrase that triggers workflow.
Returns Returns
------- -------
...@@ -34,8 +40,7 @@ def get_runs(workflow_name): ...@@ -34,8 +40,7 @@ def get_runs(workflow_name):
url.close() url.close()
pr_runs = [i for i in data pr_runs = [i for i in data
if i['author_association'].lower() in {'owner', 'member', 'collaborator'} if i['author_association'].lower() in {'owner', 'member', 'collaborator'}
and i['body'].startswith('/gha run') and i['body'].startswith('/gha run {}'.format(trigger_phrase))]
and 'Workflow **{}** has been triggered!'.format(workflow_name) in i['body']]
return pr_runs[::-1] return pr_runs[::-1]
...@@ -72,9 +77,9 @@ def get_status(runs): ...@@ -72,9 +77,9 @@ def get_status(runs):
if __name__ == "__main__": if __name__ == "__main__":
workflow_name = argv[1] trigger_phrase = argv[1]
while True: while True:
status = get_status(get_runs(workflow_name)) status = get_status(get_runs(trigger_phrase))
if status != 'in-progress': if status != 'in-progress':
break break
sleep(60) sleep(60)
......
...@@ -17,9 +17,11 @@ jobs: ...@@ -17,9 +17,11 @@ jobs:
submodules: false submodules: false
- name: Check that all tests succeeded - name: Check that all tests succeeded
run: | run: |
workflows=("R valgrind tests") workflows=("R valgrind tests;r-valgrind")
for i in "${workflows[@]}"; do for i in "${workflows[@]}"; do
python "$GITHUB_WORKSPACE/.ci/get_workflow_status.py" "$i" \ workflow_name=${i%;*}
|| { echo "The last reported status from workflow \"$i\" is failure. Commit fixes and rerun the workflow."; \ trigger_phrase=${i#*;}
python "$GITHUB_WORKSPACE/.ci/get_workflow_status.py" "$trigger_phrase" \
|| { echo "The last reported status from workflow \"$workflow_name\" is failure. Commit fixes and rerun the workflow."; \
exit -1; } exit -1; }
done done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment