Add support for Workflow Runs (#1583)

To build on the previous work supporting querying Workflows for GitHub
Actions, add a class and relevant methods to support querying runs of a
workflow.
This commit is contained in:
Steve Kowalik
2020-06-26 20:47:42 +10:00
committed by GitHub
parent 4ed7aaf8e5
commit 4fb1d23f4d
18 changed files with 784 additions and 2 deletions
+31
View File
@@ -136,6 +136,7 @@ import github.Tag
import github.Team
import github.View
import github.Workflow
import github.WorkflowRun
from . import Consts
@@ -3007,9 +3008,24 @@ class Repository(github.GithubObject.CompletableGithubObject):
list_item="workflows",
)
def get_workflow_runs(self):
"""
:calls: `GET /repos/:owner/:repo/actions/runs <https://developer.github.com/v3/actions/workflow-runs>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.WorkflowRun.WorkflowRun`
"""
return github.PaginatedList.PaginatedList(
github.WorkflowRun.WorkflowRun,
self._requester,
self.url + "/actions/runs",
None,
list_item="workflow_runs",
)
def get_workflow(self, id_or_name):
"""
:calls: `GET /repos/:owner/:repo/actions/workflows/:workflow_id <https://developer.github.com/v3/actions/workflows>`_
:param id_or_name: int or string
:rtype: :class:`github.Workflow.Workflow`
"""
assert isinstance(id_or_name, int) or isinstance(id_or_name, str), id_or_name
@@ -3018,6 +3034,21 @@ class Repository(github.GithubObject.CompletableGithubObject):
)
return github.Workflow.Workflow(self._requester, headers, data, completed=True)
def get_workflow_run(self, id_):
"""
:calls: `GET /repos/:owner/:repo/actions/runs/:run_id <https://developer.github.com/v3/actions/workflow-runs>`_
:param id_: int
:rtype: :class:`github.WorkflowRun.WorkflowRun`
"""
assert isinstance(id_, int)
headers, data = self._requester.requestJsonAndCheck(
"GET", self.url + "/actions/runs/" + str(id_)
)
return github.WorkflowRun.WorkflowRun(
self._requester, headers, data, completed=True
)
def has_in_assignees(self, assignee):
"""
:calls: `GET /repos/:owner/:repo/assignees/:assignee <http://developer.github.com/v3/issues/assignees>`_