Skip to content

Commit

Permalink
[WorkflowRun] - Add missing attributes (run_started_at & `run_attem…
Browse files Browse the repository at this point in the history
…pt`), remove deprecated `unicode` type (#2273)
  • Loading branch information
goliaro committed Oct 29, 2022
1 parent 0fadd6b commit 3a6235b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
27 changes: 27 additions & 0 deletions github/WorkflowRun.py
Expand Up @@ -60,6 +60,14 @@ def head_sha(self):
self._completeIfNotSet(self._head_sha)
return self._head_sha.value

@property
def run_attempt(self):
"""
:type: integer
"""
self._completeIfNotSet(self._run_attempt)
return self._run_attempt.value

@property
def run_number(self):
"""
Expand All @@ -76,6 +84,14 @@ def event(self):
self._completeIfNotSet(self._event)
return self._event.value

@property
def run_started_at(self):
"""
:type: datetime.datetime
"""
self._completeIfNotSet(self._run_started_at)
return self._run_started_at.value

@property
def status(self):
"""
Expand Down Expand Up @@ -266,8 +282,10 @@ def _initAttributes(self):
self._id = github.GithubObject.NotSet
self._head_branch = github.GithubObject.NotSet
self._head_sha = github.GithubObject.NotSet
self._run_attempt = github.GithubObject.NotSet
self._run_number = github.GithubObject.NotSet
self._event = github.GithubObject.NotSet
self._run_started_at = github.GithubObject.NotSet
self._status = github.GithubObject.NotSet
self._conclusion = github.GithubObject.NotSet
self._workflow_id = github.GithubObject.NotSet
Expand All @@ -294,10 +312,19 @@ def _useAttributes(self, attributes):
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 "run_attempt" in attributes: # pragma no branch
self._run_attempt = self._makeIntAttribute(attributes["run_attempt"])
if "run_number" in attributes: # pragma no branch
self._run_number = self._makeIntAttribute(attributes["run_number"])
if "event" in attributes: # pragma no branch
self._event = self._makeStringAttribute(attributes["event"])
if "run_started_at" in attributes: # pragma no branch
assert attributes["run_started_at"] is None or isinstance(
attributes["run_started_at"], str
), attributes["run_started_at"]
self._run_started_at = self._makeDatetimeAttribute(
attributes["run_started_at"]
)
if "status" in attributes: # pragma no branch
self._status = self._makeStringAttribute(attributes["status"])
if "conclusion" in attributes: # pragma no branch
Expand Down
2 changes: 1 addition & 1 deletion scripts/add_attribute.py
Expand Up @@ -55,7 +55,7 @@
),
"datetime": (
"datetime.datetime",
"(str, unicode)",
"str",
'self._makeDatetimeAttribute(attributes["' + attributeName + '"])',
),
"class": (
Expand Down
4 changes: 2 additions & 2 deletions tests/ReplayData/ExposeAllAttributes.testAllClasses.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/ReplayData/PullRequest.testGetFiles.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/ReplayData/PullRequestFile.setUp.txt

Large diffs are not rendered by default.

0 comments on commit 3a6235b

Please sign in to comment.