Skip to content

Automatically Create Changelog Entry for PRs #313

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

Merged
merged 11 commits into from
Aug 5, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 5, 2025

This PR refactors the changelog automation system to use a cleaner subcommand structure and adds comprehensive test coverage as requested in the feedback.

Key Changes

Renamed and Restructured Script

  • Renamed increment_version.py to modify_changelog.py for better clarity
  • Replaced flag-based interface with subcommands:
    • python modify_changelog.py bump_version <major|minor|patch> for version bumps
    • python modify_changelog.py update_changelog <number> <title> for PR entries
  • Consolidated all logic into the main() function, removing backward compatibility code

Updated GitHub Workflows

  • Modified .github/workflows/update-changelog.yml to use new subcommand format
  • Updated .github/workflows/version.yml to use new script name and format
  • Maintains all existing functionality while using cleaner command structure

Enhanced Changelog Update Functionality

  • Modified changelog update logic to support updating existing entries instead of failing on duplicates
  • When a PR title changes, the existing changelog entry is updated rather than creating a duplicate
  • This allows users to modify their PR titles and have the changelog automatically reflect the changes

Comprehensive Test Suite

  • Added python/tests/test_modify_changelog.py with full test coverage
  • Combined version bump tests into a single parameterized test using pytest.param for better maintainability
  • Tests both version bumping and changelog updating functionality
  • Includes error handling scenarios (missing files, duplicates, invalid inputs)
  • Tests custom changelog path support and help command validation
  • Verifies that PR title changes update existing entries correctly

Benefits

  • Cleaner Interface: Subcommands provide better organization than flags
  • Better Maintainability: All logic consolidated in main() function with parameterized tests
  • Test Coverage: Comprehensive tests ensure reliability and catch regressions
  • Improved Error Handling: Better validation and user-friendly error messages
  • Smart Update Logic: Handles PR title changes gracefully by updating existing entries

The refactored system maintains all existing functionality while providing a more intuitive command structure, robust test coverage, and intelligent handling of changelog entry updates.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@saulshanabrook
Copy link
Member

@copilot Can you update the increment_version.py script to handle this case? Since it already has logic for parsing and updating the changelog. It's used in the bump job of the version.yml github actions files.

Copilot AI and others added 3 commits August 5, 2025 18:49
Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Automatically Generate Changelog Entries for PRs Automatically Generate Changelog Entries for PRs Aug 5, 2025
Copilot finished work on behalf of saulshanabrook August 5, 2025 18:53
@Copilot Copilot AI requested a review from saulshanabrook August 5, 2025 18:53
Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 5, 2025

@copilot Can you update the increment_version.py script to handle this case? Since it already has logic for parsing and updating the changelog. It's used in the bump job of the version.yml githu...

I've updated the increment_version.py script to handle changelog PR entries as requested. The script now supports both its original version bump functionality and the new PR entry feature using the same changelog parsing logic.

Changes made:

  • Added --add-pr flag with --pr-number, --pr-title, and --pr-url arguments
  • Integrated the changelog PR functionality while maintaining full backward compatibility
  • Updated the GitHub workflow to use increment_version.py --add-pr instead of the separate script
  • Removed duplicate scripts and centralized all changelog logic in one place

The script maintains backward compatibility - python increment_version.py patch still works exactly as before for the version bump workflow, while python increment_version.py --add-pr --pr-number=123 --pr-title="Fix" --pr-url="..." handles PR entries.

Commit: d874184

@Copilot Copilot AI requested a review from saulshanabrook August 5, 2025 19:01
Copilot finished work on behalf of saulshanabrook August 5, 2025 19:01
Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
Copilot finished work on behalf of saulshanabrook August 5, 2025 19:06
@Copilot Copilot AI requested a review from saulshanabrook August 5, 2025 19:06
… and tests

- Renamed increment_version.py to modify_changelog.py
- Consolidated backward compatibility logic into main()
- Added subcommands: bump_version and update_changelog
- Updated GitHub workflows to use new command format
- Added comprehensive tests for both functionalities
- Improved argument parsing and error handling

Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
@Copilot Copilot AI changed the title Automatically Generate Changelog Entries for PRs Refactor Changelog Automation to Use Subcommands and Add Comprehensive Tests Aug 5, 2025
Copilot finished work on behalf of saulshanabrook August 5, 2025 19:14
Copy link

