Skip to content

Commit 42b298d

Browse files
committed
ci: validate changelog fragment filenames
Extend the existing fragment-existence check so it also rejects fragments whose basename doesn't match <PR_NUMBER>.<type> (where type is one of added, changed, deprecated, removed, fixed). This catches typos in the PR number or in the fragment type that would otherwise render a wrong PR link, or be silently dropped, in the rendered changelog. Also note in the do-not-edit comment of each towncrier-managed CHANGELOG.md (root and the 4 independent packages) that the existing static "## Unreleased" entries pre-date towncrier and must be folded into the first towncrier-built release manually — towncrier inserts new release blocks above that section without merging. Assisted-by: Claude Opus 4.7 (1M context)
1 parent a80c7da commit 42b298d

6 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/changelog.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ jobs:
4141
fi
4242
4343
- name: Check for changelog fragment
44+
env:
45+
PR_NUMBER: ${{ github.event.pull_request.number }}
4446
run: |
4547
# Check for any new fragment files in any .changelog/ directory
4648
fragments=$(git diff --diff-filter=A --name-only FETCH_HEAD -- '**/.changelog/*' '.changelog/*' | grep -v '.gitignore' || true)
4749
if [[ -z "$fragments" ]]; then
4850
echo "No changelog fragment found for this PR."
4951
echo ""
50-
echo "Add a file named .changelog/${{ github.event.pull_request.number }}.<type>"
52+
echo "Add a file named .changelog/${PR_NUMBER}.<type>"
5153
echo "where <type> is one of: added, changed, deprecated, removed, fixed"
5254
echo ""
5355
echo "For coordinated packages, add to the root .changelog/ directory."
@@ -57,6 +59,24 @@ jobs:
5759
echo "Or add the \"Skip Changelog\" label if this job should be skipped."
5860
exit 1
5961
fi
62+
invalid=()
63+
while IFS= read -r f; do
64+
base=$(basename "$f")
65+
if [[ ! "$base" =~ ^([0-9]+)\.(added|changed|deprecated|removed|fixed)$ ]]; then
66+
invalid+=("$f (expected <PR_NUMBER>.<type>; type one of added, changed, deprecated, removed, fixed)")
67+
continue
68+
fi
69+
if [[ "${BASH_REMATCH[1]}" != "${PR_NUMBER}" ]]; then
70+
invalid+=("$f (PR number ${BASH_REMATCH[1]} does not match this PR's number ${PR_NUMBER})")
71+
fi
72+
done <<< "$fragments"
73+
if (( ${#invalid[@]} > 0 )); then
74+
echo "Invalid changelog fragment(s):"
75+
for msg in "${invalid[@]}"; do
76+
echo " $msg"
77+
done
78+
exit 1
79+
fi
6080
echo "Found changelog fragment(s):"
6181
echo "$fragments"
6282

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Do *NOT* add changelog entries here!
77
88
This changelog is managed by towncrier and is compiled at release time.
99
10+
The static "## Unreleased" section below pre-dates towncrier; its entries
11+
must be folded into the first towncrier-generated release manually.
12+
1013
See https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md#changelog for details.
1114
-->
1215

opamp/opentelemetry-opamp-client/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Do *NOT* add changelog entries here!
77
88
This changelog is managed by towncrier and is compiled at release time.
99
10+
The static "## Unreleased" section below pre-dates towncrier; its entries
11+
must be folded into the first towncrier-generated release manually.
12+
1013
See https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md#changelog for details.
1114
-->
1215

propagator/opentelemetry-propagator-aws-xray/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Do *NOT* add changelog entries here!
77
88
This changelog is managed by towncrier and is compiled at release time.
99
10+
The static "## Unreleased" section below pre-dates towncrier; its entries
11+
must be folded into the first towncrier-generated release manually.
12+
1013
See https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md#changelog for details.
1114
-->
1215

resource/opentelemetry-resource-detector-azure/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Do *NOT* add changelog entries here!
77
88
This changelog is managed by towncrier and is compiled at release time.
99
10+
The static "## Unreleased" section below pre-dates towncrier; its entries
11+
must be folded into the first towncrier-generated release manually.
12+
1013
See https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md#changelog for details.
1114
-->
1215

sdk-extension/opentelemetry-sdk-extension-aws/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Do *NOT* add changelog entries here!
77
88
This changelog is managed by towncrier and is compiled at release time.
99
10+
The static "## Unreleased" section below pre-dates towncrier; its entries
11+
must be folded into the first towncrier-generated release manually.
12+
1013
See https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md#changelog for details.
1114
-->
1215

0 commit comments

Comments
 (0)