Skip to content

Commit

Permalink
chore: Towncrier changelog support
Browse files Browse the repository at this point in the history
  • Loading branch information
snaselj committed Jan 4, 2024
1 parent 06073a6 commit dda44ce
Show file tree
Hide file tree
Showing 13 changed files with 256 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ mkdocs-version-annotations = "1.0.0"
# Automatic documentation from sources, for MkDocs
mkdocstrings = "0.22.0"
mkdocstrings-python = "1.5.2"
towncrier = "~23.6.0"

[tool.poetry.extras]
all = [
Expand Down Expand Up @@ -127,3 +128,56 @@ add_ignore = "D212"
[build-system]
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.towncrier]
package = "nautobot"
directory = "changes"
filename = "docs/admin/release_notes/version_X.Y.md"
template = "development/towncrier_template.j2"
start_string = "<!-- towncrier release notes start -->"
issue_format = "[#{issue}](https://github.com/nautobot/nautobot/issues/{issue})"

[[tool.towncrier.type]]
directory = "security"
name = "Security"
showcontent = true

[[tool.towncrier.type]]
directory = "added"
name = "Added"
showcontent = true

[[tool.towncrier.type]]
directory = "changed"
name = "Changed"
showcontent = true

[[tool.towncrier.type]]
directory = "deprecated"
name = "Deprecated"
showcontent = true

[[tool.towncrier.type]]
directory = "removed"
name = "Removed"
showcontent = true

[[tool.towncrier.type]]
directory = "fixed"
name = "Fixed"
showcontent = true

[[tool.towncrier.type]]
directory = "dependencies"
name = "Dependencies"
showcontent = true

