-
Notifications
You must be signed in to change notification settings - Fork 1.1k
93 lines (86 loc) · 3.59 KB
/
Copy pathchangelog-check.yaml
File metadata and controls
93 lines (86 loc) · 3.59 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
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: timescaledb-runner-arm64
steps:
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.13'
- name: Install Python Dependencies
run: |
pip install PyGithub
- name: Checkout source
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
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 }}
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
folder=".unreleased"
# Get the list of modified files as a bash array. Exclude the
# development-related files because they don't require a changelog.
mapfile -t modified_files < <(gh pr view "$PR_NUMBER" --json files --jq '
[.files.[].path | select(
(startswith(".github") or startswith("test")
or startswith("tsl/test") or startswith("scripts"))
| not)] | .[]')
echo "Modified files: ${modified_files[*]}"
# Get the changelog files as a bash array
mapfile -t changelog_files < <(gh pr view "$PR_NUMBER" --json files --jq "
[.files.[].path | select(startswith(\"${folder}\"))] | .[]")
echo "Changelog files: ${changelog_files[*]}"
if echo "$BODY" | grep -E -qsi "Disable-check:[[:space:]]*force-changelog-file"
then
# skip changelog checks if forced
:
elif (( ${#modified_files[@]} > 0 && ${#changelog_files[@]} == 0 ))
then
# if no changelog files found, and the PR does not have the force disable check option
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 "${changelog_files[@]}"
do
if ! scripts/check_changelog_format.py "${file}"
then
echo "Invalid CHANGELOG entries in ${file}."
exit 1
fi
done
fi