Skip to content

Commit 0a05eee

Browse files
authored
CI: Add check for changelog entry (#88)
1 parent 0a00664 commit 0a05eee

4 files changed

Lines changed: 76 additions & 1 deletion

File tree

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.github/CODEOWNERS @neo4j/drivers
2+
/.github/workflows/ @neo4j/drivers

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
cooldown:
8+
default-days: 3
9+
open-pull-requests-limit: 5
10+
labels:
11+
- "no changelog"
12+
assignees:
13+
- "robsdedude"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Changelog Entry
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled, unlabeled]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
check:
13+
name: Check changelog entry
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
- name: Verify changelog entry or "no changelog" label
18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
REPO: ${{ github.repository }}
21+
PR_NUMBER: ${{ github.event.pull_request.number }}
22+
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
23+
run: |
24+
set -euo pipefail
25+
if echo "$LABELS" | jq -e 'index("no changelog")' > /dev/null; then
26+
echo "PR is labeled 'no changelog' - skipping check."
27+
exit 0
28+
fi
29+
expected="^changelog\\.d/${PR_NUMBER}\\.[^/]+\\.md$"
30+
matching=$(gh api "repos/$REPO/pulls/$PR_NUMBER/files" --paginate \
31+
| jq -r '.[] | select(.status == "added") | .filename' \
32+
| grep -E "$expected" \
33+
|| true)
34+
if [ -z "$matching" ]; then
35+
echo "::error::PR must add a file named 'changelog.d/${PR_NUMBER}.<type>.md' or carry the 'no changelog' label."
36+
echo "See changelog.d/README.md for how to create an entry."
37+
exit 1
38+
fi
39+
echo "Found new changelog entry/entries:"
40+
echo "$matching"
41+
echo "Checking changelog entries contain '<ISSUES_LIST>' placeholder on the first line..."
42+
missing=()
43+
while IFS= read -r file; do
44+
if ! head -n 1 "$file" | grep -qF '<ISSUES_LIST>'; then
45+
missing+=("$file")
46+
fi
47+
done <<< "$matching"
48+
if [ ${#missing[@]} -gt 0 ]; then
49+
echo "::error::The following changelog entries must contain '<ISSUES_LIST>' on the first line:"
50+
for f in "${missing[@]}"; do
51+
echo " - $f"
52+
done
53+
echo "See changelog.d/README.md for the expected format."
54+
exit 1
55+
fi

changelog.d/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1+
# How To Changelog
2+
13
To create a new entry, you can run:
4+
25
```bash
36
towncrier create "<PR number>.<type>"
47
```
8+
59
This will create a new file in the `changelog.d/` directory for you to fill in.
610
If there is no issue or PR number, you can use `+.<type>` instead.
711
The `<type>` determines how the entry will be grouped in the changelog.
812
For available types, see the `[[tool.towncrier.type]]` entries in the `pyproject.toml` file.
913

10-
You can include `<ISSUES_LIST>` in the entry to determine where the list of PR/issue links goes.
14+
The entry's first line must include `<ISSUES_LIST>.` to determine where the list of PR/issue links goes.
1115
Usually, the entries will look like this:
1216

1317
```markdown
1418
Some summary of the change<ISSUES_LIST>.
1519
```
1620

1721
or if there's more to say (note the trailing spaces after the first line):
22+
1823
```markdown
1924
Some summary of the change<ISSUES_LIST>.
2025
Some more details. Feel free to use markdown features like

0 commit comments

Comments
 (0)