-
Notifications
You must be signed in to change notification settings - Fork 882
81 lines (76 loc) · 3.07 KB
/
changelog-check.yaml
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
78
79
80
81
name: Check for changelog entry file
"on":
pull_request:
types: [opened, synchronize, reopened, edited]
branches:
- main
jobs:
# Check if the PR creates a separate file with changelog entry in the
# ".unreleased" folder
#
# This check can be disabled by adding the following line in the PR text
#
# Disable-check: force-changelog-file
#
# The file having the changelog entry is expected to have lines in the
# following format
#
# Fixes: #NNNN <bug description> (mandatory in case of bugfixes)
# Thanks: @name <thank you note> (optional)
# Implements: #NNNN <feature description> (mandatory in case of new features)
check_changelog_file:
name: Check for file with CHANGELOG entry
runs-on: ubuntu-latest
steps:
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install pip
- name: Install Python Dependencies
run: |
pip install PyGithub
- name: Checkout source
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Check if the pull request adds file in ".unreleased" folder
shell: bash --norc --noprofile {0}
env:
BODY: ${{ github.event.pull_request.body }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
folder=".unreleased"
# Get the list of modified files in this pull request
files=$(git --no-pager diff --diff-filter=ACMR --name-only $(git merge-base HEAD ${{ github.event.pull_request.base.sha }}) HEAD ':!.unreleased/*.j2')
if echo "$BODY" | egrep -qsi "Disable-check:[[:space:]]*force-changelog-file"; then
# skip changelog checks if forced
exit 0
else
# if no changelog files found, and the PR does not have the force disable check option
if ! echo "${files}" | grep -Eq "^(${folder})/.+$"; then
echo "PR does not add a change log file in .unreleased/ folder"
echo "Check .unreleased/template.rfc822 for the format of the change log file."
echo
echo "To disable changelog updated check, add this trailer to pull request message:"
echo
echo "Disable-check: force-changelog-file"
echo
echo "Trailers follow RFC2822 conventions, so no whitespace"
echo "before field name and the check is case-insensitive for"
echo "both the field name and the field body."
exit 1
else
# check the format of the files in .unreleased folder
for file in $files; do
if echo "${file}" | grep -Eq "^(${folder})/.+$"; then
if ! python scripts/check_changelog_format.py "$file"; then
echo "Not valid CHANGELOG entries in $file."
exit 1
fi
fi
done
exit 0
fi
fi