Skip to content

Commit c771348

Browse files
Remove tests and update workflow to trigger only on comment with '@actions-user changelog'
Co-authored-by: saulshanabrook <[email protected]>
1 parent b825604 commit c771348

File tree

2 files changed

+23
-108
lines changed

2 files changed

+23
-108
lines changed

.github/workflows/update-changelog.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
name: Update Changelog
22

33
on:
4-
pull_request:
5-
types: [opened, edited]
4+
issue_comment:
5+
types: [created]
66

77
jobs:
88
update-changelog:
9-
# Only run if this is not a PR from a fork to avoid permission issues
10-
# and not a commit made by GitHub Action to avoid infinite loops
11-
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'github-actions[bot]'
9+
# Only run if this is a comment on a PR containing "@actions-user changelog"
10+
# and not a comment made by GitHub Action to avoid infinite loops
11+
if: github.event.issue.pull_request && contains(github.event.comment.body, '@actions-user changelog') && github.actor != 'github-actions[bot]'
1212
runs-on: ubuntu-latest
1313
permissions:
1414
contents: write
1515
pull-requests: write
1616

1717
steps:
18+
- name: Get PR details
19+
id: pr-details
20+
uses: actions/github-script@v7
21+
with:
22+
script: |
23+
const { data: pullRequest } = await github.rest.pulls.get({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
pull_number: context.issue.number
27+
});
28+
core.setOutput('number', pullRequest.number);
29+
core.setOutput('title', pullRequest.title);
30+
core.setOutput('head_ref', pullRequest.head.ref);
31+
1832
- name: Checkout repository
1933
uses: actions/checkout@v4
2034
with:
2135
# Checkout the PR head ref
22-
ref: ${{ github.event.pull_request.head.ref }}
36+
ref: ${{ steps.pr-details.outputs.head_ref }}
2337
token: ${{ secrets.GITHUB_TOKEN }}
2438

2539
- name: Set up Python
@@ -30,8 +44,8 @@ jobs:
3044
- name: Update changelog
3145
run: |
3246
python modify_changelog.py update_changelog \
33-
"${{ github.event.pull_request.number }}" \
34-
'${{ github.event.pull_request.title }}'
47+
"${{ steps.pr-details.outputs.number }}" \
48+
'${{ steps.pr-details.outputs.title }}'
3549
3650
- name: Check for changes
3751
id: changes
@@ -48,5 +62,5 @@ jobs:
4862
git config --local user.email "[email protected]"
4963
git config --local user.name "GitHub Action"
5064
git add docs/changelog.md
51-
git commit -m "Add changelog entry for PR #${{ github.event.pull_request.number }}"
65+
git commit -m "Add changelog entry for PR #${{ steps.pr-details.outputs.number }}"
5266
git push

python/tests/test_modify_changelog.py

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -295,102 +295,3 @@ def test_custom_changelog_path():
295295
# Check changelog was updated
296296
updated_changelog = custom_changelog_path.read_text()
297297
assert "- Add new feature [#456](https://github.com/egraphs-good/egglog-python/pull/456)" in updated_changelog
298-
299-
300-
def test_update_changelog_with_markdown_backticks():
301-
"""Test that PR titles with markdown backticks are preserved correctly."""
302-
with tempfile.TemporaryDirectory() as temp_dir:
303-
temp_path = Path(temp_dir)
304-
305-
# Create mock changelog
306-
changelog_content = """# Changelog
307-
308-
## UNRELEASED
309-
310-
## 1.2.3 (2024-01-01)
311-
312-
- Some old change
313-
"""
314-
docs_dir = temp_path / "docs"
315-
docs_dir.mkdir()
316-
changelog_path = docs_dir / "changelog.md"
317-
changelog_path.write_text(changelog_content)
318-
319-
# Test with title containing markdown backticks
320-
pr_title_with_backticks = "Support methods like `__array_function__` on expressions"
321-
322-
# Run the script
323-
result = subprocess.run(
324-
[
325-
sys.executable,
326-
str(Path(__file__).parent.parent.parent / "modify_changelog.py"),
327-
"update_changelog",
328-
"315",
329-
pr_title_with_backticks,
330-
],
331-
capture_output=True,
332-
text=True,
333-
cwd=temp_path,
334-
check=False,
335-
)
336-
337-
assert result.returncode == 0
338-
assert f"Added changelog entry for PR #315: {pr_title_with_backticks}" in result.stdout
339-
340-
# Check that backticks are preserved in the changelog
341-
updated_changelog = changelog_path.read_text()
342-
expected_entry = f"- {pr_title_with_backticks} [#315](https://github.com/egraphs-good/egglog-python/pull/315)"
343-
assert expected_entry in updated_changelog
344-
345-
# Specifically check that the backticks around __array_function__ are preserved
346-
assert "`__array_function__`" in updated_changelog
347-
348-
349-
def test_update_changelog_multiple_backticks():
350-
"""Test that PR titles with multiple markdown elements are preserved correctly."""
351-
with tempfile.TemporaryDirectory() as temp_dir:
352-
temp_path = Path(temp_dir)
353-
354-
# Create mock changelog
355-
changelog_content = """# Changelog
356-
357-
## UNRELEASED
358-
359-
## 1.2.3 (2024-01-01)
360-
361-
- Some old change
362-
"""
363-
docs_dir = temp_path / "docs"
364-
docs_dir.mkdir()
365-
changelog_path = docs_dir / "changelog.md"
366-
changelog_path.write_text(changelog_content)
367-
368-
# Test with title containing multiple markdown elements
369-
pr_title_complex = "Fix `__getattr__` and add support for `__setitem__` methods"
370-
371-
# Run the script
372-
result = subprocess.run(
373-
[
374-
sys.executable,
375-
str(Path(__file__).parent.parent.parent / "modify_changelog.py"),
376-
"update_changelog",
377-
"999",
378-
pr_title_complex,
379-
],
380-
capture_output=True,
381-
text=True,
382-
cwd=temp_path,
383-
check=False,
384-
)
385-
386-
assert result.returncode == 0
387-
assert f"Added changelog entry for PR #999: {pr_title_complex}" in result.stdout
388-
389-
# Check that all backticks are preserved in the changelog
390-
updated_changelog = changelog_path.read_text()
391-
expected_entry = f"- {pr_title_complex} [#999](https://github.com/egraphs-good/egglog-python/pull/999)"
392-
assert expected_entry in updated_changelog
393-
394-
# Specifically check that both sets of backticks are preserved
395-
assert "`__getattr__`" in updated_changelog
396-
assert "`__setitem__`" in updated_changelog

0 commit comments

Comments
 (0)