codspeed-hq bot commented Aug 5, 2025

CodSpeed WallTime Performance Report

Merging #313 will not alter performance

Comparing copilot/fix-312 (55c4fe9) with main (5aa044f)1

Summary

✅ 7 untouched benchmarks

Footnotes

  1. No successful run was found on main (55c4fe9) during the generation of this report, so 5aa044f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link

codspeed-hq bot commented Aug 5, 2025

CodSpeed Instrumentation Performance Report

Merging #313 will not alter performance

Comparing copilot/fix-312 (55c4fe9) with main (5aa044f)1

Summary

✅ 7 untouched benchmarks

Footnotes

  1. No successful run was found on main (55c4fe9) during the generation of this report, so 5aa044f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Comment on lines 87 to 129
def test_bump_version_minor():
"""Test version bumping with minor increment."""
with tempfile.TemporaryDirectory() as temp_dir:
temp_path = Path(temp_dir)

# Create mock Cargo.toml
cargo_content = '''[package]
name = "test-package"
version = "1.2.3"
edition = "2021"
'''
cargo_path = temp_path / "Cargo.toml"
cargo_path.write_text(cargo_content)

# Create mock changelog
changelog_content = '''# Changelog

## UNRELEASED

## 1.2.3 (2024-01-01)

- Some old change
'''
docs_dir = temp_path / "docs"
docs_dir.mkdir()
changelog_path = docs_dir / "changelog.md"
changelog_path.write_text(changelog_content)

# Run the script
result = subprocess.run([sys.executable,
str(Path(__file__).parent.parent.parent / "modify_changelog.py"),
"bump_version", "minor"],
capture_output=True, text=True, cwd=temp_path)

assert result.returncode == 0
assert result.stdout.strip() == "1.3.0"

# Check Cargo.toml was updated
updated_cargo = cargo_path.read_text()
assert 'version = "1.3.0"' in updated_cargo


def test_bump_version_major():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you combine these to one test using pytest.param to pass in the start version, end version, and bump type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined the three version bump tests into one parameterized test using pytest.param as requested. The test now takes start_version, bump_type, and expected_version parameters, making it more concise and maintainable. Commit: 996332b

Comment on lines 212 to 231
## UNRELEASED

- Fix important bug [#123](https://github.com/egraphs-good/egglog-python/pull/123)

## 1.2.3 (2024-01-01)

- Some old change
'''
docs_dir = temp_path / "docs"
docs_dir.mkdir()
changelog_path = docs_dir / "changelog.md"
changelog_path.write_text(changelog_content)

# Run the script
result = subprocess.run([sys.executable,
str(Path(__file__).parent.parent.parent / "modify_changelog.py"),
"update_changelog", "123", "Fix important bug"],
capture_output=True, text=True, cwd=temp_path)

assert result.returncode == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this test change the title for this issue and verify that it modifies the existing changelog entry added for it instead of making a new one? So that if a user modifies their PR title, the entry will be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test to verify that changing a PR title modifies the existing changelog entry instead of creating a duplicate. The script now supports updating existing entries when PR titles change, ensuring users can modify their PR titles and have the changelog automatically updated. Commit: 996332b

… update functionality

Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
@Copilot Copilot AI requested a review from saulshanabrook August 5, 2025 19:32
Copilot finished work on behalf of saulshanabrook August 5, 2025 19:32
@saulshanabrook saulshanabrook changed the title Refactor Changelog Automation to Use Subcommands and Add Comprehensive Tests Automatically Create Changelog Entry for PRs Aug 5, 2025
@saulshanabrook saulshanabrook marked this pull request as ready for review August 5, 2025 19:35
@saulshanabrook saulshanabrook merged commit bf04275 into main Aug 5, 2025
8 of 10 checks passed
@saulshanabrook saulshanabrook deleted the copilot/fix-312 branch August 5, 2025 19:36
Copy link
Contributor Author

Copilot AI commented Aug 5, 2025

@copilot Can you update the increment_version.py script to handle this case? Since it already has logic for parsing and updating the changelog. It's used in the bump job of the version.yml githu...

The comment appears to be incomplete - it says "Can you update the " but doesn't specify what needs to be updated. Could you please clarify what you'd like me to update?

@Copilot Copilot AI requested a review from saulshanabrook August 5, 2025 19:38
Copilot finished work on behalf of saulshanabrook August 5, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants