Skip to content

Commit 23b2bdc

Browse files
tests for gh event path
1 parent 25cce0e commit 23b2bdc

File tree

2 files changed

+531
-11
lines changed

2 files changed

+531
-11
lines changed

codeflash/code_utils/env_utils.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,5 @@ def is_LSP_enabled() -> bool:
127127

128128
def is_pr_draft() -> bool:
129129
"""Check if the PR is draft. in the github action context."""
130-
try:
131-
event_path = os.getenv("GITHUB_EVENT_PATH")
132-
pr_number = get_pr_number()
133-
if pr_number is not None and event_path:
134-
with Path(event_path).open() as f:
135-
event_data = json.load(f)
136-
return bool(event_data["pull_request"]["draft"])
137-
return False # noqa
138-
except Exception as e:
139-
logger.warning(f"Error checking if PR is draft: {e}")
140-
return False
130+
event = get_cached_gh_event_data()
131+
return bool(event.get("pull_request", {}).get("draft", False))

0 commit comments

Comments
 (0)