Skip to content

Commit 1b23837

Browse files
Require stable changelog validation context (#260)
* fix: add required changelog validation context * Update wiki submodule pointer for PR #260 * docs: require stable changelog validation context for branch protection --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 6cb1b52 commit 1b23837

7 files changed

Lines changed: 76 additions & 1 deletion

File tree

.github/wiki

Submodule wiki updated from 0b4c890 to 3dea0d4

.github/workflows/changelog.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,36 @@ jobs:
147147
- Dependabot fallback generated message: `${{ steps.dependabot_entry.outputs.message || 'not needed' }}`
148148
- Validation result: success
149149
150+
changelog_validation:
151+
name: Changelog Validation
152+
needs:
153+
- resolve_php
154+
- validate_pull_request
155+
if: ${{ always() && github.event.pull_request.number && github.event.pull_request.merged != true }}
156+
runs-on: ubuntu-latest
157+
env:
158+
RELEASE_BRANCH_PREFIX: ${{ inputs.release-branch-prefix || 'release/v' }}
159+
VALIDATION_RESULT: ${{ needs.validate_pull_request.result }}
160+
161+
steps:
162+
- name: Require changelog validation result
163+
env:
164+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
165+
run: |
166+
if [[ "${HEAD_REF}" == "${RELEASE_BRANCH_PREFIX}"* ]]; then
167+
echo "Release preparation branch detected; changelog validation is intentionally skipped."
168+
exit 0
169+
fi
170+
171+
if [ "${VALIDATION_RESULT}" = "success" ]; then
172+
echo "Changelog validation passed."
173+
exit 0
174+
fi
175+
176+
echo "::error::Changelog validation did not pass for this pull request."
177+
echo "Validation result: ${VALIDATION_RESULT}"
178+
exit 1
179+
150180
prepare_release_pull_request:
151181
name: Prepare Release Pull Request
152182
needs: resolve_php

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12+
- Add a branch-protection-safe changelog validation context that fails normal
13+
pull requests when changelog validation fails while still passing release
14+
preparation branches where validation is intentionally skipped.
1215
- Teach pull-request publication guidance to read the published PR body back
1316
from GitHub and fix literal escaped Markdown control characters before
1417
handing the PR off for review.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ missing changelog file on first use, `changelog:check` enforces meaningful
177177
next semantic version from pending changes, `changelog:promote` publishes the
178178
current `Unreleased` section into a tagged version, and `changelog:show`
179179
renders one published section for GitHub release notes.
180+
Repositories that require changelog enforcement in branch protection should
181+
require the aggregate changelog check:
182+
183+
- Direct workflow invocation: `Changelog Validation`
184+
- Reusable workflow wrappers (`resources/github-actions/changelog.yml`): `changelog / Changelog Validation`
185+
186+
This remains stable for normal pull requests and release-preparation branches,
187+
while the lower-level validation job can be skipped intentionally for
188+
`release/v...` branches.
180189

181190
Structured output is available across the DevTools command surface through
182191
`--json`, which returns deterministic `message` / `level` / `context` payloads

docs/advanced/branch-protection-and-bot-commits.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ enabled. The dispatched run publishes the same required ``Run Tests`` contexts
134134
for the release PR head, which lets branch protection evaluate the final
135135
workflow-managed release commit without a maintainer bypass.
136136

137+
Changelog validation has its own branch-protection-safe aggregate context.
138+
For direct workflow runs, use ``Changelog Validation``. For consumers of the
139+
reusable workflow wrapper, use the namespaced check name ``changelog / Changelog
140+
Validation`` instead of the internal ``changelog / Validate PR Changelog`` job.
141+
The internal validation job is skipped for ``release/v...`` branches by design, while
142+
the aggregate job still reports success for release-preparation pull requests and
143+
failure for normal pull requests whose changelog validation did not pass.
144+
137145
At a high level, the workflows need permission to read repository contents,
138146
write generated preview commits, update pull request comments, and publish Pages
139147
content. Keep those permissions scoped to the workflow jobs that actually need

docs/internals/release-publishing.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ and fix pull requests SHOULD expect ``changelog:check`` to run against the base
100100
branch and fail when no meaningful ``Unreleased`` entry is added. Generated
101101
``release/v...`` pull requests are excluded from that validation because the
102102
release-preparation flow intentionally empties ``Unreleased`` after promotion.
103+
Repositories that protect merges SHOULD require the workflow's aggregate
104+
changelog context:
105+
106+
- Direct workflow invocation: ``Changelog Validation``
107+
- Reusable workflow wrapper invocation: ``changelog / Changelog Validation``
108+
109+
That context fails when a normal pull request does not pass changelog
110+
validation and succeeds for release-preparation branches where the internal
111+
validation job is intentionally skipped.
103112

104113
If maintainers must recover the release manually, create the tag from the
105114
verified ``main`` commit:

docs/usage/github-actions.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ wrapper in ``resources/github-actions/changelog.yml``.
168168
* Runs ``composer dev-tools changelog:check -- --against=<base-ref>`` against the base ref.
169169
* Fails when a normal non-release branch does not add a meaningful ``Unreleased`` change.
170170
* Skips the validation job for pull requests whose head branch matches the configured ``release-branch-prefix``, because release-preparation branches intentionally leave ``Unreleased`` empty after promotion.
171+
* Publishes the aggregate changelog check for every active pull request.
172+
Direct workflow invocation uses ``Changelog Validation``; reusable
173+
workflow consumers typically expose it namespaced as
174+
``changelog / Changelog Validation``. This is the branch-protection-safe
175+
context to require: it fails when normal changelog validation fails and
176+
succeeds for release-preparation branches where validation is
177+
intentionally skipped.
171178
* Appends a run summary with the compared base ref and changelog file.
172179
* **Manual Release Preparation**:
173180
* Checks out the repository default branch with full history.
@@ -200,6 +207,15 @@ wrapper in ``resources/github-actions/changelog.yml``.
200207
* Under **Workflow permissions**, enable **Read and write permissions**.
201208
* Enable **Allow GitHub Actions to create and approve pull requests**.
202209
* If either control is disabled or grayed out, the repository is likely constrained by organization-level policy or missing admin permission. In that case, an organization or repository admin must unlock the setting before manual release preparation can open a release pull request.
210+
* In branch protection, require the changelog workflow's aggregate context:
211+
212+
- Direct workflow invocation: ``Changelog Validation``
213+
- Reusable workflow wrapper invocation: ``changelog / Changelog Validation``
214+
215+
Use this instead of the internal ``changelog / Validate PR Changelog`` job.
216+
The internal job is intentionally skipped for release-preparation branches,
217+
while the aggregate context stays stable for normal and release pull
218+
requests.
203219

204220
.. note::
205221
Branch protection is not what blocks the release-preparation workflow from opening a pull request. Branch protection affects the merge of the ``release/v...`` pull request later in the flow. The gray or disabled workflow-permission controls come from repository permissions or organization policy.

0 commit comments

Comments
 (0)