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

add CHANGELOG #383

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

Since version unreleased the format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
This project (not yet) adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## unreleased
47 changes: 47 additions & 0 deletions changelog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### Changelogs

Temporary folder to add new changes. Each change should go into a separate file
(unless it makes sense to group some changes into one file, e.g. a story).
During release the changes will be moved to CHANGELOG.md.

Each file should follow one of the below naming patterns:

- \<issue number>.md
or
- \<story number>.md
or
- \<pr number>.md
or
- \<random number>.md if none of other apply

The content of the file should look like this:

```
### <type of change>
- description of the change in one or max two sentences (#<issue> or !<pr>)
```

< type of change > can be one of:

- **Added** for new features.
- **Changed**: for changes in existing functionality.
- **Deprecated**: for soon-to-be removed features.
- **Removed**: for now removed features.
- **Fixed**: for any bug fixes.
- **Security**: in case of vulnerabilities.

## Example

```
### Fixed
- improve userdashboard filter performance (#2449)
```

## Create release changelog

To create the changelog for a release you can either copy the content
of all the changelog files into CHANGELOG.md manually or use the
`parse_changelogs.py` in this folder by running it here:
`./parse_changelogs.py`.
3 changes: 3 additions & 0 deletions changelog/_0001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- add a CHANGELOG.md and changelog/ folder
59 changes: 59 additions & 0 deletions changelog/parse_changelogs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/python3

import logging
import os
import re
from collections import OrderedDict

logger = logging.getLogger(__name__)


def combine_sections_in_folder(folder_path):
"""Parser for changelog files following the https://keepachangelog.com
format.
"""
allowed_section_headers = [
"Added",
"Changed",
"Deprecated",
"Removed",
"Fixed",
"Security",
]
sections = OrderedDict()

for filename in os.listdir(folder_path):
if filename.endswith(".md") and filename != "README.md":
filepath = os.path.join(folder_path, filename)
with open(filepath, "r") as file:
current_section = None
for line in file:
# find all headings starting with # (they should always
# start with ### but we seem to sometimes use # or ##)
match = re.match(r"^#+ (.*)", line)
if match:
section_header = match.group(1).strip().capitalize()
if section_header not in allowed_section_headers:
logger.warning(
f"warning: section_header {section_header} "
f"in file {filename} is invalid, "
"see https://keepachangelog.com for a list of "
"allowed types."
)
current_section = sections.get(section_header, [])
elif current_section is not None and line.strip():
current_section.append(line)
sections[section_header] = current_section

combined_md = ""
for section_header, lines in sections.items():
combined_md += "### " + section_header + "\n\n"
combined_md += "".join(lines) + "\n"

return combined_md


if __name__ == "__main__":
folder_path = "."
combined_md = combine_sections_in_folder(folder_path)
print(combined_md)
Loading