-
Notifications
You must be signed in to change notification settings - Fork 101
refactor: improve release notes script and add unit tests #2870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add gh_api() helper function to consolidate GitHub API calls - Add list-prs command to list PRs with release notes as JSON - Add get-notes command to get formatted notes for a PR - Add pr_has_release_notes() function to check for checked notes - Refactor extract_notes_for_pr/commit to use gh_api helper - Wrap execution in if __name__ == "__main__" for module imports - Add release_notes_test.py with 20 unit tests - Rename workflow to release-notes.yml - Add release-notes-script-test job to run tests on script changes - Add isReleaseNotesScript detection to diffs action Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
wbbradley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. I left some nits.
| json_data = gh_api(f"/repos/MystenLabs/walrus/pulls/{pr}") | ||
| if not json_data: | ||
| return False | ||
| body = json_data.get("body", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| body = json_data.get("body", "") | |
| body = json_data.get("body") |
The default argument is not idiomatic in this setting. get will return None if there is no "body".
| # Execute the curl command | ||
| result = subprocess.run(curl_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||
| json_data = json.loads(result.stdout) | ||
| message = json_data[0].get("body") if json_data else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ternary operator is not doing anything anymore.
| message = json_data[0].get("body") if json_data else "" | |
| message = json_data[0].get("body") |
| result = subprocess.run(curl_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||
| json_data = json.loads(result.stdout) | ||
| pr = json_data[0].get("number") if json_data else "" | ||
| pr = json_data[0].get("number") if json_data else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pr = json_data[0].get("number") if json_data else None | |
| pr = json_data[0].get("number") |
Summary
gh_api()helper to consolidate GitHub API callslist-prsandget-notescommands for CI workflowsrelease-notes.ymland added automatic test execution when scripts changeBased on changes from MystenLabs/sui#24989
Test plan
python -m pytest release_notes_test.py -v)list-prsandget-notescommands work as expected🤖 Generated with Claude Code