mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Add name, display_title and path attributes to WorkflowRun (#2397)
This commit is contained in:
@@ -44,6 +44,14 @@ class WorkflowRun(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._id)
|
||||
return self._id.value
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._name)
|
||||
return self._name.value
|
||||
|
||||
@property
|
||||
def head_branch(self):
|
||||
"""
|
||||
@@ -60,6 +68,22 @@ class WorkflowRun(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._head_sha)
|
||||
return self._head_sha.value
|
||||
|
||||
@property
|
||||
def display_title(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._display_title)
|
||||
return self._display_title.value
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._path)
|
||||
return self._path.value
|
||||
|
||||
@property
|
||||
def run_attempt(self):
|
||||
"""
|
||||
@@ -280,8 +304,11 @@ class WorkflowRun(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
def _initAttributes(self):
|
||||
self._id = github.GithubObject.NotSet
|
||||
self._name = github.GithubObject.NotSet
|
||||
self._head_branch = github.GithubObject.NotSet
|
||||
self._head_sha = github.GithubObject.NotSet
|
||||
self._display_title = github.GithubObject.NotSet
|
||||
self._path = github.GithubObject.NotSet
|
||||
self._run_attempt = github.GithubObject.NotSet
|
||||
self._run_number = github.GithubObject.NotSet
|
||||
self._event = github.GithubObject.NotSet
|
||||
@@ -308,10 +335,16 @@ class WorkflowRun(github.GithubObject.CompletableGithubObject):
|
||||
def _useAttributes(self, attributes):
|
||||
if "id" in attributes: # pragma no branch
|
||||
self._id = self._makeIntAttribute(attributes["id"])
|
||||
if "name" in attributes: # pragma no branch
|
||||
self._name = self._makeStringAttribute(attributes["name"])
|
||||
if "head_branch" in attributes: # pragma no branch
|
||||
self._head_branch = self._makeStringAttribute(attributes["head_branch"])
|
||||
if "head_sha" in attributes: # pragma no branch
|
||||
self._head_sha = self._makeStringAttribute(attributes["head_sha"])
|
||||
if "display_title" in attributes: # pragma no branch
|
||||
self._display_title = self._makeStringAttribute(attributes["display_title"])
|
||||
if "path" in attributes: # pragma no branch
|
||||
self._path = self._makeStringAttribute(attributes["path"])
|
||||
if "run_attempt" in attributes: # pragma no branch
|
||||
self._run_attempt = self._makeIntAttribute(attributes["run_attempt"])
|
||||
if "run_number" in attributes: # pragma no branch
|
||||
|
||||
@@ -17,12 +17,22 @@ class WorkflowRun(CompletableGithubObject):
|
||||
@property
|
||||
def id(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def head_branch(self) -> str: ...
|
||||
@property
|
||||
def head_sha(self) -> str: ...
|
||||
@property
|
||||
def path(self) -> str: ...
|
||||
@property
|
||||
def display_title(self) -> str: ...
|
||||
@property
|
||||
def run_number(self) -> int: ...
|
||||
@property
|
||||
def run_attempt(self) -> int: ...
|
||||
@property
|
||||
def run_started_at(self) -> str: ...
|
||||
@property
|
||||
def event(self) -> str: ...
|
||||
@property
|
||||
def status(self) -> str: ...
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -2,10 +2,10 @@ https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/PyGithub/PyGithub/actions/runs/148274629/timing
|
||||
/repos/PyGithub/PyGithub/actions/runs/3881497935/timing
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('Date', 'Fri, 26 Jun 2020 05:25:09 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Server', 'GitHub.com'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4935'), ('X-RateLimit-Reset', '1593150231'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding'), ('ETag', 'W/"d5c60782b947caaf365ec6da07f69a32"'), ('X-OAuth-Scopes', 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', '9F74:5067:1B8264:1FF1A4:5EF586B5')]
|
||||
{"billable":{},"run_duration_ms":105000}
|
||||
[('Server', 'GitHub.com'), ('Date', 'Fri, 13 Jan 2023 13:19:58 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'public, max-age=60, s-maxage=60'), ('Vary', 'Accept, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"8ec19a979b8290796ff8c533ce429b277e20807aa5b771b658a04c6375422fb3"'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('x-github-api-version-selected', '2022-11-28'), ('X-RateLimit-Limit', '60'), ('X-RateLimit-Remaining', '18'), ('X-RateLimit-Reset', '1673619381'), ('X-RateLimit-Used', '42'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'CBC6:0299:F963:14A67:63C15A7D')]
|
||||
{"billable":{"UBUNTU":{"total_ms":0,"jobs":5,"job_runs":[{"job_id":10545727758,"duration_ms":0},{"job_id":10545727888,"duration_ms":0},{"job_id":10545728039,"duration_ms":0},{"job_id":10545728190,"duration_ms":0},{"job_id":10545728356,"duration_ms":0}]}},"run_duration_ms":241000}
|
||||
|
||||
|
||||
+53
-27
@@ -29,83 +29,109 @@ class WorkflowRun(Framework.TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.repo = self.g.get_repo("PyGithub/PyGithub")
|
||||
self.workflow_run = self.repo.get_workflow_run(148274629)
|
||||
self.workflow_run = self.repo.get_workflow_run(3881497935)
|
||||
|
||||
def testAttributes(self):
|
||||
self.assertEqual(
|
||||
repr(self.workflow_run),
|
||||
'WorkflowRun(url="https://api.github.com/repos/PyGithub/PyGithub/actions/runs/148274629", id=148274629)',
|
||||
'WorkflowRun(url="https://api.github.com/repos/PyGithub/PyGithub/actions/runs/3881497935", id=3881497935)',
|
||||
)
|
||||
self.assertEqual(self.workflow_run.id, 148274629)
|
||||
self.assertEqual(self.workflow_run.head_branch, "more-precise-typing")
|
||||
self.assertEqual(self.workflow_run.id, 3881497935)
|
||||
self.assertEqual(self.workflow_run.name, "CI")
|
||||
self.assertEqual(self.workflow_run.head_branch, "feat/workflow-run")
|
||||
self.assertEqual(
|
||||
self.workflow_run.head_sha, "f91c729d786efcc93db47dd755313a26172c105e"
|
||||
self.workflow_run.head_sha, "c6e5cac67a58a4eb11f1f28567a77a6e2cc8ee98"
|
||||
)
|
||||
self.assertEqual(self.workflow_run.path, ".github/workflows/ci.yml")
|
||||
self.assertEqual(self.workflow_run.display_title, "TEST PR")
|
||||
self.assertEqual(self.workflow_run.run_number, 930)
|
||||
self.assertEqual(self.workflow_run.run_attempt, 1)
|
||||
self.assertEqual(
|
||||
self.workflow_run.run_started_at, datetime.datetime(2023, 1, 10, 8, 24, 19)
|
||||
)
|
||||
self.assertEqual(self.workflow_run.run_number, 162)
|
||||
self.assertEqual(self.workflow_run.event, "pull_request")
|
||||
self.assertEqual(self.workflow_run.status, "completed")
|
||||
self.assertEqual(self.workflow_run.conclusion, "failure")
|
||||
self.assertEqual(self.workflow_run.workflow_id, 1026390)
|
||||
self.assertEqual(self.workflow_run.conclusion, "success")
|
||||
self.assertEqual(self.workflow_run.workflow_id, 1903133)
|
||||
self.assertEqual(
|
||||
self.workflow_run.url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/148274629",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/3881497935",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.html_url,
|
||||
"https://github.com/PyGithub/PyGithub/actions/runs/148274629",
|
||||
"https://github.com/PyGithub/PyGithub/actions/runs/3881497935",
|
||||
)
|
||||
self.assertEqual(self.workflow_run.pull_requests, [])
|
||||
created_at = datetime.datetime(2020, 6, 26, 4, 51, 26)
|
||||
created_at = datetime.datetime(2023, 1, 10, 8, 24, 19)
|
||||
self.assertEqual(self.workflow_run.created_at, created_at)
|
||||
updated_at = datetime.datetime(2020, 6, 26, 4, 52, 59)
|
||||
updated_at = datetime.datetime(2023, 1, 10, 8, 28, 20)
|
||||
self.assertEqual(self.workflow_run.updated_at, updated_at)
|
||||
self.assertEqual(
|
||||
self.workflow_run.jobs_url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/148274629/jobs",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/3881497935/jobs",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.logs_url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/148274629/logs",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/3881497935/logs",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.check_suite_url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/check-suites/843925976",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/check-suites/10279069747",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.artifacts_url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/148274629/artifacts",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/3881497935/artifacts",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.cancel_url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/148274629/cancel",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/3881497935/cancel",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.rerun_url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/148274629/rerun",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/3881497935/rerun",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.workflow_url,
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1026390",
|
||||
"https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1903133",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.workflow_run.head_commit.message, "add attribute 'name' on WorkflowRun"
|
||||
)
|
||||
self.assertEqual(self.workflow_run.head_commit.message, "More precise typing")
|
||||
self.assertEqual(self.workflow_run.repository.name, "PyGithub")
|
||||
self.assertEqual(self.workflow_run.head_repository.name, "PyGithub")
|
||||
|
||||
def test_timing(self):
|
||||
timing = self.workflow_run.timing()
|
||||
self.assertEqual(timing.billable, {})
|
||||
self.assertEqual(timing.run_duration_ms, 105000)
|
||||
self.assertEqual(
|
||||
timing.billable,
|
||||
{
|
||||
"UBUNTU": {
|
||||
"job_runs": [
|
||||
{"duration_ms": 0, "job_id": 10545727758},
|
||||
{"duration_ms": 0, "job_id": 10545727888},
|
||||
{"duration_ms": 0, "job_id": 10545728039},
|
||||
{"duration_ms": 0, "job_id": 10545728190},
|
||||
{"duration_ms": 0, "job_id": 10545728356},
|
||||
],
|
||||
"jobs": 5,
|
||||
"total_ms": 0,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(timing.run_duration_ms, 241000)
|
||||
|
||||
def test_rerun(self):
|
||||
self.assertTrue(self.workflow_run.rerun())
|
||||
wr = self.repo.get_workflow_run(3910280793)
|
||||
self.assertFalse(wr.rerun())
|
||||
|
||||
def test_rerun_with_successful_run(self):
|
||||
wr = self.repo.get_workflow_run(145732882)
|
||||
wr = self.repo.get_workflow_run(3881497935)
|
||||
self.assertFalse(wr.rerun())
|
||||
|
||||
def test_cancel(self):
|
||||
self.assertTrue(self.workflow_run.cancel())
|
||||
wr = self.repo.get_workflow_run(3911660493)
|
||||
self.assertFalse(wr.cancel())
|
||||
|
||||
def test_delete(self):
|
||||
wr = self.repo.get_workflow_run(1327550476)
|
||||
self.assertTrue(wr.delete())
|
||||
wr = self.repo.get_workflow_run(3881497935)
|
||||
self.assertFalse(wr.delete())
|
||||
|
||||
Reference in New Issue
Block a user