Skip to content

Commit d7a3b09

Browse files
#92 - Add support for more characters as markdown list rows (#93)
* #92 - Add support for more characters as markdown list rows - Implemented support for + and * characters. - Applied black. - Improvement of unit tests. - Update of README.md * #91 - Placeholder {number} does not # before Issue or PR number - Removed the need to provide # in template of row - for record number. - Update of pull-request to GitHub link type. Removed Markdown format of link.
1 parent f3bcb34 commit d7a3b09

21 files changed

+185
-234
lines changed

.github/workflows/check_pr_release_notes.yml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@
1414
# limitations under the License.
1515
#
1616

17-
name: Check Release Notes in PR description
17+
name: Check PR Release Notes in Description
1818

1919
on:
2020
pull_request:
2121
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
2222
branches: [ master ]
2323

24+
env:
25+
SKIP_LABEL: 'no RN'
26+
RLS_NOTES_TAG_REGEX: 'Release Notes:'
27+
2428
jobs:
2529
check-release-notes:
2630
runs-on: ubuntu-latest
27-
steps:
28-
- name: Checkout code
29-
uses: actions/checkout@v4
3031

32+
steps:
3133
- name: Get Pull Request Info
3234
id: pr_info
3335
uses: actions/github-script@v7
@@ -40,11 +42,11 @@ jobs:
4042
pull_number: pr_number
4143
});
4244
const labels = pr.data.labels ? pr.data.labels.map(label => label.name) : [];
43-
44-
// Check if "skip-release-notes-check" label is present
45-
if (labels.includes("skip-release-notes-check")) {
46-
console.log("Skipping release notes check because 'skip-release-notes-check' label is present.");
45+
46+
if (labels.includes("${{ env.SKIP_LABEL }}")) {
47+
console.log("Skipping release notes check because '${{ env.SKIP_LABEL }}' label is present.");
4748
core.setOutput("skip_check", 'true');
49+
core.setOutput("pr_body", "");
4850
return;
4951
}
5052
@@ -59,27 +61,27 @@ jobs:
5961
core.setOutput("skip_check", 'false');
6062
return;
6163
62-
- name: Skip check if 'no-release-notes' label is present
64+
- name: Skip check if SKIP_LABEL is present
6365
if: steps.pr_info.outputs.skip_check == 'true'
6466
run: echo "Skipping release notes validation."
6567

66-
- name: Check for 'Release notes:' and bullet list
68+
- name: Check for 'Release Notes:' and bullet list
6769
if: steps.pr_info.outputs.skip_check == 'false'
6870
run: |
6971
# Extract the body from the previous step
7072
PR_BODY="${{ steps.pr_info.outputs.pr_body }}"
71-
72-
# Check if "Release notes:" exists
73-
if ! echo "$PR_BODY" | grep -qi 'release notes:'; then
74-
echo "Error: 'Release notes:' not found in pull request description."
73+
74+
# Check if "Release Notes:" exists
75+
if ! echo "$PR_BODY" | grep -q '${{ env.RLS_NOTES_TAG_REGEX }}'; then
76+
echo "Error: release notes tag not found in pull request description. Has to adhere to format '${{ env.RLS_NOTES_TAG_REGEX }}'."
7577
exit 1
7678
fi
77-
78-
# Extract text after "Release notes:" line
79-
RELEASE_NOTES=$(echo "$PR_BODY" | sed -n '/[Rr]elease.*[Nn]otes/,$p' | tail -n +2)
80-
81-
# Check if there's a bullet list (lines starting with '-' or '*')
82-
if ! echo "$RELEASE_NOTES" | grep -qE '^\s*[-*]\s+.+$'; then
83-
echo "Error: No bullet list found under 'Release notes:'."
79+
80+
# Extract text after "Release Notes:" line
81+
TEXT_BELOW_RELEASE_NOTES_TAG=$(echo "$PR_BODY" | sed -n '/${{ env.RLS_NOTES_TAG_REGEX }}/,$p' | tail -n +2)
82+
83+
# Check if there's a bullet list (lines starting with '-', '+' or '*')
84+
if ! echo "$TEXT_BELOW_RELEASE_NOTES_TAG" | grep -qE '^\s*[-+*]\s+.+$'; then
85+
echo "Error: No bullet list found under release notes tag."
8486
exit 1
8587
fi

.github/workflows/release_draft.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
check-tag:
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v4.1.1
29+
- uses: actions/checkout@v4
3030
with:
3131
fetch-depth: 0
3232

@@ -78,11 +78,11 @@ jobs:
7878
7979
tag-name: ${{ github.event.inputs.tag-name }}
8080

81-
generate-release-notes:
81+
release-draft:
8282
needs: check-tag
8383
runs-on: ubuntu-latest
8484
steps:
85-
- uses: actions/checkout@v4.1.1
85+
- uses: actions/checkout@v4
8686
with:
8787
fetch-depth: 0
8888

@@ -98,13 +98,24 @@ jobs:
9898
with:
9999
tag-name: ${{ github.event.inputs.tag-name }}
100100
chapters: '[
101+
{"title": "No entry 🚫", "label": "duplicate"},
102+
{"title": "No entry 🚫", "label": "invalid"},
103+
{"title": "No entry 🚫", "label": "wontfix"},
104+
{"title": "No entry 🚫", "label": "no RN"},
101105
{"title": "Breaking Changes 💥", "label": "breaking-change"},
102106
{"title": "New Features 🎉", "label": "enhancement"},
103107
{"title": "New Features 🎉", "label": "feature"},
104-
{"title": "Bugfixes 🛠", "label": "bug"}
108+
{"title": "Bugfixes 🛠", "label": "bug"},
109+
{"title": "Infrastructure ⚙️", "label": "infrastructure"},
110+
{"title": "Silent-live 🤫", "label": "silent-live"},
111+
{"title": "Documentation 📜", "label": "documentation"}
105112
]'
113+
skip-release-notes-label: 'no RN'
106114
verbose: true
115+
107116
warnings: true
117+
print-empty-chapters: true
118+
chapters-to-pr-without-issue: true
108119

