-
Notifications
You must be signed in to change notification settings - Fork 8
77 lines (74 loc) · 3.17 KB
/
pr_checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: PR Checks
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
paths:
- 'pywhy_graphs/**'
jobs:
changelog:
name: CHANGELOG
runs-on: ubuntu-latest
# if: github.event_name == 'pull_request'
if: ${{ contains(github.event.pull_request.labels.*.name, 'No Changelog Needed') == 0 }}
steps:
- name: Get PR number and milestone
run: |
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "TAGGED_MILESTONE=${{ github.event.pull_request.milestone.title }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Check that CHANGELOG has been updated
run: |
# If this step fails, this means you haven't updated the CHANGELOG.md
# file with notes on your contribution.
# git diff --name-only $(git merge-base origin/main HEAD) | grep '^CHANGELOG.md$' && echo "Thanks for helping keep our CHANGELOG up-to-date!"
set -xe
changed_files=$(git diff --name-only origin/main)
# Changelog should be updated only if tests have been modified
if [[ ! "$changed_files" =~ tests ]]
then
exit 0
fi
all_changelogs=$(cat ./docs/whats_new/v*.rst)
if [[ "$all_changelogs" =~ :pr:\`$PR_NUMBER\` ]]
then
echo "Changelog has been updated."
# If the pull request is milestoned check the correspondent changelog
if exist -f ./docs/whats_new/v${TAGGED_MILESTONE:0:4}.rst
then
expected_changelog=$(cat ./docs/whats_new/v${TAGGED_MILESTONE:0:4}.rst)
if [[ "$expected_changelog" =~ :pr:\`$PR_NUMBER\` ]]
then
echo "Changelog and milestone correspond."
else
echo "Changelog and milestone do not correspond."
echo "If you see this error make sure that the tagged milestone for the PR"
echo "and the edited changelog filename properly match."
exit 1
fi
fi
else
echo "A Changelog entry is missing."
echo ""
echo "Please add an entry to the changelog at 'docs/whats_new/v*.rst'"
echo "to docsument your change assuming that the PR will be merged"
echo "in time for the next release of pywhy-graphs."
echo ""
echo "Look at other entries in that file for inspiration and please"
echo "reference this pull request using the ':pr:' directive and"
echo "credit yourself (and other contributors if applicable) with"
echo "the ':user:' directive."
echo ""
echo "If you see this error and there is already a changelog entry,"
echo "check that the PR number is correct."
echo ""
echo "If you believe that this PR does not warrant a changelog"
echo "entry, say so in a comment so that a maintainer will label"
echo "the PR with 'No Changelog Needed' to bypass this check."
exit 1
fi