Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
53639f4a
Unverified
Commit
53639f4a
authored
Jan 15, 2021
by
Nikita Titov
Committed by
GitHub
Jan 15, 2021
Browse files
[ci] Slightly optimize optional workflows checks (#3762)
* Update optional_checks.yml * Update get_workflow_status.py
parent
a15a3704
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
.ci/get_workflow_status.py
.ci/get_workflow_status.py
+13
-8
.github/workflows/optional_checks.yml
.github/workflows/optional_checks.yml
+5
-3
No files found.
.ci/get_workflow_status.py
View file @
53639f4a
# 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_nam
e
):
def
get_runs
(
trigger_phras
e
):
"""Get all triggering workflow comments in the current PR.
"""Get all triggering workflow comments in the current PR.
Parameters
Parameters
----------
----------
workflow_nam
e : string
trigger_phras
e : 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_nam
e
=
argv
[
1
]
trigger_phras
e
=
argv
[
1
]
while
True
:
while
True
:
status
=
get_status
(
get_runs
(
workflow_nam
e
))
status
=
get_status
(
get_runs
(
trigger_phras
e
))
if
status
!=
'in-progress'
:
if
status
!=
'in-progress'
:
break
break
sleep
(
60
)
sleep
(
60
)
...
...
.github/workflows/optional_checks.yml
View file @
53639f4a
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment