Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#92 - Add support for more characters as markdown list rows #93

Merged
merged 20 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6b15137
#92 - Add support for more characters as markdown list rows
miroslavpojer Oct 11, 2024
869a6f0
- Applied black.
miroslavpojer Oct 11, 2024
ce33aaa
- Improvement of unit tests.
miroslavpojer Oct 11, 2024
d4121ae
- Update of README.md. Fixed comment mentions.
miroslavpojer Oct 11, 2024
59e2895
- Remove not used import.
miroslavpojer Oct 11, 2024
f512978
- Apply black to fix PR check.
miroslavpojer Oct 11, 2024
4f2ccb2
#91 - Placeholder {number} does not # before Issue or PR number
miroslavpojer Oct 14, 2024
f8f9eb3
Merge branch 'master' into bugfix/91-Placeholder-number
miroslavpojer Oct 16, 2024
b8a34b1
- Fixed `Release Notes:` pattern for detection rls notes in PR body. …
miroslavpojer Oct 16, 2024
cf8ed92
- Rewording.
miroslavpojer Oct 16, 2024
5eee2e9
- Add type hint.
miroslavpojer Oct 16, 2024
3f02bfd
- Fixed text line about test and coverage in README.md.
miroslavpojer Oct 16, 2024
9e11d4d
- Moved mention of case-sensivity for `Release Notes:` detection string.
miroslavpojer Oct 16, 2024
24886a8
- Small changes and improvement from review notes.
miroslavpojer Oct 16, 2024
8d46ba8
- Fixed unit tests.
miroslavpojer Oct 16, 2024
b831fb1
- Removed TODO from pylintrc.
miroslavpojer Oct 16, 2024
1622020
- Removed not needed word.
miroslavpojer Oct 17, 2024
0362f31
- Fix of example file to fit the latest expected version.
miroslavpojer Oct 17, 2024
7eb8d24
- Applied changes from external development to keep them as examples …
miroslavpojer Oct 21, 2024
8af61cd
- Replace code root dir by . to add all python file.
miroslavpojer Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions .github/workflows/check_pr_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@
# limitations under the License.
#

name: Check Release Notes in PR description
name: Check PR Release Notes in Description

on:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
branches: [ master ]

env:
SKIP_LABEL: 'no RN'
RLS_NOTES_TAG_REGEX: 'Release Notes:'

jobs:
check-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

steps:
- name: Get Pull Request Info
id: pr_info
uses: actions/github-script@v7
Expand All @@ -40,11 +42,11 @@ jobs:
pull_number: pr_number
});
const labels = pr.data.labels ? pr.data.labels.map(label => label.name) : [];

// Check if "skip-release-notes-check" label is present
if (labels.includes("skip-release-notes-check")) {
console.log("Skipping release notes check because 'skip-release-notes-check' label is present.");

if (labels.includes("${{ env.SKIP_LABEL }}")) {
console.log("Skipping release notes check because '${{ env.SKIP_LABEL }}' label is present.");
core.setOutput("skip_check", 'true');
core.setOutput("pr_body", "");
return;
}

Expand All @@ -59,27 +61,27 @@ jobs:
core.setOutput("skip_check", 'false');
return;

- name: Skip check if 'no-release-notes' label is present
- name: Skip check if SKIP_LABEL is present
if: steps.pr_info.outputs.skip_check == 'true'
run: echo "Skipping release notes validation."

- name: Check for 'Release notes:' and bullet list
- name: Check for 'Release Notes:' and bullet list
if: steps.pr_info.outputs.skip_check == 'false'
run: |
# Extract the body from the previous step
PR_BODY="${{ steps.pr_info.outputs.pr_body }}"
# Check if "Release notes:" exists
if ! echo "$PR_BODY" | grep -qi 'release notes:'; then
echo "Error: 'Release notes:' not found in pull request description."

# Check if "Release Notes:" exists
if ! echo "$PR_BODY" | grep -q '${{ env.RLS_NOTES_TAG_REGEX }}'; then
echo "Error: release notes tag not found in pull request description. Has to adhere to format '${{ env.RLS_NOTES_TAG_REGEX }}'."
exit 1
fi
# Extract text after "Release notes:" line
RELEASE_NOTES=$(echo "$PR_BODY" | sed -n '/[Rr]elease.*[Nn]otes/,$p' | tail -n +2)
# Check if there's a bullet list (lines starting with '-' or '*')
if ! echo "$RELEASE_NOTES" | grep -qE '^\s*[-*]\s+.+$'; then
echo "Error: No bullet list found under 'Release notes:'."

# Extract text after "Release Notes:" line
TEXT_BELOW_RELEASE_NOTES_TAG=$(echo "$PR_BODY" | sed -n '/${{ env.RLS_NOTES_TAG_REGEX }}/,$p' | tail -n +2)

# Check if there's a bullet list (lines starting with '-', '+' or '*')
if ! echo "$TEXT_BELOW_RELEASE_NOTES_TAG" | grep -qE '^\s*[-+*]\s+.+$'; then
echo "Error: No bullet list found under release notes tag."
exit 1
fi
19 changes: 15 additions & 4 deletions .github/workflows/release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
check-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -78,11 +78,11 @@ jobs:

tag-name: ${{ github.event.inputs.tag-name }}

generate-release-notes:
release-draft:
needs: check-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -98,13 +98,24 @@ jobs:
with:
tag-name: ${{ github.event.inputs.tag-name }}
chapters: '[
{"title": "No entry 🚫", "label": "duplicate"},
{"title": "No entry 🚫", "label": "invalid"},
{"title": "No entry 🚫", "label": "wontfix"},
{"title": "No entry 🚫", "label": "no RN"},
{"title": "Breaking Changes 💥", "label": "breaking-change"},
{"title": "New Features 🎉", "label": "enhancement"},
{"title": "New Features 🎉", "label": "feature"},
{"title": "Bugfixes 🛠", "label": "bug"}
{"title": "Bugfixes 🛠", "label": "bug"},
{"title": "Infrastructure ⚙️", "label": "infrastructure"},
{"title": "Silent-live 🤫", "label": "silent-live"},
{"title": "Documentation 📜", "label": "documentation"}
]'
skip-release-notes-label: 'no RN'
verbose: true

warnings: true
print-empty-chapters: true
chapters-to-pr-without-issue: true


- name: Create and Push Tag
Expand Down
110 changes: 0 additions & 110 deletions .github/workflows/release_notes_comments_migration.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
run: echo "PYTHONPATH=${GITHUB_WORKSPACE}/release_notes_generator/release_notes_generator" >> $GITHUB_ENV

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

- name: Check overall coverage
run: |
Expand Down
6 changes: 1 addition & 5 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,7 @@ confidence=HIGH,
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
# TODO: Remove after this PR
disable=C0116,
C0115,
C0114,
raw-checker-failed,
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
Expand Down
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ Generate Release Notes action is dedicated to enhance the quality and organizati
### `row-format-issue`
- **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.
- **Required**: No
- **Default**: `#{number} _{title}_ in {pull-requests}"`
- **Default**: `"{number} _{title}_ in {pull-requests}"`
MobiTikula marked this conversation as resolved.
Show resolved Hide resolved

### `row-format-pr`
- **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.
- **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.
- **Required**: No
- **Default**: `#{number} _{title}_"`
- **Default**: `"{number} _{title}_"`

### `row-format-link-pr`
- **Description**: If defined `true`, the PR row will begin with a `"PR: "` string. Otherwise, no prefix will be added.
Expand Down Expand Up @@ -164,32 +164,31 @@ Add the following step to your GitHub workflow (in example are used non-default
## Features
### Built-in
#### Release Notes Extraction Process
This feature searches for release notes in the description of GitHub pull requests, making it easier for maintainers to track changes and updates.
- **Format:**
- 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).
- If no release notes line is detected under the `Release Notes:` title, no release notes will be printed in the output.
- **Example:**
- Here are examples of how to structure the release notes:
```
Release Notes:
- This update introduces a new caching mechanism that improves performance by 20%.

This action requires that your GitHub issues include comments with specific release notes. Here's how it works:
Release Notes:
* This update introduces a new caching mechanism that improves performance by 20%.

**Extraction Method**:
- 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.
- 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.
Release Notes:
+ This update introduces a new caching mechanism that improves performance by 20%.

**Comment Format**
- 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.
- Here is an example of the content for a 'Release Notes' string, which is not case-sensitive:
```
Release Notes
- This update introduces a new caching mechanism that improves performance by 20%.
```
- Using `-` as a bullet point for each note is the best practice. The Markdown parser will automatically convert it to a list.
- 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.
The extraction process supports all three types of bullet points: `-`, `*`, and `+`, and their combinations. (GitHub documentation do not recommend to mix them.)

#### Contributors Mention
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.
- **Best Practice:** Select one character from `-`, `*`, `+` for bullet points. The Markdown parser will automatically format them as a list.
- **Optional usage:** The release notes section is not mandatory for GH action to work.

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

#### No Release Notes Found
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.

### Select start date for closed issues and PRs
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.

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

- **_Closed Issues Without Release Notes_**
- **Purpose**: Identifies issues that do not contain a "Release Notes" comment.
- **Purpose**: Identifies pull requests which do not contain a "Release Notes" section in description.
- **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.

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

This will execute all tests located in the tests directory and generate a code coverage report.
This will execute all tests located in the tests directory.

## Code Coverage

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

```
pytest --cov=release_notes_generator --cov-report html tests/
pytest --cov=. --cov-report=html tests/
```

This will execute all tests located in the tests directory and generate a code coverage report.

See the coverage report on the path:

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

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

### What will happen when Merged PR is linked to open issues?
The PR will be mentioned in warning chapter **Merged PRs Linked to Open Issue**.
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ inputs:
required: false
default: 'false'
row-format-issue:
description: 'Format of the issue row in the release notes. Available placeholders: {link}, {title}, {pull-requests}. Placeholders are case-insensitive.'
description: 'Format of the issue row in the release notes. Available placeholders: {number}, {title}, {pull-requests}. Placeholders are case-insensitive.'
required: false
default: '#{number} _{title}_ in {pull-requests}'
default: '{number} _{title}_ in {pull-requests}'
row-format-pr:
description: 'Format of the pr row in the release notes. Available placeholders: {link}, {title}, {pull-requests}. Placeholders are case-insensitive.'
description: 'Format of the pr row in the release notes. Available placeholders: {number}, {title}, {pull-requests}. Placeholders are case-insensitive.'
required: false
default: '#{number} _{title}_'
default: '{number} _{title}_'
row-format-link-pr:
description: 'Add prefix "PR:" before link to PR when not linked an Issue.'
required: false
Expand Down
Loading
Loading