109120

110121
- name: Create and Push Tag

.github/workflows/release_notes_comments_migration.yml

Lines changed: 0 additions & 110 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
run: echo "PYTHONPATH=${GITHUB_WORKSPACE}/release_notes_generator/release_notes_generator" >> $GITHUB_ENV
103103

104104
- name: Build and run unit tests
105-
run: pytest --cov=release_notes_generator --cov-report html tests/ -vv
105+
run: pytest --cov=. --cov-report=html tests/ -vv
106106

107107
- name: Check overall coverage
108108
run: |

.pylintrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,7 @@ confidence=HIGH,
431431
# --enable=similarities". If you want to run only the classes checker, but have
432432
# no Warning level messages displayed, use "--disable=all --enable=classes
433433
# --disable=W".
434-
# TODO: Remove after this PR
435-
disable=C0116,
436-
C0115,
437-
C0114,
438-
raw-checker-failed,
434+
disable=raw-checker-failed,
439435
bad-inline-option,
440436
locally-disabled,
441437
file-ignored,

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ Generate Release Notes action is dedicated to enhance the quality and organizati
5454
### `row-format-issue`
5555
- **Description**: The format of the row for the issue in the release notes. The format can contain placeholders for the issue `number`, `title`, and issues `pull-requests`. The placeholders are case-sensitive.
5656
- **Required**: No
57-
- **Default**: `#{number} _{title}_ in {pull-requests}"`
57+
- **Default**: `"{number} _{title}_ in {pull-requests}"`
5858

5959
### `row-format-pr`
60-
- **Description**: The format of the row for the PR in the release notes. The format can contain placeholders for the PR `number`, `title`, and PR `pull-requests`. The placeholders are case-sensitive.
60+
- **Description**: The format of the row for the PR in the release notes. The format can contain placeholders for the PR `number`, and `title`. The placeholders are case-sensitive.
6161
- **Required**: No
62-
- **Default**: `#{number} _{title}_"`
62+
- **Default**: `"{number} _{title}_"`
6363

