Skip to content

Commit b565a52

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

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)