Skip to content

Commit 79898ef

Browse files
committed
add automated check for CHANGELOG integrity
1 parent 89a9868 commit 79898ef

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ jobs:
1919
enable-cache: true
2020
- name: Check lockfile is consistent with pyproject.toml
2121
run: uv lock --check
22+
check-changelog-history-untouched:
23+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'changelog-history-fix') or !startsWith(github.event.pull_request.title, 'release:') }}
24+
steps:
25+
- uses: actions/checkout@v6
26+
- name: Check if changes are limited to upcoming changes
27+
run: |
28+
upcoming_changes_start=$(git diff -W CHANGELOG.md | grep "^ ## Upcoming Changes" -n | cut -d: -f1)
29+
releases_start=$(git diff -W CHANGELOG.md | grep "^ ## " -n | tail -n +2 | head -n 1 | cut -d: -f1) # +2 to skip first line
30+
echo "All changes should be between $upcoming_changes_start and $releases_start"
31+
32+
# +6 to skip diff header
33+
git diff -W CHANGELOG.md | grep "^[^ ]" -n | tail -n +6 | cut -d: -f1 \
34+
| while read -r changed_line_nr; do
35+
echo -n "Checking line $changed_line_nr...";
36+
if [ $upcoming_changes_start -lt $changed_line_nr ] && [ $changed_line_nr -lt $releases_start ]; then
37+
echo "...valid";
38+
else
39+
echo "...invalid";
40+
echo "Detected illegal changes"
41+
exit 1
42+
fi
43+
done
2244
test:
2345
uses: ./.github/workflows/testing.yml
2446
build-docs:

0 commit comments

Comments
 (0)