From 928174552739f91365858c27650cd7138908cf7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 Aug 2025 19:54:29 +0000 Subject: [PATCH 1/4] Initial plan From 3fff0c9c17fc0700b65e0f5b7f403a97f0fe4eec Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 5 Aug 2025 20:06:29 +0000 Subject: [PATCH 2/4] Add changelog entry for PR #317 --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index efbe4a11..2eab79f5 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,7 @@ _This project uses semantic versioning_ ## UNRELEASED +- [WIP] Fix automatic generic of changelog entries with markdown [#317](https://github.com/egraphs-good/egglog-python/pull/317) - Automatically Create Changelog Entry for PRs [#313](https://github.com/egraphs-good/egglog-python/pull/313) - Upgrade egglog which includes new backend. - Fixes implementation of the Python Object sort to work with objects with dupliating hashes but the same value. From b8256046ebb79f6409f08197c703f17c0c239ea5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 Aug 2025 20:07:36 +0000 Subject: [PATCH 3/4] Fix automatic generation of changelog entries with markdown backticks Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com> --- .github/workflows/update-changelog.yml | 2 +- python/tests/test_modify_changelog.py | 99 ++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml index b13e32cf..7dc5f922 100644 --- a/.github/workflows/update-changelog.yml +++ b/.github/workflows/update-changelog.yml @@ -31,7 +31,7 @@ jobs: run: | python modify_changelog.py update_changelog \ "${{ github.event.pull_request.number }}" \ - "${{ github.event.pull_request.title }}" + '${{ github.event.pull_request.title }}' - name: Check for changes id: changes diff --git a/python/tests/test_modify_changelog.py b/python/tests/test_modify_changelog.py index 7682e829..7370cc83 100644 --- a/python/tests/test_modify_changelog.py +++ b/python/tests/test_modify_changelog.py @@ -295,3 +295,102 @@ def test_custom_changelog_path(): # Check changelog was updated updated_changelog = custom_changelog_path.read_text() assert "- Add new feature [#456](https://github.com/egraphs-good/egglog-python/pull/456)" in updated_changelog + + +def test_update_changelog_with_markdown_backticks(): + """Test that PR titles with markdown backticks are preserved correctly.""" + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = Path(temp_dir) + + # 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) + + # Test with title containing markdown backticks + pr_title_with_backticks = "Support methods like `__array_function__` on expressions" + + # Run the script + result = subprocess.run( + [ + sys.executable, + str(Path(__file__).parent.parent.parent / "modify_changelog.py"), + "update_changelog", + "315", + pr_title_with_backticks, + ], + capture_output=True, + text=True, + cwd=temp_path, + check=False, + ) + + assert result.returncode == 0 + assert f"Added changelog entry for PR #315: {pr_title_with_backticks}" in result.stdout + + # Check that backticks are preserved in the changelog + updated_changelog = changelog_path.read_text() + expected_entry = f"- {pr_title_with_backticks} [#315](https://github.com/egraphs-good/egglog-python/pull/315)" + assert expected_entry in updated_changelog + + # Specifically check that the backticks around __array_function__ are preserved + assert "`__array_function__`" in updated_changelog + + +def test_update_changelog_multiple_backticks(): + """Test that PR titles with multiple markdown elements are preserved correctly.""" + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = Path(temp_dir) + + # 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) + + # Test with title containing multiple markdown elements + pr_title_complex = "Fix `__getattr__` and add support for `__setitem__` methods" + + # Run the script + result = subprocess.run( + [ + sys.executable, + str(Path(__file__).parent.parent.parent / "modify_changelog.py"), + "update_changelog", + "999", + pr_title_complex, + ], + capture_output=True, + text=True, + cwd=temp_path, + check=False, + ) + + assert result.returncode == 0 + assert f"Added changelog entry for PR #999: {pr_title_complex}" in result.stdout + + # Check that all backticks are preserved in the changelog + updated_changelog = changelog_path.read_text() + expected_entry = f"- {pr_title_complex} [#999](https://github.com/egraphs-good/egglog-python/pull/999)" + assert expected_entry in updated_changelog + + # Specifically check that both sets of backticks are preserved + assert "`__getattr__`" in updated_changelog + assert "`__setitem__`" in updated_changelog From c771348f9eec928eca1b6ddabab8483d785a018a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 13 Aug 2025 01:28:47 +0000 Subject: [PATCH 4/4] Remove tests and update workflow to trigger only on comment with '@actions-user changelog' Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com> --- .github/workflows/update-changelog.yml | 32 ++++++--- python/tests/test_modify_changelog.py | 99 -------------------------- 2 files changed, 23 insertions(+), 108 deletions(-) diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml index 7dc5f922..653893b3 100644 --- a/.github/workflows/update-changelog.yml +++ b/.github/workflows/update-changelog.yml @@ -1,25 +1,39 @@ name: Update Changelog on: - pull_request: - types: [opened, edited] + issue_comment: + types: [created] jobs: update-changelog: - # Only run if this is not a PR from a fork to avoid permission issues - # and not a commit made by GitHub Action to avoid infinite loops - if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'github-actions[bot]' + # Only run if this is a comment on a PR containing "@actions-user changelog" + # and not a comment made by GitHub Action to avoid infinite loops + if: github.event.issue.pull_request && contains(github.event.comment.body, '@actions-user changelog') && github.actor != 'github-actions[bot]' runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: + - name: Get PR details + id: pr-details + uses: actions/github-script@v7 + with: + script: | + const { data: pullRequest } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + core.setOutput('number', pullRequest.number); + core.setOutput('title', pullRequest.title); + core.setOutput('head_ref', pullRequest.head.ref); + - name: Checkout repository uses: actions/checkout@v4 with: # Checkout the PR head ref - ref: ${{ github.event.pull_request.head.ref }} + ref: ${{ steps.pr-details.outputs.head_ref }} token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python @@ -30,8 +44,8 @@ jobs: - name: Update changelog run: | python modify_changelog.py update_changelog \ - "${{ github.event.pull_request.number }}" \ - '${{ github.event.pull_request.title }}' + "${{ steps.pr-details.outputs.number }}" \ + '${{ steps.pr-details.outputs.title }}' - name: Check for changes id: changes @@ -48,5 +62,5 @@ jobs: git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add docs/changelog.md - git commit -m "Add changelog entry for PR #${{ github.event.pull_request.number }}" + git commit -m "Add changelog entry for PR #${{ steps.pr-details.outputs.number }}" git push \ No newline at end of file diff --git a/python/tests/test_modify_changelog.py b/python/tests/test_modify_changelog.py index 7370cc83..7682e829 100644 --- a/python/tests/test_modify_changelog.py +++ b/python/tests/test_modify_changelog.py @@ -295,102 +295,3 @@ def test_custom_changelog_path(): # Check changelog was updated updated_changelog = custom_changelog_path.read_text() assert "- Add new feature [#456](https://github.com/egraphs-good/egglog-python/pull/456)" in updated_changelog - - -def test_update_changelog_with_markdown_backticks(): - """Test that PR titles with markdown backticks are preserved correctly.""" - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - # 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) - - # Test with title containing markdown backticks - pr_title_with_backticks = "Support methods like `__array_function__` on expressions" - - # Run the script - result = subprocess.run( - [ - sys.executable, - str(Path(__file__).parent.parent.parent / "modify_changelog.py"), - "update_changelog", - "315", - pr_title_with_backticks, - ], - capture_output=True, - text=True, - cwd=temp_path, - check=False, - ) - - assert result.returncode == 0 - assert f"Added changelog entry for PR #315: {pr_title_with_backticks}" in result.stdout - - # Check that backticks are preserved in the changelog - updated_changelog = changelog_path.read_text() - expected_entry = f"- {pr_title_with_backticks} [#315](https://github.com/egraphs-good/egglog-python/pull/315)" - assert expected_entry in updated_changelog - - # Specifically check that the backticks around __array_function__ are preserved - assert "`__array_function__`" in updated_changelog - - -def test_update_changelog_multiple_backticks(): - """Test that PR titles with multiple markdown elements are preserved correctly.""" - with tempfile.TemporaryDirectory() as temp_dir: - temp_path = Path(temp_dir) - - # 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) - - # Test with title containing multiple markdown elements - pr_title_complex = "Fix `__getattr__` and add support for `__setitem__` methods" - - # Run the script - result = subprocess.run( - [ - sys.executable, - str(Path(__file__).parent.parent.parent / "modify_changelog.py"), - "update_changelog", - "999", - pr_title_complex, - ], - capture_output=True, - text=True, - cwd=temp_path, - check=False, - ) - - assert result.returncode == 0 - assert f"Added changelog entry for PR #999: {pr_title_complex}" in result.stdout - - # Check that all backticks are preserved in the changelog - updated_changelog = changelog_path.read_text() - expected_entry = f"- {pr_title_complex} [#999](https://github.com/egraphs-good/egglog-python/pull/999)" - assert expected_entry in updated_changelog - - # Specifically check that both sets of backticks are preserved - assert "`__getattr__`" in updated_changelog - assert "`__setitem__`" in updated_changelog