|
1 | 1 | name: Check Changelog
|
| 2 | +permissions: |
| 3 | + contents: read |
| 4 | + |
2 | 5 | # This check makes sure that the changelog is properly updated
|
3 | 6 | # when a PR introduces a change in a test file.
|
4 | 7 | # To bypass this check, label the PR with "No Changelog Needed".
|
5 | 8 | on:
|
6 | 9 | pull_request:
|
7 |
| - types: [opened, edited, labeled, unlabeled, synchronize] |
| 10 | + types: [opened, synchronize, labeled, unlabeled] |
8 | 11 |
|
9 | 12 | jobs:
|
10 | 13 | check:
|
11 | 14 | name: A reviewer will let you know if it is required or can be bypassed
|
12 | 15 | runs-on: ubuntu-latest
|
13 |
| - if: ${{ contains(github.event.pull_request.labels.*.name, 'No Changelog Needed') == 0 }} |
14 | 16 | 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 | 17 | - uses: actions/checkout@v4
|
20 | 18 | with:
|
21 | 19 | fetch-depth: '0'
|
22 |
| - - name: Check the changelog entry |
| 20 | + - name: Check if tests have changed |
| 21 | + id: tests_changed |
23 | 22 | run: |
|
24 | 23 | set -xe
|
25 | 24 | changed_files=$(git diff --name-only origin/main)
|
26 | 25 | # Changelog should be updated only if tests have been modified
|
27 |
| - if [[ ! "$changed_files" =~ tests ]] |
| 26 | + if [[ "$changed_files" =~ tests ]] |
28 | 27 | 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 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 |
| 28 | + echo "check_changelog=true" >> $GITHUB_OUTPUT |
68 | 29 | fi
|
| 30 | +
|
| 31 | + - name: Check changelog entry |
| 32 | + if: steps.tests_changed.outputs.check_changelog == 'true' |
| 33 | + uses: scientific-python/action-towncrier-changelog@v1 |
| 34 | + env: |
| 35 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + BOT_USERNAME: changelog-bot |
0 commit comments