Skip to content

Commit 28108eb

Browse files
committed
add check changelog
1 parent b11eee1 commit 28108eb

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

.github/check-changelog.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Check Changelog
2+
# This check makes sure that the changelog is properly updated
3+
# when a PR introduces a change in a test file.
4+
# To bypass this check, label the PR with "No Changelog Needed".
5+
on:
6+
pull_request:
7+
types: [opened, edited, labeled, unlabeled, synchronize]
8+
9+
jobs:
10+
check:
11+
name: A reviewer will let you know if it is required or can be bypassed
12+
runs-on: ubuntu-latest
13+
if: ${{ contains(github.event.pull_request.labels.*.name, 'No Changelog Needed') == 0 }}
14+
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+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: '0'
22+
- name: Check the changelog entry
23+
run: |
24+
set -xe
25+
changed_files=$(git diff --name-only origin/main)
26+
# 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\` ]]
33+
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 imbalanced-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
68+
fi

0 commit comments

Comments
 (0)