Skip to content

Commit e544200

Browse files
authored
Add workflow to check for release notes update (#107)
This workflow will check PRs to see if a change was done in the `src/` directory, and if so, it will fail if the `RELEASE_NOTES.md` wasn't also updated. Users can override this by assigning the label `cmd:skip-release-notes` to the PR for changes that don't really need a release notes update. - cookiecutter: Add workflow to check for release notes update - Add the release notes check workflow
2 parents 156a201 + 305cdde commit e544200

File tree

14 files changed

+285
-2
lines changed

14 files changed

+285
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release Notes Check
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
types:
7+
# On by default if you specify no types.
8+
- "opened"
9+
- "reopened"
10+
- "synchronize"
11+
# For `skip-label` only.
12+
- "labeled"
13+
- "unlabeled"
14+
15+
16+
jobs:
17+
check-release-notes:
18+
name: Check release notes are updated
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check for a release notes update
22+
if: github.event_name == 'pull_request'
23+
uses: brettcannon/check-for-changed-files@4170644959a21843b31f1181f2a1761d65ef4791 # v1.2.0
24+
with:
25+
file-pattern: "RELEASE_NOTES.md"
26+
prereq-pattern: "src/**"
27+
skip-label: "cmd:skip-release-notes"
28+
failure-message: "Missing a release notes update. Please add one or apply the ${skip-label} label to the pull request"

RELEASE_NOTES.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,37 @@
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
9+
- To make the new workflow to check if release notes were updated you should add the check to the branch protection rules of your repository to require this check to pass. You should also add a new label *"cmd:skip-release-notes"* to be able to override the check. You can use the following script to do it:
10+
11+
```sh
12+
repo=... # org/repo
13+
token=... # GitHub token with the correct permissions
14+
name="cmd:skip-release-notes"
15+
desc="It is not necessary to update release notes for this PR"
16+
color="930F79"
17+
18+
# Using cURL
19+
curl -L \
20+
-X POST \
21+
-H "Accept: application/vnd.github+json" \
22+
-H "Authorization: Bearer $token" \
23+
-H "X-GitHub-Api-Version: 2022-11-28" \
24+
-d '{"name":"'"$name"'","description":"'"$desc"'","color":"'"$color"'"}' \
25+
"https://api.github.com/repos/$repo/labels"
26+
27+
# Using the gh tool (no need for a token if you already have it configured)
28+
gh api -X POST \
29+
-f name="$name" -f description="$desc" -f color="$color" \
30+
"repos/$repo/labels"
31+
```
1032

1133
## New Features
1234

13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
35+
- Cookiecutter: Add a new GitHub workflow to check that release notes were updated.
36+
37+
This workflow will check PRs to see if a change was done in the `src/` directory, and if so, it will fail if the `RELEASE_NOTES.md` wasn't also updated.
38+
39+
Users can override this by assigning the label `cmd:skip-release-notes` to the PR for changes that don't really need a release notes update.
1440

1541
## Bug Fixes
1642

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Notes Check
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
types:
7+
# On by default if you specify no types.
8+
- "opened"
9+
- "reopened"
10+
- "synchronize"
11+
# For `skip-label` only.
12+
- "labeled"
13+
- "unlabeled"
14+
15+
16+
jobs:
17+
check-release-notes:
18+
name: Check release notes are updated
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check for a release notes update
22+
if: github.event_name == 'pull_request'
23+
uses: brettcannon/check-for-changed-files@4170644959a21843b31f1181f2a1761d65ef4791 # v1.2.0
24+
with:
25+
# TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
26+
# token: {{'${{ secrets.github_token }}'}}
27+
file-pattern: "RELEASE_NOTES.md"
28+
prereq-pattern: "src/**"
29+
skip-label: "cmd:skip-release-notes"
30+
failure-message: "Missing a release notes update. Please add one or apply the ${skip-label} label to the pull request"

docs/index.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,50 @@ sessions, which include running linters and tests.
109109
Otherwise, `nox` will create many virtual environments each time you run
110110
it, which is **very** slow.
111111

112+
### Configure the release notes check GitHub workflow
113+
114+
By default a workflow to check if the release notes were updated is
115+
included. This workflow will check PRs to see if a change was done in the
116+
`src/` directory, and if so, it will fail if the `RELEASE_NOTES.md` wasn't also
117+
updated.
118+
119+
But this check will not be enforced unless some extra configuration is done. To
120+
enforce the check for PRs to be merged you need to go to the *GitHub repository
121+
-> Settings -> Branches* and select the rule for the branch you want to protect.
122+
123+
Then in the rules search for the *Require status checks to pass before merging*
124+
checkbox and search for *"Check release notes are updated"* in the search box.
125+
126+
As sometimes it is OK for PRs not to have release notes, as maybe some changes
127+
don't impact the end user, this workflow can be overridden by assigning the
128+
label `cmd:skip-release-notes` to the PR. To be able to do this, you also need
129+
to add that label to the repository.
130+
131+
You can do this from the GitHub web interface, or using one of the following
132+
commands:
133+
134+
```sh
135+
repo=... # org/repo
136+
token=... # GitHub token with the correct permissions
137+
name="cmd:skip-release-notes"
138+
desc="It is not necessary to update release notes for this PR"
139+
color="930F79"
140+
141+
# Using cURL
142+
curl -L \
143+
-X POST \
144+
-H "Accept: application/vnd.github+json" \
145+
-H "Authorization: Bearer $token" \
146+
-H "X-GitHub-Api-Version: 2022-11-28" \
147+
-d '{"name":"'"$name"'","description":"'"$desc"'","color":"'"$color"'"}' \
148+
"https://api.github.com/repos/$repo/labels"
149+
150+
# Using the gh tool (no need for a token if you already have it configured)
151+
gh api -X POST \
152+
-f name="$name" -f description="$desc" -f color="$color" \
153+
"repos/$repo/labels"
154+
```
155+
112156
### Verify the generated documentation works
113157

114158
To generate the documentation, you can use `mkdocs`:

tests_golden/integration/test_cookiecutter_generation/actor/cookiecutter-stdout.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
./.github/ISSUE_TEMPLATE/config.yml: # TODO(cookiecutter): Make sure the GitHub repository has a discussion category "Support"
33
./.github/keylabeler.yml: # TODO(cookiecutter): Add other parts
44
./.github/labeler.yml:# TODO(cookiecutter): Add different parts of the source
5+
./.github/workflows/release-notes-check.yml: # TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
56
./CODEOWNERS:# TODO(cookiecutter): Add more specific code-owners, check if the default is correct
67
./CODEOWNERS:* TODO(cookiecutter): Add codeowners (like @{github_org}/some-team)# Temporary, should probably change
78
./README.md:TODO(cookiecutter): Improve the README file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Notes Check
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
types:
7+
# On by default if you specify no types.
8+
- "opened"
9+
- "reopened"
10+
- "synchronize"
11+
# For `skip-label` only.
12+
- "labeled"
13+
- "unlabeled"
14+
15+
16+
jobs:
17+
check-release-notes:
18+
name: Check release notes are updated
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check for a release notes update
22+
if: github.event_name == 'pull_request'
23+
uses: brettcannon/check-for-changed-files@4170644959a21843b31f1181f2a1761d65ef4791 # v1.2.0
24+
with:
25+
# TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
26+
# token: ${{ secrets.github_token }}
27+
file-pattern: "RELEASE_NOTES.md"
28+
prereq-pattern: "src/**"
29+
skip-label: "cmd:skip-release-notes"
30+
failure-message: "Missing a release notes update. Please add one or apply the ${skip-label} label to the pull request"

tests_golden/integration/test_cookiecutter_generation/api/cookiecutter-stdout.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
./.github/ISSUE_TEMPLATE/config.yml: # TODO(cookiecutter): Make sure the GitHub repository has a discussion category "Support"
33
./.github/keylabeler.yml: # TODO(cookiecutter): Add other parts
44
./.github/labeler.yml:# TODO(cookiecutter): Add different parts of the source
5+
./.github/workflows/release-notes-check.yml: # TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
56
./CODEOWNERS:# TODO(cookiecutter): Add more specific code-owners, check if the default is correct
67
./README.md:TODO(cookiecutter): Improve the README file
78
./mkdocs.yml: # TODO(cookiecutter): You might want to add other external references here
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Notes Check
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
types:
7+
# On by default if you specify no types.
8+
- "opened"
9+
- "reopened"
10+
- "synchronize"
11+
# For `skip-label` only.
12+
- "labeled"
13+
- "unlabeled"
14+
15+
16+
jobs:
17+
check-release-notes:
18+
name: Check release notes are updated
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check for a release notes update
22+
if: github.event_name == 'pull_request'
23+
uses: brettcannon/check-for-changed-files@4170644959a21843b31f1181f2a1761d65ef4791 # v1.2.0
24+
with:
25+
# TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
26+
# token: ${{ secrets.github_token }}
27+
file-pattern: "RELEASE_NOTES.md"
28+
prereq-pattern: "src/**"
29+
skip-label: "cmd:skip-release-notes"
30+
failure-message: "Missing a release notes update. Please add one or apply the ${skip-label} label to the pull request"

tests_golden/integration/test_cookiecutter_generation/app/cookiecutter-stdout.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
./.github/ISSUE_TEMPLATE/config.yml: # TODO(cookiecutter): Make sure the GitHub repository has a discussion category "Support"
33
./.github/keylabeler.yml: # TODO(cookiecutter): Add other parts
44
./.github/labeler.yml:# TODO(cookiecutter): Add different parts of the source
5+
./.github/workflows/release-notes-check.yml: # TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
56
./CODEOWNERS:# TODO(cookiecutter): Add more specific code-owners, check if the default is correct
67
./README.md:TODO(cookiecutter): Improve the README file
78
./mkdocs.yml: # TODO(cookiecutter): You might want to add other external references here
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Notes Check
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
types:
7+
# On by default if you specify no types.
8+
- "opened"
9+
- "reopened"
10+
- "synchronize"
11+
# For `skip-label` only.
12+
- "labeled"
13+
- "unlabeled"
14+
15+
16+
jobs:
17+
check-release-notes:
18+
name: Check release notes are updated
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check for a release notes update
22+
if: github.event_name == 'pull_request'
23+
uses: brettcannon/check-for-changed-files@4170644959a21843b31f1181f2a1761d65ef4791 # v1.2.0
24+
with:
25+
# TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
26+
# token: ${{ secrets.github_token }}
27+
file-pattern: "RELEASE_NOTES.md"
28+
prereq-pattern: "src/**"
29+
skip-label: "cmd:skip-release-notes"
30+
failure-message: "Missing a release notes update. Please add one or apply the ${skip-label} label to the pull request"

0 commit comments

Comments
 (0)