6464
### `row-format-link-pr`
6565
- **Description**: If defined `true`, the PR row will begin with a `"PR: "` string. Otherwise, no prefix will be added.
@@ -164,32 +164,31 @@ Add the following step to your GitHub workflow (in example are used non-default
164164
## Features
165165
### Built-in
166166
#### Release Notes Extraction Process
167+
This feature searches for release notes in the description of GitHub pull requests, making it easier for maintainers to track changes and updates.
168+
- **Format:**
169+
- The release notes section have to begin with the title `Release Notes:` (case-sensitive), followed by the release notes in bullet points. [Markdown formatting is supported](https://www.markdownguide.org/basic-syntax/#unordered-lists).
170+
- If no release notes line is detected under the `Release Notes:` title, no release notes will be printed in the output.
171+
- **Example:**
172+
- Here are examples of how to structure the release notes:
173+
```
174+
Release Notes:
175+
- This update introduces a new caching mechanism that improves performance by 20%.
167176
168-
This action requires that your GitHub issues include comments with specific release notes. Here's how it works:
177+
Release Notes:
178+
* This update introduces a new caching mechanism that improves performance by 20%.
169179
170-
**Extraction Method**:
171-
- The action scans through comments on each closed issue since the last release. It identifies comments that follow the specified format and extracts the content as part of the release notes.
172-
- The time considered for the previous release is based on its creation time. This means that the action will look for issues closed after the creation time of the most recent release to ensure that all relevant updates since that release are included.
180+
Release Notes:
181+
+ This update introduces a new caching mechanism that improves performance by 20%.
173182
174-
**Comment Format**
175-
- For an issue's contributions to be included in the release notes, it must contain a comment starting with "Release Notes" followed by the note content. This comment is typically added by the contributors.
176-
- Here is an example of the content for a 'Release Notes' string, which is not case-sensitive:
177-
```
178-
Release Notes
179-
- This update introduces a new caching mechanism that improves performance by 20%.
180183
```
181-
- Using `-` as a bullet point for each note is the best practice. The Markdown parser will automatically convert it to a list.
182-
- These comments are not required for action functionality. If an issue does not contain a "Release Notes" comment, it will be marked accordingly in the release notes. This helps maintainers quickly identify which issues need attention for documentation.
184+
The extraction process supports all three types of bullet points: `-`, `*`, and `+`, and their combinations. (GitHub documentation do not recommend to mix them.)
183185

184-
#### Contributors Mention
185-
Along with the release note content, the action also gathers a list of contributors for each issue. This includes issue assignees and authors of linked pull requests' commits, providing acknowledgment for their contributions in the release notes.
186+
- **Best Practice:** Select one character from `-`, `*`, `+` for bullet points. The Markdown parser will automatically format them as a list.
187+
- **Optional usage:** The release notes section is not mandatory for GH action to work.
186188

187189
#### Handling Multiple PRs
188190
If an issue is linked to multiple PRs, the action fetches and aggregates contributions from all linked PRs.
189191

190-
#### No Release Notes Found
191-
If no valid "Release Notes" comment is found in an issue, it will be marked accordingly. This helps maintainers quickly identify which issues need attention for documentation.
192-
193192
### Select start date for closed issues and PRs
194193
By set **published-at** to true the action will use the `published-at` timestamp of the latest release as the reference point for searching closed issues and PRs, instead of the `created-at` date. If first release, repository creation date is used.
195194

@@ -210,7 +209,7 @@ The action includes four specific warning chapters to highlight potential areas
210209
- **Importance**: Ensures all issues are categorized correctly according to the project's classification system. It aids in organizing release notes into predefined chapters effectively.
211210

212211
- **_Closed Issues Without Release Notes_**
213-
- **Purpose**: Identifies issues that do not contain a "Release Notes" comment.
212+
- **Purpose**: Identifies pull requests which do not contain a "Release Notes" section in description.
214213
- **Importance**: Ensures that all significant changes are properly documented in the release notes, enhancing the completeness and usefulness of the release information provided to end-users.
215214

216215
- **_Merged PRs Without Linked Issue_**
@@ -341,16 +340,18 @@ Unit tests are written using pytest. To run the tests, use the following command
341340
pytest tests/
342341
```
343342

344-
This will execute all tests located in the tests directory and generate a code coverage report.
343+
This will execute all tests located in the tests directory.
345344

346345
## Code Coverage
347346

348347
Code coverage is collected using pytest-cov coverage tool. To run the tests and collect coverage information, use the following command:
349348

350349
```
351-
pytest --cov=release_notes_generator --cov-report html tests/
350+
pytest --cov=. --cov-report=html tests/
352351
```
353352

353+
This will execute all tests located in the tests directory and generate a code coverage report.
354+
354355
See the coverage report on the path:
355356

356357
```
@@ -448,8 +449,8 @@ We defined chapters for our GH actions this way:
448449
Then in chapters `New Features 🎉` and `Bugfixes 🛠` will be duplicated lines for this issue. When mentioned second+ times then **[Duplicate]** prefix will be visible.
449450
In the `New Features 🎉` chapter will be mentioned this issue once only.
450451

451-
### What will happen when the issue contains multiple "Release Notes" comments?
452-
All issue comments are checked for presence of `Release Notes` string. All detected release notes are collected printed under issue.
452+
### What will happen when the pull request contains multiple "Release Notes" sections?
453+
Only the first one will be used.
453454

454455
### What will happen when Merged PR is linked to open issues?
455456
The PR will be mentioned in warning chapter **Merged PRs Linked to Open Issue**.

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ inputs:
5252
required: false
5353
default: 'false'
5454
row-format-issue:
55-
description: 'Format of the issue row in the release notes. Available placeholders: {link}, {title}, {pull-requests}. Placeholders are case-insensitive.'
55+
description: 'Format of the issue row in the release notes. Available placeholders: {number}, {title}, {pull-requests}. Placeholders are case-insensitive.'
5656
required: false
57-
default: '#{number} _{title}_ in {pull-requests}'
57+
default: '{number} _{title}_ in {pull-requests}'
5858
row-format-pr:
59-
description: 'Format of the pr row in the release notes. Available placeholders: {link}, {title}, {pull-requests}. Placeholders are case-insensitive.'
59+
description: 'Format of the pr row in the release notes. Available placeholders: {number}, {title}, {pull-requests}. Placeholders are case-insensitive.'
6060
required: false
61-
default: '#{number} _{title}_'
61+
default: '{number} _{title}_'
6262
row-format-link-pr:
6363
description: 'Add prefix "PR:" before link to PR when not linked an Issue.'
6464
required: false

0 commit comments

Comments
 (0)