Skip to content

Commit 7aeb1cb

Browse files
committed
ci: Resolve an issue calculating workflow variables
PRs are now getting the following: Traceback (most recent call last): File "/home/runner/work/compiler-builtins/compiler-builtins/ci/ci-util.py", line 510, in <module> main() File "/home/runner/work/compiler-builtins/compiler-builtins/ci/ci-util.py", line 496, in main ctx.emit_workflow_output() File "/home/runner/work/compiler-builtins/compiler-builtins/ci/ci-util.py", line 294, in emit_workflow_output pr = PrInfo.from_env() ^^^^^^^^^^^^^^^^^ File "/home/runner/work/compiler-builtins/compiler-builtins/ci/ci-util.py", line 152, in from_env return cls.from_pr(pr_env) ^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/compiler-builtins/compiler-builtins/ci/ci-util.py", line 174, in from_pr return cls(**json.loads(pr_info), cfg=PrCfg(pr_json["body"])) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/work/compiler-builtins/compiler-builtins/ci/ci-util.py", line 134, in __init__ pprint.pp(self) File "/usr/lib/python3.12/pprint.py", line 66, in pp pprint(object, *args, sort_dicts=sort_dicts, **kwargs) ... AttributeError: 'PrCfg' object has no attribute 'extra_extensive'. Did you mean: 'skip_extensive'? Resolve this by using `__post_init__` rather than `__init__`.
1 parent 79d6b2a commit 7aeb1cb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ci/ci-util.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,21 @@ def eprint(*args, **kwargs):
7171
print(*args, file=sys.stderr, **kwargs)
7272

7373

74-
@dataclass(init=False)
74+
@dataclass(kw_only=True)
7575
class PrCfg:
7676
"""Directives that we allow in the commit body to control test behavior.
7777
7878
These are of the form `ci: foo`, at the start of a line.
7979
"""
8080

81+
# The PR body
82+
body: str
8183
# Skip regression checks (must be at the start of a line).
8284
allow_regressions: bool = False
8385
# Don't run extensive tests
8486
skip_extensive: bool = False
8587
# Add these extensive tests to the list
86-
extra_extensive: list[str] = field(default_factory=list)
88+
extra_extensive: list[str] = field(default_factory=list, init=False)
8789

8890
# Allow running a large number of extensive tests. If not set, this script
8991
# will error out if a threshold is exceeded in order to avoid accidentally
@@ -103,10 +105,10 @@ class PrCfg:
103105
DIR_TEST_LIBM: str = "test-libm"
104106
DIR_EXTRA_EXTENSIVE: str = "extra-extensive"
105107

106-
def __init__(self, body: str):
108+
def __post_init__(self):
107109
directives = re.finditer(
108110
r"^\s*ci:\s*(?P<dir_name>[^\s=]*)(?:\s*=\s*(?P<args>.*))?",
109-
body,
111+
self.body,
110112
re.MULTILINE,
111113
)
112114
for dir in directives:
@@ -171,7 +173,8 @@ def from_pr(cls, pr_number: int | str) -> Self:
171173
)
172174
pr_json = json.loads(pr_info)
173175
eprint("PR info:", json.dumps(pr_json, indent=4))
174-
return cls(**json.loads(pr_info), cfg=PrCfg(pr_json["body"]))
176+
print(f"JB: {pr_json["body"]}")
177+
return cls(**pr_json, cfg=PrCfg(body=pr_json["body"]))
175178

176179

177180
class FunctionDef(TypedDict):

0 commit comments

Comments
 (0)