[[tool.towncrier.type]]
directory = "documentation"
name = "Documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "housekeeping"
name = "Housekeeping"
showcontent = true
1 change: 1 addition & 0 deletions nautobot-app-ssot/{{ cookiecutter.project_slug }}/changes
54 changes: 54 additions & 0 deletions nautobot-app-ssot/{{ cookiecutter.project_slug }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mkdocs-version-annotations = "1.0.0"
# Automatic documentation from sources, for MkDocs
mkdocstrings = "0.22.0"
mkdocstrings-python = "1.5.2"
towncrier = "~23.6.0"

[tool.poetry.extras]
all = [
Expand Down Expand Up @@ -124,3 +125,56 @@ add_ignore = "D212"
[build-system]
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.towncrier]
package = "nautobot"
directory = "changes"
filename = "docs/admin/release_notes/version_X.Y.md"
template = "development/towncrier_template.j2"
start_string = "<!-- towncrier release notes start -->"
issue_format = "[#{issue}](https://github.com/nautobot/nautobot/issues/{issue})"

[[tool.towncrier.type]]
directory = "security"
name = "Security"
showcontent = true

[[tool.towncrier.type]]
directory = "added"
name = "Added"
showcontent = true

[[tool.towncrier.type]]
directory = "changed"
name = "Changed"
showcontent = true

[[tool.towncrier.type]]
directory = "deprecated"
name = "Deprecated"
showcontent = true

[[tool.towncrier.type]]
directory = "removed"
name = "Removed"
showcontent = true

[[tool.towncrier.type]]
directory = "fixed"
name = "Fixed"
showcontent = true

[[tool.towncrier.type]]
directory = "dependencies"
name = "Dependencies"
showcontent = true

[[tool.towncrier.type]]
directory = "documentation"
name = "Documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "housekeeping"
name = "Housekeeping"
showcontent = true
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Please feel free to update todos to keep track of your own notes for WIP PRs.
-->
- [ ] Explanation of Change(s)
- [ ] Added change log fragment(s) (for more information see [the documentation](https://docs.nautobot.com/projects/core/en/stable/development/#creating-changelog-fragments))
- [ ] Attached Screenshots, Payload Example
- [ ] Unit, Integration Tests
- [ ] Documentation Updates (when adding/changing features)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@ jobs:
if: "matrix.db-backend == 'mysql'"
- name: "Run Tests"
run: "poetry run invoke unittest"
changelog:
if: contains(fromJson('["develop","ltm-1.6"]'), github.base_ref)
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
fetch-depth: "0"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Check for changelog entry"
run: |
{% raw %-}
git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
poetry run towncrier check --compare-with origin/${{ github.base_ref }}
{% endraw %}
publish_gh:
needs:
- "unittest"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% raw %}
{% if render_title %}
## v{{ versiondata.version }} ({{ versiondata.date }})

{% endif %}
{% for section, _ in sections.items() %}
{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section] %}
{% if sections[section][category]|length != 0 %}
### {{ definitions[category]['name'] }}

{% if definitions[category]['showcontent'] %}
{% for text, values in sections[section][category].items() %}
{% for item in text.split('\n') %}
- {{ values|join(', ') }} - {{ item.strip() }}
{% endfor %}
{% endfor %}

{% else %}
- {{ sections[section][category]['']|join(', ') }}

{% endif %}
{% endif %}
{% endfor %}
{% else %}
No significant changes.

{% endif %}
{% endfor %}
{% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,35 @@ The project is following Network to Code software development guidelines and is

Documentation is built using [mkdocs](https://www.mkdocs.org/). The [Docker based development environment](dev_environment.md#docker-development-environment) automatically starts a container hosting a live version of the documentation website on [http://localhost:8001](http://localhost:8001) that auto-refreshes when you make any changes to your local files.

## Creating Changelog Fragments

All pull requests to `next` or `develop` must include a changelog fragment file in the `./changes` directory. To create a fragment, use your GitHub issue number and fragment type as the filename. For example, `2362.added`. Valid fragment types are `added`, `changed`, `deprecated`, `fixed`, `removed`, and `security`. The change summary is added to the file in plain text. Change summaries should be complete sentences, starting with a capital letter and ending with a period, and be in past tense. Each line of the change fragment will generate a single change entry in the release notes. Use multiple lines in the same file if your change needs to generate multiple release notes in the same category. If the change needs to create multiple entries in separate categories, create multiple files.

!!! example

**Wrong**
```plaintext title="changes/1234.fixed"
fix critical bug in documentation
```

**Right**
```plaintext title="changes/1234.fixed"
Fixed critical bug in documentation.
```

!!! example "Multiple Entry Example"

This will generate 2 entries in the `fixed` category and one entry in the `changed` category.

```plaintext title="changes/1234.fixed"
Fixed critical bug in documentation.
Fixed release notes generation.
```

```plaintext title="changes/1234.changed"
Changed release notes generation.
```

## Branching Policy

!!! warning "Developer Note - Remove Me!"
Expand Down
54 changes: 54 additions & 0 deletions nautobot-app/{{ cookiecutter.project_slug }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ mkdocs-version-annotations = "1.0.0"
# Automatic documentation from sources, for MkDocs
mkdocstrings = "0.22.0"
mkdocstrings-python = "1.5.2"
towncrier = "~23.6.0"

[tool.poetry.extras]
all = [
Expand Down Expand Up @@ -123,3 +124,56 @@ add_ignore = "D212"
[build-system]
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.towncrier]
package = "nautobot"
directory = "changes"
filename = "docs/admin/release_notes/version_X.Y.md"
template = "development/towncrier_template.j2"
start_string = "<!-- towncrier release notes start -->"
issue_format = "[#{issue}](https://github.com/nautobot/nautobot/issues/{issue})"

[[tool.towncrier.type]]
directory = "security"
name = "Security"
showcontent = true

[[tool.towncrier.type]]
directory = "added"
name = "Added"
showcontent = true

[[tool.towncrier.type]]
directory = "changed"
name = "Changed"
showcontent = true

[[tool.towncrier.type]]
directory = "deprecated"
name = "Deprecated"
showcontent = true

[[tool.towncrier.type]]
directory = "removed"
name = "Removed"
showcontent = true

[[tool.towncrier.type]]
directory = "fixed"
name = "Fixed"
showcontent = true

[[tool.towncrier.type]]
directory = "dependencies"
name = "Dependencies"
showcontent = true

[[tool.towncrier.type]]
directory = "documentation"
name = "Documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "housekeeping"
name = "Housekeeping"
showcontent = true
13 changes: 13 additions & 0 deletions nautobot-app/{{ cookiecutter.project_slug }}/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,19 @@ def help_task(context):
context.run(f"invoke {task_name} --help")


@task(
help={
"version": "Version of {{ cookiecutter.verbose_name }} to generate the release notes for.",
}
)
def generate_release_notes(context, version=""):
"""Generate Release Notes using Towncrier."""
command = "env DJANGO_SETTINGS_MODULE=nautobot.core.settings towncrier build"
if version:
command += f" --version {version}"
run_command(context, command)


# ------------------------------------------------------------------------------
# TESTS
# ------------------------------------------------------------------------------
Expand Down

0 comments on commit dda44ce

Please sign in to comment.