@@ -4,65 +4,30 @@ name: Check Changelog
4
4
# To bypass this check, label the PR with "No Changelog Needed".
5
5
on :
6
6
pull_request :
7
- types : [opened, edited , labeled, unlabeled, synchronize ]
7
+ types : [opened, synchronize , labeled, unlabeled]
8
8
9
9
jobs :
10
10
check :
11
11
name : A reviewer will let you know if it is required or can be bypassed
12
12
runs-on : ubuntu-latest
13
- if : ${{ contains(github.event.pull_request.labels.*.name, 'No Changelog Needed') == 0 }}
14
13
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
19
14
- uses : actions/checkout@v4
20
15
with :
21
16
fetch-depth : ' 0'
22
- - name : Check the changelog entry
17
+ - name : Check if tests have changed
18
+ id : tests_changed
23
19
run : |
24
20
set -xe
25
21
changed_files=$(git diff --name-only origin/main)
26
22
# 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 ]]
33
24
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
68
26
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
0 commit comments