Add method to delete Workflow runs (#2078)

One piece of missing functionality is the ability to delete Workflow
Runs, which the GitHub API supports. Add a delete() method to
WorkflowRun.

Fixes #2019
This commit is contained in:
Steve Kowalik
2021-10-15 15:40:09 +11:00
committed by GitHub
parent 53fb49882f
commit b1c8eec58f
3 changed files with 34 additions and 0 deletions
+8
View File
@@ -243,6 +243,14 @@ class WorkflowRun(github.GithubObject.CompletableGithubObject):
timingdata = namedtuple("TimingData", data.keys())
return timingdata._make(data.values())
def delete(self):
"""
:calls: `DELETE /repos/{owner}/{repo}/actions/runs/{run_id} <https://docs.github.com/en/rest/reference/actions#workflow-runs>`_
:rtype: bool
"""
status, _, _ = self._requester.requestJson("DELETE", self.url)
return status == 204
def _initAttributes(self):
self._id = github.GithubObject.NotSet
self._head_branch = github.GithubObject.NotSet
File diff suppressed because one or more lines are too long
+4
View File
@@ -105,3 +105,7 @@ class WorkflowRun(Framework.TestCase):
def test_cancel(self):
self.assertTrue(self.workflow_run.cancel())
def test_delete(self):
wr = self.repo.get_workflow_run(1327550476)
self.assertTrue(wr.delete())