Skip to content

Commit 219eedc

Browse files
authored
CI Update changelog check after move to towncrier (scikit-learn#30086)
1 parent 08961de commit 219eedc

File tree

2 files changed

+19
-47
lines changed

2 files changed

+19
-47
lines changed

.github/workflows/check-changelog.yml

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,30 @@ name: Check Changelog
44
# To bypass this check, label the PR with "No Changelog Needed".
55
on:
66
pull_request:
7-
types: [opened, edited, labeled, unlabeled, synchronize]
7+
types: [opened, synchronize, labeled, unlabeled]
88

99
jobs:
1010
check:
1111
name: A reviewer will let you know if it is required or can be bypassed
1212
runs-on: ubuntu-latest
13-
if: ${{ contains(github.event.pull_request.labels.*.name, 'No Changelog Needed') == 0 }}
1413
steps:
15-
- name: Get PR number and milestone
16-
run: |
17-
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
18-
echo "TAGGED_MILESTONE=${{ github.event.pull_request.milestone.title }}" >> $GITHUB_ENV
1914
- uses: actions/checkout@v4
2015
with:
2116
fetch-depth: '0'
22-
- name: Check the changelog entry
17+
- name: Check if tests have changed
18+
id: tests_changed
2319
run: |
2420
set -xe
2521
changed_files=$(git diff --name-only origin/main)
2622
# Changelog should be updated only if tests have been modified
27-
if [[ ! "$changed_files" =~ tests ]]
28-
then
29-
exit 0
30-
fi
31-
all_changelogs=$(cat ./doc/whats_new/v*.rst)
32-
if [[ "$all_changelogs" =~ :pr:\`$PR_NUMBER\` ]]
23+
if [[ "$changed_files" =~ tests ]]
3324
then
34-
echo "Changelog has been updated."
35-
# If the pull request is milestoned check the correspondent changelog
36-
if exist -f ./doc/whats_new/v${TAGGED_MILESTONE:0:4}.rst
37-
then
38-
expected_changelog=$(cat ./doc/whats_new/v${TAGGED_MILESTONE:0:4}.rst)
39-
if [[ "$expected_changelog" =~ :pr:\`$PR_NUMBER\` ]]
40-
then
41-
echo "Changelog and milestone correspond."
42-
else
43-
echo "Changelog and milestone do not correspond."
44-
echo "If you see this error make sure that the tagged milestone for the PR"
45-
echo "and the edited changelog filename properly match."
46-
exit 1
47-
fi
48-
fi
49-
else
50-
echo "A Changelog entry is missing."
51-
echo ""
52-
echo "Please add an entry to the changelog at 'doc/whats_new/v*.rst'"
53-
echo "to document your change assuming that the PR will be merged"
54-
echo "in time for the next release of scikit-learn."
55-
echo ""
56-
echo "Look at other entries in that file for inspiration and please"
57-
echo "reference this pull request using the ':pr:' directive and"
58-
echo "credit yourself (and other contributors if applicable) with"
59-
echo "the ':user:' directive."
60-
echo ""
61-
echo "If you see this error and there is already a changelog entry,"
62-
echo "check that the PR number is correct."
63-
echo ""
64-
echo "If you believe that this PR does not warrant a changelog"
65-
echo "entry, say so in a comment so that a maintainer will label"
66-
echo "the PR with 'No Changelog Needed' to bypass this check."
67-
exit 1
25+
echo "check_changelog=true" >> $GITHUB_OUTPUT
6826
fi
27+
28+
- name: Check changelog entry
29+
if: steps.tests_changed.outputs.check_changelog == 'true'
30+
uses: scientific-python/action-towncrier-changelog@v1
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
BOT_USERNAME: changelog-bot

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ package = "sklearn" # name of your package
253253
"spin.cmds.meson.docs"
254254
]
255255

256+
[tool.changelog-bot]
257+
[tool.changelog-bot.towncrier_changelog]
258+
enabled = true
259+
verify_pr_number = true
260+
changelog_noop_label = "No Changelog Needed"
261+
whatsnew_pattern = 'doc/whatsnew/upcoming_changes/[^/]+/\d+\.[^.]+\.rst'
262+
256263
[tool.towncrier]
257264
package = "sklearn"
258265
filename = "doc/whats_new/notes-towncrier.rst"

0 commit comments

Comments
 (0)