Skip to content

Commit e25c923

Browse files
committed
Manage the change log with towncrier
Adds the towncrier config, an empty CHANGELOG.md, the fragment template and a workflow that fails a pull request carrying no news fragment. News fragments for the three fixes on this branch come with it. Two things had to follow from it. The changelog workflow exempts a pull request labelled "skip changelog", and that label did not exist in the repository, so the escape hatch worked for nobody; it exists now. Dependabot cannot write a fragment for itself, so both of its update blocks carry that label, otherwise every dependency bump would arrive with a failing check. The generated CHANGELOG.md pointed contributors at Plone's contributing guide. It points at this repository's README instead, which now documents the fragment types, the naming convention and the label. Also excludes the changelog files from the docker build context, the way README.md and Makefile already are.
1 parent c84be84 commit e25c923

13 files changed

Lines changed: 147 additions & 0 deletions

‎.dockerignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ Makefile
77
README.md
88
Dockerfile.test
99
tests
10+
CHANGELOG.md
11+
news
12+
towncrier.toml

‎.github/dependabot.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ updates:
1414
patterns:
1515
- "*"
1616
# Must already exist in the repository, otherwise it is silently ignored.
17+
# "skip changelog" is what exempts these pull requests from the changelog
18+
# workflow, which dependabot has no way of satisfying itself.
1719
labels:
1820
- "dependencies"
21+
- "skip changelog"
1922

2023
- package-ecosystem: "docker"
2124
# Keeps the pinned base image in Dockerfile current.
@@ -27,3 +30,4 @@ updates:
2730
default-days: 7
2831
labels:
2932
- "dependencies"
33+
- "skip changelog"

‎.github/workflows/changelog.yml‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Changelog"
2+
on:
3+
pull_request:
4+
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
5+
branches:
6+
- main
7+
8+
env:
9+
base-branch: main
10+
11+
permissions:
12+
contents: read
13+
pull-requests: read
14+
15+
jobs:
16+
17+
checks:
18+
runs-on: ubuntu-latest
19+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip changelog') }}
20+
steps:
21+
- uses: actions/checkout@v7
22+
with:
23+
# Fetch all history
24+
fetch-depth: '0'
25+
26+
- name: Setup uv
27+
uses: plone/meta/.github/actions/setup_uv@2.x
28+
with:
29+
python-version: "3.14"
30+
working-directory: '.'
31+
32+
- name: "Fetch base branch"
33+
run: |
34+
# Reference: https://github.com/actions/checkout/#fetch-all-branches.
35+
git fetch --no-tags origin ${{ env.base-branch }}
36+
37+
- name: "Repository: Check"
38+
id: repository-changelog
39+
run: |
40+
uvx towncrier check --compare-with origin/${{ env.base-branch }} --config ./towncrier.toml --dir ./
41+
42+
- name: "Report check"
43+
if: ${{ always() }}
44+
run: |
45+
echo '# Workflow Report' >> $GITHUB_STEP_SUMMARY
46+
echo '| Job ID | Conclusion |' >> $GITHUB_STEP_SUMMARY
47+
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
48+
echo '| repository |${{ steps.repository-changelog.conclusion }} |' >> $GITHUB_STEP_SUMMARY

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change log
2+
3+
<!-- You should *NOT* be adding new change log entries to this file.
4+
You should create a file in the news directory instead.
5+
See the Development section of README.md for the fragment types and
6+
naming convention.
7+
-->
8+
9+
<!-- towncrier release notes start -->

‎Makefile‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ build-test-image: # Build the bats test runner image
5757
test: build-test-image # Run the bats test suite
5858
docker run --rm -v "$(PWD)":/code -w /code $(TEST_RUNNER_IMAGE) tests/
5959

60+
# Changelog
61+
.PHONY: draft-changelog
62+
draft-changelog: # Display the draft of the changelog
63+
@uvx towncrier build --draft --version unreleased --config towncrier.toml
64+
65+
# Release
66+
.PHONY: create-tag
6067
create-tag: # Create a new tag using git
6168
@test -n "$(VERSION)"
6269
if git show-ref --tags v$(VERSION) --quiet; \
@@ -65,6 +72,7 @@ create-tag: # Create a new tag using git
6572
else \
6673
echo "Creating new tag $(VERSION)"; \
6774
sed -i 's/$(BASE_NAME):latest/$(BASE_NAME):$(VERSION)/' action.yml; \
75+
uvx towncrier build --yes --version $(VERSION) --config towncrier.toml; \
6876
git commit -am "Prepare release $(VERSION)"; \
6977
git tag -a v$(VERSION) -m "Release $(VERSION)"; \
7078
git push && git push --tags; \

‎README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,28 @@ Tests that document a currently open bug call `skip` with a link to the issue.
224224
They are written to assert the *desired* behaviour, so fixing the bug means
225225
deleting the `skip` line rather than writing a new test.
226226

227+
### Change log
228+
229+
`CHANGELOG.md` is generated by [towncrier](https://towncrier.readthedocs.io/) —
230+
do not edit it directly. Add a file to `news/` instead, named for the issue it
231+
addresses, and CI will check that every pull request has one.
232+
233+
```
234+
news/21.bugfix # an issue number, when there is an issue
235+
news/+test-harness.internal # a short slug, when there is not
236+
```
237+
238+
Types are `breaking`, `feature`, `bugfix`, `internal` and `documentation`. Write
239+
one sentence in the past tense, describing the change from the user's side, and
240+
sign it with your GitHub handle:
241+
242+
```
243+
Fixed `env_file` values containing spaces being truncated. @ericof
244+
```
245+
246+
Preview the result with `uvx towncrier build --draft --version <next>`. A pull
247+
request that genuinely needs no entry can carry the `skip changelog` label.
248+
227249
228250
## Credits
229251

‎news/+test-harness.internal‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a bats test suite for the shell scripts, run in CI together with shellcheck. @ericof

‎news/+towncrier.internal‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added towncrier to manage the change log, with a CI check that every pull request carries a news fragment. @ericof

‎news/.changelog_template.jinja‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% if sections[""] %}
2+
{% for category, val in definitions.items() if category in sections[""] %}
3+
4+
### {{ definitions[category]['name'] }}
5+
6+
{% for text, values in sections[""][category].items() %}
7+
- {{ text }} {{ values|join(', ') }}
8+
{% endfor %}
9+
10+
{% endfor %}
11+
{% else %}
12+
No significant changes.
13+
14+
15+
{% endif %}

‎news/13.bugfix‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the deploy waiting until it timed out on a `mode: replicated-job` service that had already run to completion. @ericof

0 commit comments

Comments
 (0)